aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/CAPI/GL/CAPI_GL_Util.h')
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_Util.h92
1 files changed, 79 insertions, 13 deletions
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
index aa6a26b..9e6af3e 100644
--- a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
@@ -5,15 +5,18 @@ Content : Utility header for OpenGL
Created : March 27, 2014
Authors : Andrew Reisse, David Borel
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
+
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
+you may not use the Oculus VR Rift SDK except in compliance with the License,
+which is provided at the time of installation or download, or which
+otherwise accompanies this software in either electronic or hard copy form.
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-http://www.apache.org/licenses/LICENSE-2.0
+http://www.oculusvr.com/licenses/LICENSE-3.2
-Unless required by applicable law or agreed to in writing, software
+Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@@ -39,6 +42,8 @@ limitations under the License.
#if defined(OVR_OS_MAC)
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
+#include <CoreGraphics/CGDirectDisplay.h>
+#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/gl3.h>
@@ -72,6 +77,13 @@ typedef void (__stdcall *PFNGLGETFLOATVPROC) (GLenum, GLfloat*);
typedef const GLubyte * (__stdcall *PFNGLGETSTRINGPROC) (GLenum);
typedef const GLubyte * (__stdcall *PFNGLGETSTRINGIPROC) (GLenum, GLuint);
typedef void(__stdcall *PFNGLGETINTEGERVPROC) (GLenum, GLint*);
+typedef PROC(__stdcall *PFNWGLGETPROCADDRESSPROC) (LPCSTR);
+typedef BOOL(__stdcall *PFNWGLSHARELISTSPROC)(HGLRC hglrcShare, HGLRC hglrcSrc);
+typedef BOOL(__stdcall *PFNWGLMAKECURRENTPROC)(HDC, HGLRC);
+typedef HDC(__stdcall *PFNWGLGETCURRENTDCPROC)(void);
+typedef HGLRC(__stdcall *PFNWGLCREATECONTEXTPROC)(HDC hDC);
+typedef HGLRC(__stdcall *PFNWGLGETCURRENTCONTEXTPROC)(void);
+typedef BOOL(__stdcall *PFNWGLDELETECONTEXTPROC)(HGLRC hglrc);
typedef void (__stdcall *PFNGLGETDOUBLEVPROC) (GLenum, GLdouble*);
typedef PROC (__stdcall *PFNWGLGETPROCADDRESS) (LPCSTR);
typedef void (__stdcall *PFNGLFLUSHPROC) ();
@@ -99,6 +111,10 @@ typedef void (__stdcall *PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
extern PFNWGLGETPROCADDRESS wglGetProcAddress;
extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
+extern PFNWGLGETCURRENTDCPROC wglGetCurrentDC;
+extern PFNWGLGETCURRENTCONTEXTPROC wglGetCurrentContext;
+extern PFNWGLCREATECONTEXTPROC wglCreateContext;
+extern PFNWGLSHARELISTSPROC wglShareLists;
extern PFNGLGETERRORPROC glGetError;
extern PFNGLENABLEPROC glEnable;
@@ -186,6 +202,8 @@ extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
+extern PFNGLBLITFRAMEBUFFEREXTPROC glBlitFramebuffer;
+extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
extern void InitGLExtensions();
@@ -496,17 +514,33 @@ public:
struct Uniform
{
const char* Name;
- VarType Type;
- int Offset, Size;
+ VarType Type;
+ int Offset;
+ int Size;
};
- const Uniform* UniformRefl;
- size_t UniformReflSize;
- ShaderBase(RenderParams* rp, ShaderStage stage) : Shader(stage), pParams(rp), UniformData(0), UniformsSize(0) {}
+ const Uniform* UniformRefl;
+ size_t UniformReflSize;
+
+ ShaderBase(RenderParams* rp, ShaderStage stage) :
+ Shader(stage),
+ pParams(rp),
+ UniformData(NULL),
+ UniformsSize(0),
+ UniformRefl(NULL),
+ UniformReflSize(0)
+ {
+ }
~ShaderBase()
{
- if (UniformData)
- OVR_FREE(UniformData);
+ if (UniformData)
+ {
+ OVR_FREE(UniformData);
+ UniformData = NULL;
+ }
+
+ // Do not need to free UniformRefl
+ UniformRefl = NULL;
}
void InitUniforms(const Uniform* refl, size_t reflSize);
@@ -605,8 +639,8 @@ struct GLVersionAndExtensions
WholeVersion(0),
IsGLES(false),
IsCoreProfile(false),
- SupportsDrawBuffers(false),
SupportsVAO(false),
+ SupportsDrawBuffers(false),
Extensions("")
{
}
@@ -622,6 +656,38 @@ protected:
void GetGLVersionAndExtensions(GLVersionAndExtensions& versionInfo);
+class Context
+{
+ bool initialized;
+ bool ownsContext;
+ int incarnation;
+#if defined(OVR_OS_WIN32)
+ HDC hdc;
+ HGLRC systemContext;
+#elif defined(OVR_OS_LINUX)
+ Display *x11Display;
+ GLXDrawable x11Drawable;
+ GLXContext systemContext;
+ XVisualInfo x11Visual;
+#elif defined(OVR_OS_MAC)
+ CGLContextObj systemContext;
+#endif
+
+public:
+
+ Context();
+ void InitFromCurrent();
+ void CreateShared( Context & ctx );
+#if defined(OVR_OS_MAC)
+ void SetSurface( Context & ctx );
+#endif
+ void Destroy();
+ void Bind();
+ void Unbind();
+ int GetIncarnation() const { return incarnation; }
+
+};
+
}}} // namespace OVR::CAPI::GL