mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0022819: Redesign of OpenGl driver
This commit is contained in:
@@ -1,37 +1,15 @@
|
||||
// File: OpenGl_FrameBuffer.hxx
|
||||
// Author: Kirill GAVRILOV
|
||||
// Copyright: OPEN CASCADE 2011
|
||||
|
||||
#ifndef OPENGL_FRAME_BUFFER_H
|
||||
#define OPENGL_FRAME_BUFFER_H
|
||||
|
||||
#include <OpenGl_Extension.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <InterfaceGraphic.hxx>
|
||||
|
||||
#ifndef GL_FRAMEBUFFER_EXT
|
||||
#define GL_FRAMEBUFFER_EXT 0x8D40
|
||||
#endif
|
||||
|
||||
#ifndef GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
|
||||
#endif
|
||||
|
||||
#ifndef GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
|
||||
#endif
|
||||
|
||||
#ifndef GL_RENDERBUFFER_EXT
|
||||
#define GL_RENDERBUFFER_EXT 0x8D41
|
||||
#endif
|
||||
|
||||
#ifndef GL_DEPTH_ATTACHMENT_EXT
|
||||
#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
|
||||
#endif
|
||||
|
||||
#ifdef WNT
|
||||
#define GL_API_ENTRY APIENTRY
|
||||
#else
|
||||
#define GL_API_ENTRY
|
||||
#endif
|
||||
|
||||
class OpenGl_FrameBuffer
|
||||
{
|
||||
|
||||
@@ -42,33 +20,13 @@ public:
|
||||
static const GLuint NO_FRAMEBUFFER = 0;
|
||||
static const GLuint NO_RENDERBUFFER = 0;
|
||||
|
||||
public:
|
||||
|
||||
typedef void (GL_API_ENTRY *glGenFramebuffersEXT_t) (GLsizei n, GLuint* ids);
|
||||
typedef void (GL_API_ENTRY *glDeleteFramebuffersEXT_t) (GLsizei n, GLuint* ids);
|
||||
typedef void (GL_API_ENTRY *glBindFramebufferEXT_t) (GLenum target, GLuint id);
|
||||
typedef void (GL_API_ENTRY *glFramebufferTexture2DEXT_t) (GLenum target, GLenum attachmentPoint,
|
||||
GLenum textureTarget, GLuint textureId,
|
||||
GLint level);
|
||||
typedef GLenum (GL_API_ENTRY *glCheckFramebufferStatusEXT_t) (GLenum target);
|
||||
typedef void (GL_API_ENTRY *glGenRenderbuffersEXT_t) (GLsizei n, GLuint* ids);
|
||||
typedef void (GL_API_ENTRY *glDeleteRenderbuffersEXT_t) (GLsizei n, GLuint* ids);
|
||||
typedef void (GL_API_ENTRY *glBindRenderbufferEXT_t) (GLenum target, GLuint id);
|
||||
typedef void (GL_API_ENTRY *glRenderbufferStorageEXT_t) (GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height);
|
||||
|
||||
typedef void (GL_API_ENTRY *glFramebufferRenderbufferEXT_t) (GLenum target,
|
||||
GLenum attachmentPoint,
|
||||
GLenum renderbufferTarget,
|
||||
GLuint renderbufferId);
|
||||
|
||||
public:
|
||||
|
||||
OpenGl_FrameBuffer (GLint theTextureFormat = GL_RGBA8);
|
||||
|
||||
virtual ~OpenGl_FrameBuffer()
|
||||
{
|
||||
Release();
|
||||
Release (Handle(OpenGl_Context)());
|
||||
}
|
||||
|
||||
//! Texture width.
|
||||
@@ -109,12 +67,13 @@ public:
|
||||
//! current implementation will try to generate compatible FBO;
|
||||
//! 2) FBO rendering will be done in software mode (ForceWare 'hack');
|
||||
//! 3) FBO rendering will be incorrect (some obsolete Catalyst drivers).
|
||||
Standard_Boolean Init (GLsizei theViewportSizeX,
|
||||
Standard_Boolean Init (const Handle(OpenGl_Context)& theGlContext,
|
||||
GLsizei theViewportSizeX,
|
||||
GLsizei theViewportSizeY,
|
||||
GLboolean toForcePowerOfTwo = GL_FALSE);
|
||||
|
||||
//! Release GL objects
|
||||
void Release();
|
||||
void Release (const Handle(OpenGl_Context)& theGlContext);
|
||||
|
||||
//! Setup viewport to render into FBO
|
||||
void SetupViewport()
|
||||
@@ -131,15 +90,15 @@ public:
|
||||
}
|
||||
|
||||
//! Bind frame buffer (to render into the texture).
|
||||
void BindBuffer()
|
||||
void BindBuffer (const Handle(OpenGl_Context)& theGlContext)
|
||||
{
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, myGlFBufferId);
|
||||
theGlContext->extFBO->glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, myGlFBufferId);
|
||||
}
|
||||
|
||||
//! Unbind frame buffer.
|
||||
void UnbindBuffer()
|
||||
void UnbindBuffer (const Handle(OpenGl_Context)& theGlContext)
|
||||
{
|
||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, NO_FRAMEBUFFER);
|
||||
theGlContext->extFBO->glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, NO_FRAMEBUFFER);
|
||||
}
|
||||
|
||||
//! Bind the texture.
|
||||
@@ -162,7 +121,7 @@ private:
|
||||
Standard_Boolean IsProxySuccess() const;
|
||||
|
||||
//! Generate texture with undefined data
|
||||
Standard_Boolean InitTrashTexture();
|
||||
Standard_Boolean InitTrashTexture (const Handle(OpenGl_Context)& theGlContext);
|
||||
|
||||
Standard_Boolean IsValidTexture() const
|
||||
{
|
||||
@@ -179,9 +138,6 @@ private:
|
||||
return myGlTextureId != NO_RENDERBUFFER;
|
||||
}
|
||||
|
||||
Standard_Boolean AreFBOFunctionsValid();
|
||||
Standard_Boolean InitFBOFunctions();
|
||||
|
||||
private:
|
||||
|
||||
GLsizei mySizeX; // texture width
|
||||
@@ -193,18 +149,6 @@ private:
|
||||
GLuint myGlFBufferId; // FBO object ID
|
||||
GLuint myGlDepthRBId; // RenderBuffer object for depth ID
|
||||
|
||||
// functions
|
||||
glGenFramebuffersEXT_t glGenFramebuffersEXT;
|
||||
glDeleteFramebuffersEXT_t glDeleteFramebuffersEXT;
|
||||
glBindFramebufferEXT_t glBindFramebufferEXT;
|
||||
glFramebufferTexture2DEXT_t glFramebufferTexture2DEXT;
|
||||
glCheckFramebufferStatusEXT_t glCheckFramebufferStatusEXT;
|
||||
glGenRenderbuffersEXT_t glGenRenderbuffersEXT;
|
||||
glDeleteRenderbuffersEXT_t glDeleteRenderbuffersEXT;
|
||||
glBindRenderbufferEXT_t glBindRenderbufferEXT;
|
||||
glRenderbufferStorageEXT_t glRenderbufferStorageEXT;
|
||||
glFramebufferRenderbufferEXT_t glFramebufferRenderbufferEXT;
|
||||
|
||||
};
|
||||
|
||||
#endif //OPENGL_FRAME_BUFFER_H
|
||||
|
Reference in New Issue
Block a user