mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 19:55:46 -04:00
Misc: Correctness fixes for OpenGL
GLES2 fallback should be functional again.
This commit is contained in:
@ -159,9 +159,6 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
}
|
||||
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||
|
||||
if (bd->GlVersion >= 320)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
|
||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||
// Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
||||
if (glsl_version == NULL)
|
||||
@ -171,11 +168,10 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
strcpy(bd->GlslVersionString, glsl_version);
|
||||
strcat(bd->GlslVersionString, "\n");
|
||||
|
||||
if (!glDrawElementsBaseVertex)
|
||||
{
|
||||
Log_ErrorPrintf("Missing glDrawElementsBaseVertex()");
|
||||
return false;
|
||||
}
|
||||
if (glDrawElementsBaseVertex)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
else
|
||||
Log_WarningPrintf("Missing glDrawElementsBaseVertex()");
|
||||
|
||||
return ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
@ -226,7 +222,9 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
||||
glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||
|
||||
// Bind vertex/index buffers and setup attributes for ImDrawVert
|
||||
glBindVertexArray(bd->VaoHandle);
|
||||
if (bd->VaoHandle)
|
||||
glBindVertexArray(bd->VaoHandle);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, bd->VboHandle);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bd->ElementsHandle);
|
||||
glEnableVertexAttribArray(bd->AttribLocationVtxPos);
|
||||
@ -305,12 +303,17 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
const GL::Texture* tex = static_cast<const GL::Texture*>(pcmd->GetTexID());
|
||||
if (tex)
|
||||
tex->Bind();
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||
|
||||
if (glDrawElementsBaseVertex)
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||
else
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
if (bd->VaoHandle)
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
@ -544,7 +547,9 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||
// Create buffers
|
||||
glGenBuffers(1, &bd->VboHandle);
|
||||
glGenBuffers(1, &bd->ElementsHandle);
|
||||
glGenVertexArrays(1, &bd->VaoHandle);
|
||||
|
||||
if (glGenVertexArrays)
|
||||
glGenVertexArrays(1, &bd->VaoHandle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -569,6 +569,11 @@ void Host::AddOSDMessage(std::string message, float duration /*= 2.0f*/)
|
||||
|
||||
void Host::AddKeyedOSDMessage(std::string key, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
if (!key.empty())
|
||||
Log_InfoPrintf("OSD [%s]: %s", key.c_str(), message.c_str());
|
||||
else
|
||||
Log_InfoPrintf("OSD: %s", message.c_str());
|
||||
|
||||
OSDMessage msg;
|
||||
msg.key = std::move(key);
|
||||
msg.text = std::move(message);
|
||||
@ -711,7 +716,7 @@ void ImGuiManager::DrawOSDMessages()
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiManager::RenderOSD()
|
||||
void ImGuiManager::RenderOSDMessages()
|
||||
{
|
||||
AcquirePendingOSDMessages();
|
||||
DrawOSDMessages();
|
||||
|
@ -34,7 +34,7 @@ void UpdateScale();
|
||||
void NewFrame();
|
||||
|
||||
/// Renders any on-screen display elements.
|
||||
void RenderOSD();
|
||||
void RenderOSDMessages();
|
||||
|
||||
/// Returns the scale of all on-screen elements.
|
||||
float GetGlobalScale();
|
||||
|
@ -297,7 +297,8 @@ bool OpenGLHostDisplay::CreateDevice(const WindowInfo& wi, bool vsync)
|
||||
|
||||
bool OpenGLHostDisplay::SetupDevice()
|
||||
{
|
||||
m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_0);
|
||||
// If we don't have GLES3.1, then SV_VertexID isn't defined when no VBOs are active.
|
||||
m_use_gles2_draw_path = (GetRenderAPI() == RenderAPI::OpenGLES && !GLAD_GL_ES_VERSION_3_1);
|
||||
if (!m_use_gles2_draw_path)
|
||||
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, reinterpret_cast<GLint*>(&m_uniform_buffer_alignment));
|
||||
|
||||
@ -540,7 +541,7 @@ void main()
|
||||
|
||||
glSamplerParameteri(m_display_border_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glSamplerParameteri(m_display_border_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
glTexParameterfv(m_display_border_sampler, GL_TEXTURE_BORDER_COLOR, border_color);
|
||||
glSamplerParameterfv(m_display_border_sampler, GL_TEXTURE_BORDER_COLOR, border_color);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -740,7 +741,7 @@ void OpenGLHostDisplay::RenderDisplay()
|
||||
return;
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (!HasDisplayTexture())
|
||||
|
Reference in New Issue
Block a user