From 80239b4d50fe6f96f1a43826f55429e8646173ba Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 9 Aug 2021 19:03:42 +0100 Subject: [PATCH] OpenGL: Only load the core API by default See the breaking changes document for more details. --- BREAKING-CHANGES.txt | 22 ++++++++++++++++++++++ modules/juce_opengl/opengl/juce_gl.cpp | 14 +++++++++++++- modules/juce_opengl/opengl/juce_gl.h | 12 ++++++++++++ modules/juce_opengl/opengl/juce_gles2.cpp | 14 +++++++++++++- modules/juce_opengl/opengl/juce_gles2.h | 12 ++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/BREAKING-CHANGES.txt b/BREAKING-CHANGES.txt index a4800c772e..7111d84085 100644 --- a/BREAKING-CHANGES.txt +++ b/BREAKING-CHANGES.txt @@ -4,6 +4,28 @@ JUCE breaking changes Develop ======= +Change +------ +juce::gl::loadFunctions() no longer loads extension functions. + +Possible Issues +--------------- +Code that depended on extension functions being loaded automatically may cease +to function correctly. + +Workaround +---------- +Extension functions can now be loaded using juce::gl::loadExtensions(). + +Rationale +--------- +There are a great number of extension functions, and on some systems these can +be slow to load (i.e. a second or so). Projects that do not require these +extension functions should not have to pay for this unnecessary overhead. Now, +only core functions will be loaded by default, and extensions can be loaded +explicitly in projects that require such functionality. + + Change ------ Thread::setPriority() will no longer set a realtime scheduling policy for all diff --git a/modules/juce_opengl/opengl/juce_gl.cpp b/modules/juce_opengl/opengl/juce_gl.cpp index 3f123fd610..3b71f32163 100644 --- a/modules/juce_opengl/opengl/juce_gl.cpp +++ b/modules/juce_opengl/opengl/juce_gl.cpp @@ -3784,7 +3784,9 @@ JUCE_GL_FUNCTIONS_GL_VERSION_4_3_DYNAMIC \ JUCE_GL_FUNCTIONS_GL_VERSION_4_4_DYNAMIC \ JUCE_GL_FUNCTIONS_GL_VERSION_4_5_DYNAMIC \ - JUCE_GL_FUNCTIONS_GL_VERSION_4_6_DYNAMIC \ + JUCE_GL_FUNCTIONS_GL_VERSION_4_6_DYNAMIC + +#define JUCE_EXTENSION_GL_FUNCTIONS \ JUCE_GL_FUNCTIONS_GL_3DFX_tbuffer \ JUCE_GL_FUNCTIONS_GL_AMD_debug_output \ JUCE_GL_FUNCTIONS_GL_AMD_draw_buffers_blend \ @@ -4049,6 +4051,7 @@ JUCE_STATIC_GL_FUNCTIONS static returns (KHRONOS_APIENTRY* juce_ ## name) params = nullptr; \ returns (KHRONOS_APIENTRY* const& ::juce::gl::name) params = juce_ ## name; JUCE_DYNAMIC_GL_FUNCTIONS +JUCE_EXTENSION_GL_FUNCTIONS #undef X void juce::gl::loadFunctions() @@ -4059,5 +4062,14 @@ void juce::gl::loadFunctions() #undef X } +void juce::gl::loadExtensions() +{ + #define X(returns, name, params) \ + juce_ ## name = reinterpret_cast (::juce::OpenGLHelpers::getExtensionFunction (#name)); + JUCE_EXTENSION_GL_FUNCTIONS + #undef X +} + #undef JUCE_STATIC_GL_FUNCTIONS #undef JUCE_DYNAMIC_GL_FUNCTIONS +#undef JUCE_EXTENSION_GL_FUNCTIONS diff --git a/modules/juce_opengl/opengl/juce_gl.h b/modules/juce_opengl/opengl/juce_gl.h index 586c4c8329..83396cce58 100644 --- a/modules/juce_opengl/opengl/juce_gl.h +++ b/modules/juce_opengl/opengl/juce_gl.h @@ -11990,7 +11990,19 @@ enum : GLenum #endif +/** Load all available functions from the OpenGL core API. + + This will not load extensions! +*/ void loadFunctions(); +/** Load all available OpenGL extension functions. + + It's probably a good idea to stick to the core API as much as possible. + Extensions are not as portable, and it can be a little time-consuming to + load all of the extension entry-points. +*/ +void loadExtensions(); + } } diff --git a/modules/juce_opengl/opengl/juce_gles2.cpp b/modules/juce_opengl/opengl/juce_gles2.cpp index 61f197b806..2897d5361b 100644 --- a/modules/juce_opengl/opengl/juce_gles2.cpp +++ b/modules/juce_opengl/opengl/juce_gles2.cpp @@ -1253,7 +1253,9 @@ JUCE_GL_FUNCTIONS_GL_ES_VERSION_2_0_DYNAMIC \ JUCE_GL_FUNCTIONS_GL_ES_VERSION_3_0_DYNAMIC \ JUCE_GL_FUNCTIONS_GL_ES_VERSION_3_1_DYNAMIC \ - JUCE_GL_FUNCTIONS_GL_ES_VERSION_3_2_DYNAMIC \ + JUCE_GL_FUNCTIONS_GL_ES_VERSION_3_2_DYNAMIC + +#define JUCE_EXTENSION_GL_FUNCTIONS \ JUCE_GL_FUNCTIONS_GL_AMD_framebuffer_multisample_advanced \ JUCE_GL_FUNCTIONS_GL_AMD_performance_monitor \ JUCE_GL_FUNCTIONS_GL_ANGLE_framebuffer_blit \ @@ -1392,6 +1394,7 @@ JUCE_STATIC_GL_FUNCTIONS static returns (KHRONOS_APIENTRY* juce_ ## name) params = nullptr; \ returns (KHRONOS_APIENTRY* const& ::juce::gl::name) params = juce_ ## name; JUCE_DYNAMIC_GL_FUNCTIONS +JUCE_EXTENSION_GL_FUNCTIONS #undef X void juce::gl::loadFunctions() @@ -1402,5 +1405,14 @@ void juce::gl::loadFunctions() #undef X } +void juce::gl::loadExtensions() +{ + #define X(returns, name, params) \ + juce_ ## name = reinterpret_cast (::juce::OpenGLHelpers::getExtensionFunction (#name)); + JUCE_EXTENSION_GL_FUNCTIONS + #undef X +} + #undef JUCE_STATIC_GL_FUNCTIONS #undef JUCE_DYNAMIC_GL_FUNCTIONS +#undef JUCE_EXTENSION_GL_FUNCTIONS diff --git a/modules/juce_opengl/opengl/juce_gles2.h b/modules/juce_opengl/opengl/juce_gles2.h index 55dbf8e510..3ef882d42d 100644 --- a/modules/juce_opengl/opengl/juce_gles2.h +++ b/modules/juce_opengl/opengl/juce_gles2.h @@ -5252,7 +5252,19 @@ enum : GLenum #endif +/** Load all available functions from the OpenGL core API. + + This will not load extensions! +*/ void loadFunctions(); +/** Load all available OpenGL extension functions. + + It's probably a good idea to stick to the core API as much as possible. + Extensions are not as portable, and it can be a little time-consuming to + load all of the extension entry-points. +*/ +void loadExtensions(); + } }