@ -74,7 +74,9 @@
# include "overlay.h"
# include "overlay.h"
namespace MangoHud {
namespace MangoHud { namespace GL {
extern overlay_params params ;
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
# if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
# if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
@ -501,6 +503,8 @@ void ImGui_ImplOpenGL3_NewFrame()
static void ImGui_ImplOpenGL3_SetupRenderState ( ImDrawData * draw_data , int fb_width , int fb_height , GLuint vertex_array_object )
static void ImGui_ImplOpenGL3_SetupRenderState ( ImDrawData * draw_data , int fb_width , int fb_height , GLuint vertex_array_object )
{
{
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
if ( params . gl_bind_framebuffer > = 0 & & g_GlVersion > = 300 )
glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , params . gl_bind_framebuffer ) ;
glEnable ( GL_BLEND ) ;
glEnable ( GL_BLEND ) ;
glBlendEquation ( GL_FUNC_ADD ) ;
glBlendEquation ( GL_FUNC_ADD ) ;
glBlendFuncSeparate ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA , GL_ONE , GL_ONE_MINUS_SRC_ALPHA ) ;
glBlendFuncSeparate ( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA , GL_ONE , GL_ONE_MINUS_SRC_ALPHA ) ;
@ -535,7 +539,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
float R = draw_data - > DisplayPos . x + draw_data - > DisplaySize . x ;
float R = draw_data - > DisplayPos . x + draw_data - > DisplaySize . x ;
float T = draw_data - > DisplayPos . y ;
float T = draw_data - > DisplayPos . y ;
float B = draw_data - > DisplayPos . y + draw_data - > DisplaySize . 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
if ( ! params. gl_dont_flip & & ! 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 ] =
const float ortho_projection [ 4 ] [ 4 ] =
{
{
{ 2.0f / ( R - L ) , 0.0f , 0.0f , 0.0f } ,
{ 2.0f / ( R - L ) , 0.0f , 0.0f , 0.0f } ,
@ -662,7 +666,10 @@ 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 )
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
// Apply scissor/clipping rectangle
if ( ! params . gl_dont_flip )
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 ) ) ;
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 ) ;
// Bind texture, Draw
// Bind texture, Draw
glBindTexture ( GL_TEXTURE_2D , ( GLuint ) ( intptr_t ) pcmd - > TextureId ) ;
glBindTexture ( GL_TEXTURE_2D , ( GLuint ) ( intptr_t ) pcmd - > TextureId ) ;
@ -712,4 +719,4 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
glEnable ( GL_FRAMEBUFFER_SRGB ) ;
glEnable ( GL_FRAMEBUFFER_SRGB ) ;
}
}
}
} } // namespace