Skip to content

Commit

Permalink
[GLES] Various GLES fixes.
Browse files Browse the repository at this point in the history
- Removed ARB_clip_control from GLES backend since it's not supported on mobile.
- Enable OutputDebug states in GLES if GL_KHR_debug extension is available.
- Include <GLES2/gl2ext.h> header for Android to load extensions dynamically.
  • Loading branch information
LukasBanana committed Aug 5, 2024
1 parent b9aa01d commit 4949862
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ bool LoadSupportedOpenGLExtensions(bool isCoreProfile, bool abortOnFailure)

ENABLE_GLEXT(ARB_clear_buffer_object);
ENABLE_GLEXT(ARB_clear_texture);
ENABLE_GLEXT(ARB_clip_control);
ENABLE_GLEXT(ARB_buffer_storage);
ENABLE_GLEXT(ARB_copy_buffer);
ENABLE_GLEXT(ARB_draw_buffers);
Expand Down
3 changes: 2 additions & 1 deletion sources/Renderer/OpenGL/GLESProfile/OpenGLES.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# include <OpenGLES/ES3/gl.h>
# include <OpenGLES/ES3/glext.h>
#elif defined(LLGL_OS_ANDROID)
// Include all GLES 3.0 functions with static linkage
// Include all GLES 3.0 functions with static linkage as well as GLES2 extensions
# include <GLES3/gl3.h>
# include <GLES2/gl2ext.h>

// Include all GLES 3.1+ functions as extensions with dynamic linkage
# ifdef GL_GLES_PROTOTYPES
Expand Down
11 changes: 7 additions & 4 deletions sources/Renderer/OpenGL/GLRenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,10 +592,13 @@ void GLRenderSystem::RegisterNewGLContext(GLContext& /*context*/, const GLPixelF
EnableDebugCallback();
}

#ifdef GL_KHR_debug
#if GL_KHR_debug

void APIENTRY GLDebugCallback(
GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* /*userParam*/)
#ifdef LLGL_OPENGL
void APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* /*userParam*/)
#else
void GL_APIENTRY GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* /*userParam*/)
#endif
{
/* Forward callback to log */
DebugPrintf(
Expand All @@ -613,7 +616,7 @@ struct GLDebugMessageMetaData

void GLRenderSystem::EnableDebugCallback(bool enable)
{
#ifdef GL_KHR_debug
#if GL_KHR_debug

if (HasExtension(GLExt::KHR_debug))
{
Expand Down
7 changes: 7 additions & 0 deletions sources/Renderer/OpenGL/RenderState/GLContextState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ namespace LLGL
{


constexpr GLuint GLContextState::numTextureLayers;
constexpr GLuint GLContextState::numImageUnits;
constexpr GLuint GLContextState::numCaps;
constexpr GLuint GLContextState::numBufferTargets;
constexpr GLuint GLContextState::numFboTargets;
constexpr GLuint GLContextState::numTextureTargets;

static void GLGetValue(GLenum pname, GLint& params)
{
glGetIntegerv(pname, &params);
Expand Down
4 changes: 2 additions & 2 deletions sources/Renderer/OpenGL/RenderState/GLState.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ enum class GLState
{
Blend = 0, // GL_BLEND
CullFace, // GL_CULL_FACE
DebugOutput, // GL_DEBUG_OUTPUT
DebugOutputSynchronous, // GL_DEBUG_OUTPUT_SYNCHRONOUS
DepthTest, // GL_DEPTH_TEST
Dither, // GL_DITHER
PolygonOffsetFill, // GL_POLYGON_OFFSET_FILL
Expand All @@ -40,8 +42,6 @@ enum class GLState

ColorLogicOp, // GL_COLOR_LOGIC_OP
DepthClamp, // GL_DEPTH_CLAMP
DebugOutput, // GL_DEBUG_OUTPUT
DebugOutputSynchronous, // GL_DEBUG_OUTPUT_SYNCHRONOUS
FramebufferSRGB, // GL_FRAMEBUFFER_SRGB
LineSmooth, // GL_LINE_SMOOTH
Multisample, // GL_MULTISAMPLE
Expand Down
9 changes: 7 additions & 2 deletions sources/Renderer/OpenGL/RenderState/GLStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ static const GLenum g_stateCapsEnum[] =
{
GL_BLEND,
GL_CULL_FACE,
#if GL_KHR_debug
GL_DEBUG_OUTPUT,
GL_DEBUG_OUTPUT_SYNCHRONOUS,
#else
0,
0,
#endif
GL_DEPTH_TEST,
GL_DITHER,
GL_POLYGON_OFFSET_FILL,
Expand All @@ -57,8 +64,6 @@ static const GLenum g_stateCapsEnum[] =
#ifdef LLGL_OPENGL
GL_COLOR_LOGIC_OP,
GL_DEPTH_CLAMP,
GL_DEBUG_OUTPUT,
GL_DEBUG_OUTPUT_SYNCHRONOUS,
GL_FRAMEBUFFER_SRGB,
GL_LINE_SMOOTH,
GL_MULTISAMPLE,
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/Texture/GLRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void GLRenderTarget::BuildResolveAttachment(const AttachmentDescriptor& attachme

void GLRenderTarget::BuildDepthStencilAttachment(const AttachmentDescriptor& attachmentDesc)
{
if (auto* texture = attachmentDesc.texture)
if (const Texture* texture = attachmentDesc.texture)
BuildAttachmentWithTexture(AllocDepthStencilAttachmentBinding(texture->GetFormat()), attachmentDesc);
else
BuildAttachmentWithRenderbuffer(AllocDepthStencilAttachmentBinding(attachmentDesc.format), attachmentDesc.format);
Expand Down

0 comments on commit 4949862

Please sign in to comment.