mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a method OpenGLContext::setOpenGLVersionRequired, which can be used to request a v3.2 context.
This commit is contained in:
parent
5f2b87d69b
commit
272bcbcaab
9 changed files with 56 additions and 21 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ public:
|
|||
NativeContext (Component& comp,
|
||||
const OpenGLPixelFormat& pixelFormat,
|
||||
void* /*contextToShareWith*/,
|
||||
bool /*useMultisampling*/)
|
||||
bool /*useMultisampling*/,
|
||||
OpenGLVersion)
|
||||
: component (comp),
|
||||
isInsideGLCallback (false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ public:
|
|||
NativeContext (Component& component,
|
||||
const OpenGLPixelFormat& pixelFormat,
|
||||
void* contextToShareWith,
|
||||
bool /*useMultisampling*/)
|
||||
bool /*useMultisampling*/,
|
||||
OpenGLVersion)
|
||||
{
|
||||
createNativeWindow (component);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue