Browse Source

Cleanup OpenGL3 use, log shader compilation errors

pull/506/head
falkTX 2 months ago
parent
commit
9af911eb5e
2 changed files with 25 additions and 7 deletions
  1. +24
    -6
      dgl/src/OpenGL3.cpp
  2. +1
    -1
      distrho/src/jackbridge/JackBridge.cpp

+ 24
- 6
dgl/src/OpenGL3.cpp View File

@@ -23,9 +23,6 @@
#include "../Color.hpp" #include "../Color.hpp"
#include "../ImageWidgets.hpp" #include "../ImageWidgets.hpp"


// #include "SubWidgetPrivateData.hpp"
// #include "TopLevelWidgetPrivateData.hpp"
// #include "WidgetPrivateData.hpp"
#include "WindowPrivateData.hpp" #include "WindowPrivateData.hpp"


// templated classes // templated classes
@@ -100,6 +97,8 @@ void Line<T>::draw(const GraphicsContext& context, const T width)


const GLubyte order[] = { 0, 1 }; const GLubyte order[] = { 0, 1 };
glDrawElements(GL_LINES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); glDrawElements(GL_LINES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order);

glDisableVertexAttribArray(gl3context.pos);
} }


#ifdef DGL_ALLOW_DEPRECATED_METHODS #ifdef DGL_ALLOW_DEPRECATED_METHODS
@@ -182,6 +181,8 @@ static void drawCircle(const GraphicsContext& context,


glDrawElements(GL_TRIANGLES, numSegments * 3, GL_UNSIGNED_SHORT, order); glDrawElements(GL_TRIANGLES, numSegments * 3, GL_UNSIGNED_SHORT, order);
} }

glDisableVertexAttribArray(gl3context.pos);
} }


template<typename T> template<typename T>
@@ -253,6 +254,8 @@ static void drawTriangle(const GraphicsContext& context,
{ {
glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLES, 0, 3);
} }

glDisableVertexAttribArray(gl3context.pos);
} }


template<typename T> template<typename T>
@@ -319,6 +322,8 @@ static void drawRectangle(const GraphicsContext& context, const Rectangle<T>& re
const GLubyte order[] = { 0, 1, 2, 0, 2, 3 }; const GLubyte order[] = { 0, 1, 2, 0, 2, 3 };
glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order);
} }

glDisableVertexAttribArray(gl3context.pos);
} }


template<typename T> template<typename T>
@@ -463,6 +468,8 @@ void OpenGLImage::drawAt(const GraphicsContext& context, const Point<int>& pos)
const GLubyte order[] = { 0, 1, 2, 0, 2, 3 }; const GLubyte order[] = { 0, 1, 2, 0, 2, 3 };
glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order); glDrawElements(GL_TRIANGLES, ARRAY_SIZE(order), GL_UNSIGNED_BYTE, order);


glDisableVertexAttribArray(gl3context.tex);
glDisableVertexAttribArray(gl3context.pos);
glUniform1i(gl3context.texok, 0); glUniform1i(gl3context.texok, 0);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
@@ -614,8 +621,19 @@ template class ImageBaseSwitch<OpenGLImage>;


// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------


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<GLchar> errorLog(len);
glGetShaderInfoLog(shaderErr, len, &len, errorLog.data());

d_stderr2("OpenGL3 shader compilation error: %s", errorLog.data());
}

gl3context.prog = -1; gl3context.prog = -1;
return gl3context; return gl3context;
} }
@@ -665,7 +683,7 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept
glCompileShader(fragment); glCompileShader(fragment);


glGetShaderiv(fragment, GL_COMPILE_STATUS, &status); 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); glCompileShader(vertex);


glGetShaderiv(vertex, GL_COMPILE_STATUS, &status); 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); glAttachShader(program, fragment);


+ 1
- 1
distrho/src/jackbridge/JackBridge.cpp View File

@@ -1,6 +1,6 @@
/* /*
* JackBridge for DPF * JackBridge for DPF
* Copyright (C) 2013-2024 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013-2025 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this


Loading…
Cancel
Save