Skip to content

Commit de3e72a

Browse files
committed
Delay GL3 context creation until first pugl configure event
Signed-off-by: falkTX <[email protected]>
1 parent 023c8f1 commit de3e72a

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

dgl/src/Cairo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ void Window::PrivateData::renderToPicture(const char*, const GraphicsContext&, u
858858

859859
// --------------------------------------------------------------------------------------------------------------------
860860

861-
void Window::PrivateData::createContext()
861+
void Window::PrivateData::createContextIfNeeded()
862862
{
863863
}
864864

dgl/src/OpenGL2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ template class ImageBaseSwitch<OpenGLImage>;
549549

550550
// --------------------------------------------------------------------------------------------------------------------
551551

552-
void Window::PrivateData::createContext()
552+
void Window::PrivateData::createContextIfNeeded()
553553
{
554554
}
555555

dgl/src/OpenGL3.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,13 @@ static void contextCreationFail(const GLuint program, const GLuint shader1, cons
789789
glDeleteShader(shader2);
790790
}
791791

792-
void Window::PrivateData::createContext()
792+
void Window::PrivateData::createContextIfNeeded()
793793
{
794+
OpenGL3GraphicsContext& gl3context = reinterpret_cast<OpenGL3GraphicsContext&>(graphicsContext);
795+
796+
if (gl3context.program != 0)
797+
return;
798+
794799
#if defined(DISTRHO_OS_WINDOWS)
795800
# if defined(__GNUC__) && (__GNUC__ >= 9)
796801
# pragma GCC diagnostic push
@@ -837,7 +842,6 @@ DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer)
837842
# endif
838843
#endif
839844

840-
OpenGL3GraphicsContext& gl3context = reinterpret_cast<OpenGL3GraphicsContext&>(graphicsContext);
841845
int status;
842846

843847
const GLuint fragment = glCreateShader(GL_FRAGMENT_SHADER);

dgl/src/Vulkan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void Window::PrivateData::renderToPicture(const char*, const GraphicsContext&, u
273273

274274
// -----------------------------------------------------------------------
275275

276-
void Window::PrivateData::createContext()
276+
void Window::PrivateData::createContextIfNeeded()
277277
{
278278
}
279279

dgl/src/WindowPrivateData.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,6 @@ bool Window::PrivateData::initPost()
323323
return false;
324324
}
325325

326-
#ifndef DPF_TEST_WINDOW_CPP
327-
createContext();
328-
#endif
329-
330326
if (isEmbed)
331327
{
332328
appData->oneWindowShown();
@@ -653,6 +649,10 @@ void Window::PrivateData::onPuglConfigure(const uint width, const uint height)
653649

654650
DGL_DBGp("PUGL: onReshape : %d %d\n", width, height);
655651

652+
#ifndef DPF_TEST_WINDOW_CPP
653+
createContextIfNeeded();
654+
#endif
655+
656656
if (autoScaling)
657657
{
658658
const double scaleHorizontal = width / static_cast<double>(minWidth);

dgl/src/WindowPrivateData.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct Window::PrivateData : IdleCallback {
4646

4747
/** Reserved space for graphics context. */
4848
mutable uint8_t graphicsContext[sizeof(int) * 9];
49-
void createContext();
49+
void createContextIfNeeded();
5050
void destroyContext();
5151
void startContext();
5252
void endContext();

0 commit comments

Comments
 (0)