Backends: OpenGL3: Fix state corruption on OpenGL ES 2.0 due to not preserving GL_ELEMENT_ARRAY_BUFFER_BINDING and vertex attribute states.

This change partially reverts 9770c8b21d.
This commit is contained in:
Rokas Kupstys 2021-08-30 13:59:43 +03:00 committed by ocornut
parent 507a87354b
commit b7686a88e9
3 changed files with 183 additions and 109 deletions

View File

@ -14,6 +14,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2022-05-05: OpenGL: Fix state corruption on OpenGL ES 2.0 due to not preserving GL_ELEMENT_ARRAY_BUFFER_BINDING and vertex attribute states.
// 2021-12-15: OpenGL: Using buffer orphaning + glBufferSubData(), seems to fix leaks with multi-viewports with some Intel HD drivers. // 2021-12-15: OpenGL: Using buffer orphaning + glBufferSubData(), seems to fix leaks with multi-viewports with some Intel HD drivers.
// 2021-08-23: OpenGL: Fixed ES 3.0 shader ("#version 300 es") use normal precision floats to avoid wobbly rendering at HD resolutions. // 2021-08-23: OpenGL: Fixed ES 3.0 shader ("#version 300 es") use normal precision floats to avoid wobbly rendering at HD resolutions.
// 2021-08-19: OpenGL: Embed and use our own minimal GL loader (imgui_impl_opengl3_loader.h), removing requirement and support for third-party loader. // 2021-08-19: OpenGL: Embed and use our own minimal GL loader (imgui_impl_opengl3_loader.h), removing requirement and support for third-party loader.
@ -203,6 +204,35 @@ static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData()
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : NULL; return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
} }
// OpenGL vertex attribute state
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
struct ImGui_ImplOpenGL3_VtxAttribState
{
GLint Enabled;
GLint Size;
GLint Type;
GLint Normalized;
GLint Stride;
GLvoid* Ptr;
};
static void ImGui_ImplOpenGL3_BackupVertexAttribState(GLint index, ImGui_ImplOpenGL3_VtxAttribState* state)
{
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &state->Enabled);
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_SIZE, &state->Size);
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_TYPE, &state->Type);
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &state->Normalized);
glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &state->Stride);
glGetVertexAttribPointerv(index, GL_VERTEX_ATTRIB_ARRAY_POINTER, &state->Ptr);
}
static void ImGui_ImplOpenGL3_RestoreVertexAttribState(GLint index, ImGui_ImplOpenGL3_VtxAttribState* state)
{
glVertexAttribPointer(index, state->Size, state->Type, state->Normalized, state->Stride, state->Ptr);
if (state->Enabled) glEnableVertexAttribArray(index); else glDisableVertexAttribArray(index);
}
#endif
// Functions // Functions
bool ImGui_ImplOpenGL3_Init(const char* glsl_version) bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
{ {
@ -400,6 +430,15 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
GLuint last_sampler; if (bd->GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; } GLuint last_sampler; if (bd->GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
#endif #endif
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer); GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
// This is part of VAO on OpenGL 3.0+ and OpenGL ES 3.0+.
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
ImGui_ImplOpenGL3_VtxAttribState last_vtx_attrib_state_pos, last_vtx_attrib_state_uv, last_vtx_attrib_state_color;
ImGui_ImplOpenGL3_BackupVertexAttribState(bd->AttribLocationVtxPos, &last_vtx_attrib_state_pos);
ImGui_ImplOpenGL3_BackupVertexAttribState(bd->AttribLocationVtxUV, &last_vtx_attrib_state_uv);
ImGui_ImplOpenGL3_BackupVertexAttribState(bd->AttribLocationVtxColor, &last_vtx_attrib_state_color);
#endif
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY #ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object); GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
#endif #endif
@ -509,6 +548,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
glBindVertexArray(last_vertex_array_object); glBindVertexArray(last_vertex_array_object);
#endif #endif
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
#ifndef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
ImGui_ImplOpenGL3_RestoreVertexAttribState(bd->AttribLocationVtxPos, &last_vtx_attrib_state_pos);
ImGui_ImplOpenGL3_RestoreVertexAttribState(bd->AttribLocationVtxUV, &last_vtx_attrib_state_uv);
ImGui_ImplOpenGL3_RestoreVertexAttribState(bd->AttribLocationVtxColor, &last_vtx_attrib_state_color);
#endif
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha); glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);

