2323#include " ../Color.hpp"
2424#include " ../ImageWidgets.hpp"
2525
26- // #include "SubWidgetPrivateData.hpp"
27- // #include "TopLevelWidgetPrivateData.hpp"
28- // #include "WidgetPrivateData.hpp"
2926#include " WindowPrivateData.hpp"
3027
3128// templated classes
@@ -100,6 +97,8 @@ void Line<T>::draw(const GraphicsContext& context, const T width)
10097
10198 const GLubyte order[] = { 0 , 1 };
10299 glDrawElements (GL_LINES, ARRAY_SIZE (order), GL_UNSIGNED_BYTE, order);
100+
101+ glDisableVertexAttribArray (gl3context.pos );
103102}
104103
105104#ifdef DGL_ALLOW_DEPRECATED_METHODS
@@ -182,6 +181,8 @@ static void drawCircle(const GraphicsContext& context,
182181
183182 glDrawElements (GL_TRIANGLES, numSegments * 3 , GL_UNSIGNED_SHORT, order);
184183 }
184+
185+ glDisableVertexAttribArray (gl3context.pos );
185186}
186187
187188template <typename T>
@@ -253,6 +254,8 @@ static void drawTriangle(const GraphicsContext& context,
253254 {
254255 glDrawArrays (GL_TRIANGLES, 0 , 3 );
255256 }
257+
258+ glDisableVertexAttribArray (gl3context.pos );
256259}
257260
258261template <typename T>
@@ -319,6 +322,8 @@ static void drawRectangle(const GraphicsContext& context, const Rectangle<T>& re
319322 const GLubyte order[] = { 0 , 1 , 2 , 0 , 2 , 3 };
320323 glDrawElements (GL_TRIANGLES, ARRAY_SIZE (order), GL_UNSIGNED_BYTE, order);
321324 }
325+
326+ glDisableVertexAttribArray (gl3context.pos );
322327}
323328
324329template <typename T>
@@ -463,6 +468,8 @@ void OpenGLImage::drawAt(const GraphicsContext& context, const Point<int>& pos)
463468 const GLubyte order[] = { 0 , 1 , 2 , 0 , 2 , 3 };
464469 glDrawElements (GL_TRIANGLES, ARRAY_SIZE (order), GL_UNSIGNED_BYTE, order);
465470
471+ glDisableVertexAttribArray (gl3context.tex );
472+ glDisableVertexAttribArray (gl3context.pos );
466473 glUniform1i (gl3context.texok , 0 );
467474 glBindTexture (GL_TEXTURE_2D, 0 );
468475}
@@ -614,8 +621,19 @@ template class ImageBaseSwitch<OpenGLImage>;
614621
615622// --------------------------------------------------------------------------------------------------------------------
616623
617- static const GraphicsContext& contextCreationFail (const OpenGL3GraphicsContext& gl3context)
624+ static const GraphicsContext& contextCreationFail (const OpenGL3GraphicsContext& gl3context, GLuint shaderErr = 0 )
618625{
626+ if (shaderErr != 0 )
627+ {
628+ GLint len = 0 ;
629+ glGetShaderiv (shaderErr, GL_INFO_LOG_LENGTH, &len);
630+
631+ std::vector<GLchar> errorLog (len);
632+ glGetShaderInfoLog (shaderErr, len, &len, errorLog.data ());
633+
634+ d_stderr2 (" OpenGL3 shader compilation error: %s" , errorLog.data ());
635+ }
636+
619637 gl3context.prog = -1 ;
620638 return gl3context;
621639}
@@ -665,7 +683,7 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept
665683 glCompileShader (fragment);
666684
667685 glGetShaderiv (fragment, GL_COMPILE_STATUS, &status);
668- DISTRHO_SAFE_ASSERT_RETURN (status != 0 , contextCreationFail (gl3context));
686+ DISTRHO_SAFE_ASSERT_RETURN (status != 0 , contextCreationFail (gl3context, fragment ));
669687 }
670688
671689 {
@@ -679,7 +697,7 @@ const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept
679697 glCompileShader (vertex);
680698
681699 glGetShaderiv (vertex, GL_COMPILE_STATUS, &status);
682- DISTRHO_SAFE_ASSERT_RETURN (status != 0 , contextCreationFail (gl3context));
700+ DISTRHO_SAFE_ASSERT_RETURN (status != 0 , contextCreationFail (gl3context, vertex ));
683701 }
684702
685703 glAttachShader (program, fragment);
0 commit comments