1#include "GraphicsDeviceGLES30.h"
3#include "FormatsGLES30.h"
5#include "Foundation/Platform/WindowData.h"
7#include "../Base/Utilities.h"
13Cogs::GraphicsDeviceGLES30::GraphicsDeviceGLES30(RenderingAllocatorInfo*)
17Cogs::GraphicsDeviceGLES30::~GraphicsDeviceGLES30()
19 if (glContext.makeCurrent()) {
27 if (
reinterpret_cast<void*
>(settings.windowData->windowHandle) ==
nullptr) {
28 LOG_ERROR(logger,
"No window handle");
34 GLContext::NativeDisplay display = settings.windowData->display;
36 GLContext::NativeDisplay display = (GLContext::NativeDisplay)
nullptr;
38 if (!glContext.create(display, settings.windowData,
nullptr, &settings, GLContext::Platform::ES3, enableDiagnostics)) {
41 glContext.makeCurrent();
45 if(!has_glClipControl()) useClipControl =
false;
46#elif defined(__APPLE__)
47 useClipControl =
false;
49 if(!glClipControl) useClipControl =
false;
52 capabilities.initialize(glContext.platform == GLContext::Platform::GL, useClipControl);
53 buffers.initialize(&capabilities, &context, &effects);
54 textures.initialize(&context, &capabilities);
55 context.initialize(&buffers, &textures, &effects, &renderTargets, &capabilities, &syncObjects);
56 renderTargets.initialize(&capabilities, &textures);
57 effects.initialize(&context);
59 if (settings.ioHandler) effects.setIOHandler(settings.ioHandler);
63 LOG_DEBUG(logger,
"glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE)");
64 glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
73 if (width == this->width && height == this->height)
return;
76 this->height = height;
78 LOG_TRACE(logger,
"Resize(%d, %d)", width, height);
80 CHECKED(glViewport(0, 0, width, height));
85 glContext.makeCurrent();
86 glEnable(GL_DEPTH_TEST);
88 context.frameStatisticsBeginFrame();
89 context.setDefaults();
94 context.clearCachedState();
95 glContext.swapBuffers(syncInterval, presentFlags);
100 effects.releaseResources();
101 renderTargets.releaseResources();
102 textures.releaseResources();
103 buffers.releaseResources();
110 stats.bufferMemoryConsumption = buffers.bufferMemoryConsumption;
111 stats.textureMemoryConsumption = textures.textureMemoryConsumption;
112 stats.bufferCount =
static_cast<uint32_t
>(buffers.buffers.size());
113 stats.vertexArrayObjectCount =
static_cast<uint32_t
>(buffers.vertexArrayObjects.size());
114 stats.inputLayoutCount =
static_cast<uint32_t
>(buffers.inputLayouts.size());
115 stats.textureCount =
static_cast<uint32_t
>(textures.textures.size());
116 stats.samplerStateCount = 0;
117 stats.effectCount =
static_cast<uint32_t
>(effects.effects.size());
118 stats.blendStateCount =
static_cast<uint32_t
>(renderTargets.blendStates.size());
119 stats.rasterizerStateCount =
static_cast<uint32_t
>(renderTargets.rasterizerStates.size());
120 stats.depthStencilStateCount =
static_cast<uint32_t
>(renderTargets.depthStencilStates.size());
121 stats.rendertargetsCount =
static_cast<uint32_t
>(renderTargets.renderTargets.size());
122 stats.framebufferCount = 0;
Log implementation class.
constexpr Log getLogger(const char(&name)[LEN]) noexcept
PresentFlags
Flags controlling presentation.
@ EnableDiagnostics
If available, the device will print diagnostic information to the log.
@ UseOpenGLClipControl
For OpenGL / OpenGLES backends.
bool initialize()
Initializes the graphics device with the settings previous set through calling setSettings.
void setSize(int width, int height) override
Set the size of the main drawing buffer used by the graphics device in pixels.
void endFrame(uint32_t syncInterval=0, PresentFlags presentFlags=PresentFlags::None) override
Signal the end of a frame to the graphics device.
void releaseResources() override
Release all resources allocated.
void beginFrame() override
Signal the beginning of a new frame to the graphics device.