View File

@ -177,6 +177,7 @@ typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap);
typedef void (APIENTRYP PFNGLFLUSHPROC) (void);
typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
@ -193,6 +194,7 @@ GLAPI void APIENTRY glClear (GLbitfield mask);
GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GLAPI void APIENTRY glDisable (GLenum cap); GLAPI void APIENTRY glDisable (GLenum cap);
GLAPI void APIENTRY glEnable (GLenum cap); GLAPI void APIENTRY glEnable (GLenum cap);
GLAPI void APIENTRY glFlush (void);
GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param);
GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
GLAPI GLenum APIENTRY glGetError (void); GLAPI GLenum APIENTRY glGetError (void);
@ -244,6 +246,7 @@ typedef khronos_intptr_t GLintptr;
#define GL_ARRAY_BUFFER 0x8892 #define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0 #define GL_STREAM_DRAW 0x88E0
typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
@ -264,7 +267,13 @@ typedef khronos_int16_t GLshort;
typedef khronos_int8_t GLbyte; typedef khronos_int8_t GLbyte;
typedef khronos_uint16_t GLushort; typedef khronos_uint16_t GLushort;
#define GL_BLEND_EQUATION_RGB 0x8009 #define GL_BLEND_EQUATION_RGB 0x8009
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_BLEND_EQUATION_ALPHA 0x883D #define GL_BLEND_EQUATION_ALPHA 0x883D
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_FRAGMENT_SHADER 0x8B30 #define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31 #define GL_VERTEX_SHADER 0x8B31
#define GL_COMPILE_STATUS 0x8B81 #define GL_COMPILE_STATUS 0x8B81
@ -280,6 +289,7 @@ typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
@ -287,6 +297,8 @@ typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei buf
typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer);
typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
@ -302,6 +314,7 @@ GLAPI GLuint APIENTRY glCreateShader (GLenum type);
GLAPI void APIENTRY glDeleteProgram (GLuint program); GLAPI void APIENTRY glDeleteProgram (GLuint program);
GLAPI void APIENTRY glDeleteShader (GLuint shader); GLAPI void APIENTRY glDeleteShader (GLuint shader);
GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
@ -309,6 +322,8 @@ GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsize
GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
GLAPI void APIENTRY glLinkProgram (GLuint program); GLAPI void APIENTRY glLinkProgram (GLuint program);
GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
GLAPI void APIENTRY glUseProgram (GLuint program); GLAPI void APIENTRY glUseProgram (GLuint program);
@ -437,122 +452,130 @@ GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
/* gl3w internal state */ /* gl3w internal state */
union GL3WProcs { union GL3WProcs {
GL3WglProc ptr[54]; GL3WglProc ptr[58];
struct { struct {
PFNGLACTIVETEXTUREPROC ActiveTexture; PFNGLACTIVETEXTUREPROC ActiveTexture;
PFNGLATTACHSHADERPROC AttachShader; PFNGLATTACHSHADERPROC AttachShader;
PFNGLBINDBUFFERPROC BindBuffer; PFNGLBINDBUFFERPROC BindBuffer;
PFNGLBINDSAMPLERPROC BindSampler; PFNGLBINDSAMPLERPROC BindSampler;
PFNGLBINDTEXTUREPROC BindTexture; PFNGLBINDTEXTUREPROC BindTexture;
PFNGLBINDVERTEXARRAYPROC BindVertexArray; PFNGLBINDVERTEXARRAYPROC BindVertexArray;
PFNGLBLENDEQUATIONPROC BlendEquation; PFNGLBLENDEQUATIONPROC BlendEquation;
PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate; PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate;
PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate; PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
PFNGLBUFFERDATAPROC BufferData; PFNGLBUFFERDATAPROC BufferData;
PFNGLBUFFERSUBDATAPROC BufferSubData; PFNGLBUFFERSUBDATAPROC BufferSubData;
PFNGLCLEARPROC Clear; PFNGLCLEARPROC Clear;
PFNGLCLEARCOLORPROC ClearColor; PFNGLCLEARCOLORPROC ClearColor;
PFNGLCOMPILESHADERPROC CompileShader; PFNGLCOMPILESHADERPROC CompileShader;
PFNGLCREATEPROGRAMPROC CreateProgram; PFNGLCREATEPROGRAMPROC CreateProgram;
PFNGLCREATESHADERPROC CreateShader; PFNGLCREATESHADERPROC CreateShader;
PFNGLDELETEBUFFERSPROC DeleteBuffers; PFNGLDELETEBUFFERSPROC DeleteBuffers;
PFNGLDELETEPROGRAMPROC DeleteProgram; PFNGLDELETEPROGRAMPROC DeleteProgram;
PFNGLDELETESHADERPROC DeleteShader; PFNGLDELETESHADERPROC DeleteShader;
PFNGLDELETETEXTURESPROC DeleteTextures; PFNGLDELETETEXTURESPROC DeleteTextures;
PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays; PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
PFNGLDETACHSHADERPROC DetachShader; PFNGLDETACHSHADERPROC DetachShader;
PFNGLDISABLEPROC Disable; PFNGLDISABLEPROC Disable;
PFNGLDRAWELEMENTSPROC DrawElements; PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex; PFNGLDRAWELEMENTSPROC DrawElements;
PFNGLENABLEPROC Enable; PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex;
PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; PFNGLENABLEPROC Enable;
PFNGLGENBUFFERSPROC GenBuffers; PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
PFNGLGENTEXTURESPROC GenTextures; PFNGLFLUSHPROC Flush;
PFNGLGENVERTEXARRAYSPROC GenVertexArrays; PFNGLGENBUFFERSPROC GenBuffers;
PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; PFNGLGENTEXTURESPROC GenTextures;
PFNGLGETERRORPROC GetError; PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
PFNGLGETINTEGERVPROC GetIntegerv; PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; PFNGLGETERRORPROC GetError;
PFNGLGETPROGRAMIVPROC GetProgramiv; PFNGLGETINTEGERVPROC GetIntegerv;
PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
PFNGLGETSHADERIVPROC GetShaderiv; PFNGLGETPROGRAMIVPROC GetProgramiv;
PFNGLGETSTRINGPROC GetString; PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
PFNGLGETSTRINGIPROC GetStringi; PFNGLGETSHADERIVPROC GetShaderiv;
PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; PFNGLGETSTRINGPROC GetString;
PFNGLISENABLEDPROC IsEnabled; PFNGLGETSTRINGIPROC GetStringi;
PFNGLLINKPROGRAMPROC LinkProgram; PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation;
PFNGLPIXELSTOREIPROC PixelStorei; PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv;
PFNGLPOLYGONMODEPROC PolygonMode; PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv;
PFNGLREADPIXELSPROC ReadPixels; PFNGLISENABLEDPROC IsEnabled;
PFNGLSCISSORPROC Scissor; PFNGLLINKPROGRAMPROC LinkProgram;
PFNGLSHADERSOURCEPROC ShaderSource; PFNGLPIXELSTOREIPROC PixelStorei;
PFNGLTEXIMAGE2DPROC TexImage2D; PFNGLPOLYGONMODEPROC PolygonMode;
PFNGLTEXPARAMETERIPROC TexParameteri; PFNGLREADPIXELSPROC ReadPixels;
PFNGLUNIFORM1IPROC Uniform1i; PFNGLSCISSORPROC Scissor;
PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; PFNGLSHADERSOURCEPROC ShaderSource;
PFNGLUSEPROGRAMPROC UseProgram; PFNGLTEXIMAGE2DPROC TexImage2D;
PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; PFNGLTEXPARAMETERIPROC TexParameteri;
PFNGLVIEWPORTPROC Viewport; PFNGLUNIFORM1IPROC Uniform1i;
PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv;
PFNGLUSEPROGRAMPROC UseProgram;
PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
PFNGLVIEWPORTPROC Viewport;
} gl; } gl;
}; };
GL3W_API extern union GL3WProcs imgl3wProcs; GL3W_API extern union GL3WProcs imgl3wProcs;
/* OpenGL functions */ /* OpenGL functions */
#define glActiveTexture imgl3wProcs.gl.ActiveTexture #define glActiveTexture imgl3wProcs.gl.ActiveTexture
#define glAttachShader imgl3wProcs.gl.AttachShader #define glAttachShader imgl3wProcs.gl.AttachShader
#define glBindBuffer imgl3wProcs.gl.BindBuffer #define glBindBuffer imgl3wProcs.gl.BindBuffer
#define glBindSampler imgl3wProcs.gl.BindSampler #define glBindSampler imgl3wProcs.gl.BindSampler
#define glBindTexture imgl3wProcs.gl.BindTexture #define glBindTexture imgl3wProcs.gl.BindTexture
#define glBindVertexArray imgl3wProcs.gl.BindVertexArray #define glBindVertexArray imgl3wProcs.gl.BindVertexArray
#define glBlendEquation imgl3wProcs.gl.BlendEquation #define glBlendEquation imgl3wProcs.gl.BlendEquation
#define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate #define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate
#define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate #define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate
#define glBufferData imgl3wProcs.gl.BufferData #define glBufferData imgl3wProcs.gl.BufferData
#define glBufferSubData imgl3wProcs.gl.BufferSubData #define glBufferSubData imgl3wProcs.gl.BufferSubData
#define glClear imgl3wProcs.gl.Clear #define glClear imgl3wProcs.gl.Clear
#define glClearColor imgl3wProcs.gl.ClearColor #define glClearColor imgl3wProcs.gl.ClearColor
#define glCompileShader imgl3wProcs.gl.CompileShader #define glCompileShader imgl3wProcs.gl.CompileShader
#define glCreateProgram imgl3wProcs.gl.CreateProgram #define glCreateProgram imgl3wProcs.gl.CreateProgram
#define glCreateShader imgl3wProcs.gl.CreateShader #define glCreateShader imgl3wProcs.gl.CreateShader
#define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers #define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers
#define glDeleteProgram imgl3wProcs.gl.DeleteProgram #define glDeleteProgram imgl3wProcs.gl.DeleteProgram
#define glDeleteShader imgl3wProcs.gl.DeleteShader #define glDeleteShader imgl3wProcs.gl.DeleteShader
#define glDeleteTextures imgl3wProcs.gl.DeleteTextures #define glDeleteTextures imgl3wProcs.gl.DeleteTextures
#define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays #define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays
#define glDetachShader imgl3wProcs.gl.DetachShader #define glDetachShader imgl3wProcs.gl.DetachShader
#define glDisable imgl3wProcs.gl.Disable #define glDisable imgl3wProcs.gl.Disable
#define glDrawElements imgl3wProcs.gl.DrawElements #define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray
#define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex #define glDrawElements imgl3wProcs.gl.DrawElements
#define glEnable imgl3wProcs.gl.Enable #define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex
#define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray #define glEnable imgl3wProcs.gl.Enable
#define glGenBuffers imgl3wProcs.gl.GenBuffers #define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray
#define glGenTextures imgl3wProcs.gl.GenTextures #define glFlush imgl3wProcs.gl.Flush
#define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays #define glGenBuffers imgl3wProcs.gl.GenBuffers
#define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation #define glGenTextures imgl3wProcs.gl.GenTextures
#define glGetError imgl3wProcs.gl.GetError #define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays
#define glGetIntegerv imgl3wProcs.gl.GetIntegerv #define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation
#define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog #define glGetError imgl3wProcs.gl.GetError
#define glGetProgramiv imgl3wProcs.gl.GetProgramiv #define glGetIntegerv imgl3wProcs.gl.GetIntegerv
#define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog #define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog
#define glGetShaderiv imgl3wProcs.gl.GetShaderiv #define glGetProgramiv imgl3wProcs.gl.GetProgramiv
#define glGetString imgl3wProcs.gl.GetString #define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog
#define glGetStringi imgl3wProcs.gl.GetStringi #define glGetShaderiv imgl3wProcs.gl.GetShaderiv
#define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation #define glGetString imgl3wProcs.gl.GetString
#define glIsEnabled imgl3wProcs.gl.IsEnabled #define glGetStringi imgl3wProcs.gl.GetStringi
#define glLinkProgram imgl3wProcs.gl.LinkProgram #define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation
#define glPixelStorei imgl3wProcs.gl.PixelStorei #define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv
#define glPolygonMode imgl3wProcs.gl.PolygonMode #define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv
#define glReadPixels imgl3wProcs.gl.ReadPixels #define glIsEnabled imgl3wProcs.gl.IsEnabled
#define glScissor imgl3wProcs.gl.Scissor #define glLinkProgram imgl3wProcs.gl.LinkProgram
#define glShaderSource imgl3wProcs.gl.ShaderSource #define glPixelStorei imgl3wProcs.gl.PixelStorei
#define glTexImage2D imgl3wProcs.gl.TexImage2D #define glPolygonMode imgl3wProcs.gl.PolygonMode
#define glTexParameteri imgl3wProcs.gl.TexParameteri #define glReadPixels imgl3wProcs.gl.ReadPixels
#define glUniform1i imgl3wProcs.gl.Uniform1i #define glScissor imgl3wProcs.gl.Scissor
#define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv #define glShaderSource imgl3wProcs.gl.ShaderSource
#define glUseProgram imgl3wProcs.gl.UseProgram #define glTexImage2D imgl3wProcs.gl.TexImage2D
#define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer #define glTexParameteri imgl3wProcs.gl.TexParameteri
#define glViewport imgl3wProcs.gl.Viewport #define glUniform1i imgl3wProcs.gl.Uniform1i
#define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv
#define glUseProgram imgl3wProcs.gl.UseProgram
#define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer
#define glViewport imgl3wProcs.gl.Viewport
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -709,10 +732,12 @@ static const char *proc_names[] = {
"glDeleteVertexArrays", "glDeleteVertexArrays",
"glDetachShader", "glDetachShader",
"glDisable", "glDisable",
"glDisableVertexAttribArray",
"glDrawElements", "glDrawElements",
"glDrawElementsBaseVertex", "glDrawElementsBaseVertex",
"glEnable", "glEnable",
"glEnableVertexAttribArray", "glEnableVertexAttribArray",
"glFlush",
"glGenBuffers", "glGenBuffers",
"glGenTextures", "glGenTextures",
"glGenVertexArrays", "glGenVertexArrays",
@ -726,6 +751,8 @@ static const char *proc_names[] = {
"glGetString", "glGetString",
"glGetStringi", "glGetStringi",
"glGetUniformLocation", "glGetUniformLocation",
"glGetVertexAttribPointerv",
"glGetVertexAttribiv",
"glIsEnabled", "glIsEnabled",
"glLinkProgram", "glLinkProgram",
"glPixelStorei", "glPixelStorei",

View File

@ -249,6 +249,8 @@ Other Changes:
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk] - Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]
It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers. It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers.
- Backends: OpenGL3: Fix OpenGL ES2 includes on Apple systems. [@rokups] - Backends: OpenGL3: Fix OpenGL ES2 includes on Apple systems. [@rokups]
- Backends: OpenGL3: Fix state corruption on OpenGL ES 2.0 due to not preserving GL_ELEMENT_ARRAY_BUFFER_BINDING and vertex
attribute states. [@rokups]
- Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz] - Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz]
Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file. Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file.
- Backends: Metal: Ignore ImDrawCmd where ElemCount == 0, which are normally not emitted by the library but - Backends: Metal: Ignore ImDrawCmd where ElemCount == 0, which are normally not emitted by the library but