Browse Source

Added a method OpenGLContext::setOpenGLVersionRequired, which can be used to request a v3.2 context.

tags/2021-05-28
jules 11 years ago
parent
commit
272bcbcaab
9 changed files with 56 additions and 21 deletions
  1. +7
    -2
      modules/juce_opengl/juce_opengl.h
  2. +16
    -11
      modules/juce_opengl/native/juce_OpenGLExtensions.h
  3. +2
    -1
      modules/juce_opengl/native/juce_OpenGL_android.h
  4. +2
    -1
      modules/juce_opengl/native/juce_OpenGL_ios.h
  5. +2
    -1
      modules/juce_opengl/native/juce_OpenGL_linux.h
  6. +3
    -1
      modules/juce_opengl/native/juce_OpenGL_osx.h
  7. +2
    -1
      modules/juce_opengl/native/juce_OpenGL_win32.h
  8. +9
    -3
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  9. +13
    -0
      modules/juce_opengl/opengl/juce_OpenGLContext.h

+ 7
- 2
modules/juce_opengl/juce_opengl.h View File

@@ -58,8 +58,13 @@
#elif JUCE_IOS
#include <OpenGLES/ES2/gl.h>
#elif JUCE_MAC
#include <OpenGL/gl.h>
#include "OpenGL/glext.h"
#if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_7)
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <OpenGL/gl.h>
#include "OpenGL/glext.h"
#endif
#elif JUCE_ANDROID
#include <GLES2/gl2.h>
#endif


+ 16
- 11
modules/juce_opengl/native/juce_OpenGLExtensions.h View File

@@ -98,23 +98,28 @@ struct OpenGLExtensionFunctions
typedef pointer_sized_int GLintptr;
#endif
#if JUCE_WINDOWS || JUCE_LINUX
#if JUCE_WINDOWS
#define JUCE_GL_STDCALL __stdcall
#else
#define JUCE_GL_STDCALL
#endif
#define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) typedef returnType (JUCE_GL_STDCALL *type_ ## name) params; type_ ## name name;
//==============================================================================
#if JUCE_WINDOWS
#define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) typedef returnType (__stdcall *type_ ## name) params; type_ ## name name;
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION)
//==============================================================================
#elif JUCE_LINUX
#define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) typedef returnType (*type_ ## name) params; type_ ## name name;
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION)
//==============================================================================
#elif JUCE_OPENGL_ES
#define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) static returnType name params;
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION)
//==============================================================================
#else
#define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) inline static returnType name params { return ::name callparams; }
#define JUCE_DECLARE_GL_FUNCTION_EXT(name, returnType, params, callparams) inline static returnType name params { return ::name ## EXT callparams; }
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION_EXT)
#undef JUCE_DECLARE_GL_FUNCTION_EXT
#if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MIN_ALLOWED >= MAC_OS_X_VERSION_10_7)
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION)
#else
#define JUCE_DECLARE_GL_FUNCTION_EXT(name, returnType, params, callparams) inline static returnType name params { return ::name ## EXT callparams; }
JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION, JUCE_DECLARE_GL_FUNCTION_EXT)
#undef JUCE_DECLARE_GL_FUNCTION_EXT
#endif
#endif
#undef JUCE_DECLARE_GL_FUNCTION


+ 2
- 1
modules/juce_opengl/native/juce_OpenGL_android.h View File

@@ -38,7 +38,8 @@ public:
NativeContext (Component& comp,
const OpenGLPixelFormat& pixelFormat,
void* /*contextToShareWith*/,
bool /*useMultisampling*/)
bool /*useMultisampling*/,
OpenGLVersion)
: component (comp),
isInsideGLCallback (false)
{


+ 2
- 1
modules/juce_opengl/native/juce_OpenGL_ios.h View File

@@ -46,7 +46,8 @@ public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixFormat,
void* contextToShare,
bool multisampling)
bool multisampling,
OpenGLVersion)
: frameBufferHandle (0), colorBufferHandle (0), depthBufferHandle (0),
msaaColorHandle (0), msaaBufferHandle (0),
lastWidth (0), lastHeight (0), needToRebuildBuffers (false),


