From 9af911eb5ecaf7c10cdc79ed1f11d0aea13cd801 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 9 Aug 2025 15:14:55 +0200 Subject: [PATCH] Cleanup OpenGL3 use, log shader compilation errors --- dgl/src/OpenGL3.cpp | 30 +++++++++++++++++++++------ distrho/src/jackbridge/JackBridge.cpp | 2 +- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/dgl/src/OpenGL3.cpp b/dgl/src/OpenGL3.cpp index e80c9966..9ef57c29 100644 --- a/dgl/src/OpenGL3.cpp +++ b/dgl/src/OpenGL3.cpp @@ -23,9 +23,6 @@ #include "../Color.hpp" #include "../ImageWidgets.hpp" -// #include "SubWidgetPrivateData.hpp" -// #include "TopLevelWidgetPrivateData.hpp" -// #include "WidgetPrivateData.hpp" #include "WindowPrivateData.hpp" // templated classes @@ -100,6 +97,8 @@ void Line::draw(const GraphicsContext& context, const T width) const GLubyte order[] = { 0, 1 }; glDrawElements(GL_LINES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); + + glDisableVertexAttribArray(gl3context.pos); } #ifdef DGL_ALLOW_DEPRECATED_METHODS @@ -182,6 +181,8 @@ static void drawCircle(const GraphicsContext& context, glDrawElements(GL_TRIANGLES, numSegments * 3, GL_UNSIGNED_SHORT, order); } + + glDisableVertexAttribArray(gl3context.pos); } template @@ -253,6 +254,8 @@ static void drawTriangle(const GraphicsContext& context, { glDrawArrays(GL_TRIANGLES, 0, 3); } + + glDisableVertexAttribArray(gl3context.pos); } template @@ -319,6 +322,8 @@ static void drawRectangle(const GraphicsContext& context, const Rectangle& re const GLubyte order[] = { 0, 1, 2, 0, 2, 3 }; glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); } + + glDisableVertexAttribArray(gl3context.pos); } template @@ -463,6 +468,8 @@ void OpenGLImage::drawAt(const GraphicsContext& context, const Point& pos) const GLubyte order[] = { 0, 1, 2, 0, 2, 3 }; glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); + glDisableVertexAttribArray(gl3context.tex); + glDisableVertexAttribArray(gl3context.pos); glUniform1i(gl3context.texok, 0); glBindTexture(GL_TEXTURE_2D, 0); } @@ -614,8 +621,19 @@ template class ImageBaseSwitch; // -------------------------------------------------------------------------------------------------------------------- -static const GraphicsContext& contextCreationFail(const OpenGL3GraphicsContext& gl3context) +static const GraphicsContext& contextCreationFail(const OpenGL3GraphicsContext& gl3context, GLuint shaderErr = 0) { + if (shaderErr != 0) + { + GLint len = 0; + glGetShaderiv(shaderErr, GL_INFO_LOG_LENGTH, &len); + + std::vector errorLog(len); + glGetShaderInfoLog(shaderErr, len, &len, errorLog.data()); + + d_stderr2("OpenGL3 shader compilation error: %s", errorLog.data()); + } + gl3context.prog = -1; return gl3context; } @@ -665,7 +683,7 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept glCompileShader(fragment); glGetShaderiv(fragment, GL_COMPILE_STATUS, &status); - DISTRHO_SAFE_ASSERT_RETURN(status != 0, contextCreationFail(gl3context)); + DISTRHO_SAFE_ASSERT_RETURN(status != 0, contextCreationFail(gl3context, fragment)); } { @@ -679,7 +697,7 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept glCompileShader(vertex); glGetShaderiv(vertex, GL_COMPILE_STATUS, &status); - DISTRHO_SAFE_ASSERT_RETURN(status != 0, contextCreationFail(gl3context)); + DISTRHO_SAFE_ASSERT_RETURN(status != 0, contextCreationFail(gl3context, vertex)); } glAttachShader(program, fragment); diff --git a/distrho/src/jackbridge/JackBridge.cpp b/distrho/src/jackbridge/JackBridge.cpp index f104101c..7c5633d0 100644 --- a/distrho/src/jackbridge/JackBridge.cpp +++ b/distrho/src/jackbridge/JackBridge.cpp @@ -1,6 +1,6 @@ /* * JackBridge for DPF - * Copyright (C) 2013-2024 Filipe Coelho + * Copyright (C) 2013-2025 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this