@ -514,6 +514,14 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
if ( ! g_IsGLES & & g_GlVersion > = 200 )
glPolygonMode ( GL_FRONT_AND_BACK , GL_FILL ) ;
bool clip_origin_lower_left = true ;
GLenum last_clip_origin = 0 ;
if ( ! g_IsGLES & & /*g_GlVersion >= 450*/ ( glad_glClipControl | | glad_glClipControlEXT ) ) {
glGetIntegerv ( GL_CLIP_ORIGIN , ( GLint * ) & last_clip_origin ) ; // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
if ( last_clip_origin = = GL_UPPER_LEFT )
clip_origin_lower_left = false ;
}
// Setup viewport, orthographic projection matrix
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
glViewport ( 0 , 0 , ( GLsizei ) fb_width , ( GLsizei ) fb_height ) ;
@ -521,6 +529,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
float R = draw_data - > DisplayPos . x + draw_data - > DisplaySize . x ;
float T = draw_data - > DisplayPos . y ;
float B = draw_data - > DisplayPos . y + draw_data - > DisplaySize . y ;
if ( ! clip_origin_lower_left ) { float tmp = T ; T = B ; B = tmp ; } // Swap top and bottom if origin is upper left
const float ortho_projection [ 4 ] [ 4 ] =
{
{ 2.0f / ( R - L ) , 0.0f , 0.0f , 0.0f } ,
@ -598,18 +607,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
GLboolean last_enable_scissor_test = glIsEnabled ( GL_SCISSOR_TEST ) ;
// Disable and store SRGB state.
GLboolean last_srgb_enabled = glIsEnabled ( GL_FRAMEBUFFER_SRGB ) ;
bool clip_origin_lower_left = true ;
GLenum last_clip_origin = 0 ;
GLenum last_clip_depth_mode = 0 ;
if ( ! g_IsGLES & & /*g_GlVersion >= 450*/ ( glad_glClipControl | | glad_glClipControlEXT ) ) {
glGetIntegerv ( GL_CLIP_ORIGIN , ( GLint * ) & last_clip_origin ) ; // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
glGetIntegerv ( GL_CLIP_DEPTH_MODE , ( GLint * ) & last_clip_depth_mode ) ;
if ( last_clip_origin = = GL_UPPER_LEFT ) {
clip_origin_lower_left = false ;
glClipControl ( GL_LOWER_LEFT , GL_ZERO_TO_ONE ) ;
}
}
// Setup desired GL state
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
@ -656,10 +654,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
if ( clip_rect . x < fb_width & & clip_rect . y < fb_height & & clip_rect . z > = 0.0f & & clip_rect . w > = 0.0f )
{
// Apply scissor/clipping rectangle
//if (clip_origin_lower_left)
glScissor ( ( int ) clip_rect . x , ( int ) ( fb_height - clip_rect . w ) , ( int ) ( clip_rect . z - clip_rect . x ) , ( int ) ( clip_rect . w - clip_rect . y ) ) ;
//else
// glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
glScissor ( ( int ) clip_rect . x , ( int ) ( fb_height - clip_rect . w ) , ( int ) ( clip_rect . z - clip_rect . x ) , ( int ) ( clip_rect . w - clip_rect . y ) ) ;
// Bind texture, Draw
glBindTexture ( GL_TEXTURE_2D , ( GLuint ) ( intptr_t ) pcmd - > TextureId ) ;
@ -705,10 +700,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
if ( last_srgb_enabled )
glEnable ( GL_FRAMEBUFFER_SRGB ) ;
if ( ! g_IsGLES & & /*g_GlVersion >= 450*/ glad_glClipControl )
if ( ! clip_origin_lower_left )
glClipControl ( last_clip_origin , last_clip_depth_mode ) ;
}
}