Backends: OpenGL2, OpenGL3: fixed DrawCallback_ResetRenderState handler not reseting all states in the glTexParameter() path. (#9378)
+ made OpenGL3 SetSamplerLinear/SetSamplerNearest check UseBindSampler for consistency.
This commit is contained in:
parent
b5135f270f
commit
333f5186e3
@ -132,6 +132,8 @@ static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
|
bd->UseTexParameterToSetSampler = false;
|
||||||
bd->NextSampler = GL_LINEAR;
|
bd->NextSampler = GL_LINEAR;
|
||||||
|
|
||||||
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
||||||
|
|||||||
@ -387,9 +387,12 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, ImGui_Impl
|
|||||||
glUniform1i(bd->AttribLocationTex, 0);
|
glUniform1i(bd->AttribLocationTex, 0);
|
||||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||||
|
|
||||||
(void)render_state;
|
render_state->UseBindSampler = bd->HasBindSampler;
|
||||||
|
render_state->UseTexParameterFilter = false;
|
||||||
|
render_state->CurrentSampler = 0;
|
||||||
|
render_state->CurrentTexParameterFilter = 0;
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
if (render_state->UseBindSampler)
|
if (bd->HasBindSampler && render_state->UseBindSampler)
|
||||||
{
|
{
|
||||||
render_state->CurrentSampler = bd->TexSamplers[0];
|
render_state->CurrentSampler = bd->TexSamplers[0];
|
||||||
glBindSampler(0, render_state->CurrentSampler); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
glBindSampler(0, render_state->CurrentSampler); // We use combined texture/sampler state. Applications using GL 3.3 and GL ES 3.0 may set that otherwise.
|
||||||
@ -419,7 +422,7 @@ static void ImGui_ImplOpenGL3_DrawCallback_SetSamplerLinear(const ImDrawList*, c
|
|||||||
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
if (bd->HasBindSampler)
|
if (bd->HasBindSampler && render_state->UseBindSampler)
|
||||||
{
|
{
|
||||||
render_state->CurrentSampler = bd->TexSamplers[0];
|
render_state->CurrentSampler = bd->TexSamplers[0];
|
||||||
render_state->UseTexParameterFilter = false;
|
render_state->UseTexParameterFilter = false;
|
||||||
@ -437,7 +440,7 @@ static void ImGui_ImplOpenGL3_DrawCallback_SetSamplerNearest(const ImDrawList*,
|
|||||||
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
ImGui_ImplOpenGL3_RenderState* render_state = ImGui_ImplOpenGL3_GetRenderState();
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
if (bd->HasBindSampler)
|
if (bd->HasBindSampler && render_state->UseBindSampler)
|
||||||
{
|
{
|
||||||
render_state->CurrentSampler = bd->TexSamplers[1];
|
render_state->CurrentSampler = bd->TexSamplers[1];
|
||||||
render_state->UseTexParameterFilter = false;
|
render_state->UseTexParameterFilter = false;
|
||||||
@ -522,11 +525,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
|
|
||||||
// Setup render state structure (for callbacks and custom texture bindings)
|
// Setup render state structure (for callbacks and custom texture bindings)
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
ImGui_ImplOpenGL3_RenderState render_state;
|
ImGui_ImplOpenGL3_RenderState render_state = {};
|
||||||
render_state.UseBindSampler = bd->HasBindSampler;
|
|
||||||
render_state.UseTexParameterFilter = false;
|
|
||||||
render_state.CurrentSampler = 0;
|
|
||||||
render_state.CurrentTexParameterFilter = 0;
|
|
||||||
platform_io.Renderer_RenderState = &render_state;
|
platform_io.Renderer_RenderState = &render_state;
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, &render_state, fb_width, fb_height, vertex_array_object);
|
ImGui_ImplOpenGL3_SetupRenderState(draw_data, &render_state, fb_width, fb_height, vertex_array_object);
|
||||||
|
|||||||
@ -73,8 +73,8 @@ struct ImGui_ImplOpenGL3_RenderState
|
|||||||
{
|
{
|
||||||
bool UseBindSampler;
|
bool UseBindSampler;
|
||||||
bool UseTexParameterFilter;
|
bool UseTexParameterFilter;
|
||||||
unsigned int CurrentSampler; // (GLuint) Used if UseBindSampler == true, otherwise always 0
|
unsigned int CurrentSampler; // (GLuint) Used if UseBindSampler == true (and are available), otherwise always 0
|
||||||
unsigned int CurrentTexParameterFilter; // (GLuint) Used if UseTexParameterToSetSampler == true
|
unsigned int CurrentTexParameterFilter; // (GLuint) Used if UseTexParameterFilter == true
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline ImGui_ImplOpenGL3_RenderState* ImGui_ImplOpenGL3_GetRenderState() { return (ImGui_ImplOpenGL3_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState; }
|
static inline ImGui_ImplOpenGL3_RenderState* ImGui_ImplOpenGL3_GetRenderState() { return (ImGui_ImplOpenGL3_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState; }
|
||||||
|
|||||||
@ -107,6 +107,8 @@ Other Changes:
|
|||||||
- Added `Widgets->Mixed Values` section. (#5518, #5677, #6865)
|
- Added `Widgets->Mixed Values` section. (#5518, #5677, #6865)
|
||||||
- Backends:
|
- Backends:
|
||||||
- QNX: added QNX Screen backend. (#9492) [@mgorchak-blackberry]
|
- QNX: added QNX Screen backend. (#9492) [@mgorchak-blackberry]
|
||||||
|
- OpenGL2, OpenGL3: fixed `DrawCallback_ResetRenderState` handler not reseting all states
|
||||||
|
in the glTexParameter() path. (#9378)
|
||||||
- SDL2: fixed querying framebuffer scale/density when using Metal without
|
- SDL2: fixed querying framebuffer scale/density when using Metal without
|
||||||
going through a SDL_Renderer. (#5592) [@lailoken]
|
going through a SDL_Renderer. (#5592) [@lailoken]
|
||||||
- SDLRenderer3: restore any temporarily modified texture scale modes at the of `RenderDrawData()`. (#9378)
|
- SDLRenderer3: restore any temporarily modified texture scale modes at the of `RenderDrawData()`. (#9378)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user