diff options
author | Brad Davis <[email protected]> | 2014-04-14 21:25:09 -0700 |
---|---|---|
committer | Brad Davis <[email protected]> | 2014-04-14 21:25:09 -0700 |
commit | 07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (patch) | |
tree | 1854d0c690eff32e77b137567c88a52d56d8b660 /Samples/CommonSrc/Render/Render_GL_Device.h | |
parent | f28388ff2af14b56ef2d973b2f4f9da021716d4c (diff) |
Adding windows 0.3.1 SDK
Diffstat (limited to 'Samples/CommonSrc/Render/Render_GL_Device.h')
-rw-r--r-- | Samples/CommonSrc/Render/Render_GL_Device.h | 113 |
1 files changed, 84 insertions, 29 deletions
diff --git a/Samples/CommonSrc/Render/Render_GL_Device.h b/Samples/CommonSrc/Render/Render_GL_Device.h index 88eaff4..5d97eef 100644 --- a/Samples/CommonSrc/Render/Render_GL_Device.h +++ b/Samples/CommonSrc/Render/Render_GL_Device.h @@ -34,13 +34,76 @@ limitations under the License. #include <OpenGL/gl.h> #include <OpenGL/glext.h> #else +#ifndef GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES +#endif #include <GL/gl.h> #include <GL/glext.h> +#if defined(OVR_OS_WIN32) +#include <GL/wglext.h> +#endif #endif namespace OVR { namespace Render { namespace GL { +// GL extension Hooks for PC. +#if defined(OVR_OS_WIN32) + +extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; +extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; +extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT; +extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT; +extern PFNGLDELETESHADERPROC glDeleteShader; +extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT; +extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT; +extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT; +extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT; +extern PFNGLACTIVETEXTUREPROC glActiveTexture; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +extern PFNGLBINDBUFFERPROC glBindBuffer; +extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; +extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; +extern PFNGLBUFFERDATAPROC glBufferData; +extern PFNGLGENBUFFERSPROC glGenBuffers; +extern PFNGLMAPBUFFERPROC glMapBuffer; +extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; +extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +extern PFNGLGETSHADERIVPROC glGetShaderiv; +extern PFNGLCOMPILESHADERPROC glCompileShader; +extern PFNGLSHADERSOURCEPROC glShaderSource; +extern PFNGLCREATESHADERPROC glCreateShader; +extern PFNGLCREATEPROGRAMPROC glCreateProgram; +extern PFNGLATTACHSHADERPROC glAttachShader; +extern PFNGLDETACHSHADERPROC glDetachShader; +extern PFNGLDELETEPROGRAMPROC glDeleteProgram; +extern PFNGLUNIFORM1IPROC glUniform1i; +extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; +extern PFNGLUSEPROGRAMPROC glUseProgram; +extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +extern PFNGLGETPROGRAMIVPROC glGetProgramiv; +extern PFNGLLINKPROGRAMPROC glLinkProgram; +extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; +extern PFNGLUNIFORM4FVPROC glUniform4fv; +extern PFNGLUNIFORM3FVPROC glUniform3fv; +extern PFNGLUNIFORM2FVPROC glUniform2fv; +extern PFNGLUNIFORM1FVPROC glUniform1fv; +extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D; +extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT; +extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT; +extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT; +extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT; + +// For testing +extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; + +extern void InitGLExtensions(); + +#endif + + class RenderDevice; class Buffer : public Render::Buffer @@ -77,6 +140,7 @@ public: virtual int GetHeight() const { return Height; } virtual void SetSampleMode(int); + virtual ovrTexture Get_ovrTexture(); virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const; }; @@ -91,11 +155,8 @@ public: { Compile(src); } - ~Shader() - { - if (GLShader) - glDeleteShader(GLShader); - } + + ~Shader(); bool Compile(const char* src); GLenum GLStage() const @@ -133,22 +194,8 @@ public: ShaderSet(); ~ShaderSet(); - virtual void SetShader(Render::Shader *s) - { - Shaders[s->GetStage()] = s; - Shader* gls = (Shader*)s; - glAttachShader(Prog, gls->GLShader); - if (Shaders[Shader_Vertex] && Shaders[Shader_Fragment]) - Link(); - } - virtual void UnsetShader(int stage) - { - Shader* gls = (Shader*)(Render::Shader*)Shaders[stage]; - if (gls) - glDetachShader(Prog, gls->GLShader); - Shaders[stage] = NULL; - Link(); - } + virtual void SetShader(Render::Shader *s); + virtual void UnsetShader(int stage); virtual void Set(PrimitiveType prim) const; @@ -161,7 +208,7 @@ public: bool Link(); }; - class RBuffer : public RefCountBase<RBuffer> +class RBuffer : public RefCountBase<RBuffer> { public: int Width, Height; @@ -180,28 +227,38 @@ class RenderDevice : public Render::RenderDevice Matrix4f Proj; +protected: Ptr<Texture> CurRenderTarget; - Array<Ptr<RBuffer> > DepthBuffers; + Array<Ptr<Texture> > DepthBuffers; GLuint CurrentFbo; const LightingParams* Lighting; public: RenderDevice(const RendererParams& p); + virtual ~RenderDevice(); - virtual void SetRealViewport(const Viewport& vp); + virtual void Shutdown(); + + virtual void FillTexturedRect(float left, float top, float right, float bottom, float ul, float vt, float ur, float vb, Color c, Ptr<OVR::Render::Texture> tex); + + virtual void SetViewport(const Recti& vp); //virtual void SetScissor(int x, int y, int w, int h); + + virtual void WaitUntilGpuIdle(); - virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1); + virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1, + bool clearColor = true, bool clearDepth = true); virtual void Rect(float left, float top, float right, float bottom) { OVR_UNUSED4(left,top,right,bottom); } virtual void BeginRendering(); virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less); virtual void SetWorldUniforms(const Matrix4f& proj); - RBuffer* GetDepthBuffer(int w, int h, int ms); + Texture* GetDepthBuffer(int w, int h, int ms); + virtual void Present (bool withVsync){OVR_UNUSED(withVsync);}; virtual void SetRenderTarget(Render::Texture* color, Render::Texture* depth = NULL, Render::Texture* stencil = NULL); @@ -209,7 +266,7 @@ public: virtual void Render(const Matrix4f& matrix, Model* model); virtual void Render(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices, - const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles); + const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles, bool useDistortionVertex = false); virtual void RenderWithAlpha(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices, const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles); @@ -222,8 +279,6 @@ public: virtual Shader *LoadBuiltinShader(ShaderStage stage, int shader); void SetTexture(Render::ShaderStage, int slot, const Texture* t); - - virtual bool SetFullscreen(DisplayMode fullscreen); }; }}} |