+ 2
- 1
modules/juce_opengl/native/juce_OpenGL_linux.h View File

@@ -32,7 +32,8 @@ public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixelFormat,
void* shareContext,
bool /*useMultisampling*/)
bool /*useMultisampling*/,
OpenGLVersion)
: renderContext (0), embeddedWindow (0), swapFrames (0), bestVisual (0),
contextToShareWith (shareContext)
{


+ 3
- 1
modules/juce_opengl/native/juce_OpenGL_osx.h View File

@@ -28,11 +28,13 @@ public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixFormat,
void* contextToShare,
bool /*useMultisampling*/)
bool /*useMultisampling*/,
OpenGLVersion version)
: lastSwapTime (0), minSwapTimeMs (0), underrunCounter (0)
{
NSOpenGLPixelFormatAttribute attribs[] =
{
NSOpenGLPFAOpenGLProfile, version >= openGL3_2 ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAMPSafe,
NSOpenGLPFAClosestPolicy,


+ 2
- 1
modules/juce_opengl/native/juce_OpenGL_win32.h View File

@@ -31,7 +31,8 @@ public:
NativeContext (Component& component,
const OpenGLPixelFormat& pixelFormat,
void* contextToShareWith,
bool /*useMultisampling*/)
bool /*useMultisampling*/,
OpenGLVersion)
{
createNativeWindow (component);


+ 9
- 3
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -39,7 +39,8 @@ public:
hasInitialised (false),
needsUpdate (1), lastMMLockReleaseTime (0)
{
nativeContext = new NativeContext (component, pixFormat, contextToShare, c.useMultisampling);
nativeContext = new NativeContext (component, pixFormat, contextToShare,
c.useMultisampling, c.versionRequired);
if (nativeContext->createdOk())
context.nativeContext = nativeContext;
@@ -553,8 +554,8 @@ private:
//==============================================================================
OpenGLContext::OpenGLContext()
: nativeContext (nullptr), renderer (nullptr), currentRenderScale (1.0),
contextToShareWith (nullptr), renderComponents (true),
useMultisampling (false), continuousRepaint (false)
contextToShareWith (nullptr), versionRequired (OpenGLContext::defaultGLVersion),
renderComponents (true), useMultisampling (false), continuousRepaint (false)
{
}
@@ -613,6 +614,11 @@ void OpenGLContext::setMultisamplingEnabled (bool b) noexcept
useMultisampling = b;
}
void OpenGLContext::setOpenGLVersionRequired (OpenGLVersion v) noexcept
{
versionRequired = v;
}
void OpenGLContext::attachTo (Component& component)
{
component.repaint();


+ 13
- 0
modules/juce_opengl/opengl/juce_OpenGLContext.h View File

@@ -109,6 +109,18 @@ public:
/** Returns true if shaders can be used in this context. */
bool areShadersAvailable() const;
/** OpenGL versions, used by setOpenGLVersionRequired(). */
enum OpenGLVersion
{
defaultGLVersion = 0,
openGL3_2
};
/** Sets a preference for the version of GL that this context should use, if possible.
Some platforms may ignore this value.
*/
void setOpenGLVersionRequired (OpenGLVersion) noexcept;
/** Enables or disables the use of the GL context to perform 2D rendering
of the component to which it is attached.
If this is false, then only your OpenGLRenderer will be used to perform
@@ -264,6 +276,7 @@ private:
ScopedPointer<Attachment> attachment;
OpenGLPixelFormat pixelFormat;
void* contextToShareWith;
OpenGLVersion versionRequired;
bool renderComponents, useMultisampling, continuousRepaint;
CachedImage* getCachedImage() const noexcept;


Loading…
Cancel
Save