/usr/include/oce/OpenGl_FrameBuffer.hxx is in liboce-visualization-dev 0.9.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | #ifndef OPENGL_FRAME_BUFFER_H
#define OPENGL_FRAME_BUFFER_H
#include <OpenGl_Extension.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
{
public:
//! Helpful constants
static const GLuint NO_TEXTURE = 0;
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();
}
//! Texture width.
GLsizei GetSizeX() const
{
return mySizeX;
}
//! Texture height.
GLsizei GetSizeY() const
{
return mySizeY;
}
//! Viewport width.
GLsizei GetVPSizeX() const
{
return myVPSizeX;
}
//! Viewport height.
GLsizei GetVPSizeY() const
{
return myVPSizeY;
}
//! Returns true if current object was initialized
Standard_Boolean IsValid() const
{
return IsValidFrameBuffer() && IsValidTexture() && IsValidDepthBuffer();
}
//! Notice! Obsolete hardware (GeForce FX etc)
//! doesn't support rectangular textures!
//! There are 3 possible results if you are trying
//! to create non power-of-two FBO on these cards:
//! 1) FBO creation will fail,
//! 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,
GLsizei theViewportSizeY,
GLboolean toForcePowerOfTwo = GL_FALSE);
//! Release GL objects
void Release();
//! Setup viewport to render into FBO
void SetupViewport()
{
glViewport (0, 0, myVPSizeX, myVPSizeY);
}
//! Override viewport settings
void ChangeViewport (const GLsizei theVPSizeX,
const GLsizei theVPSizeY)
{
myVPSizeX = theVPSizeX;
myVPSizeY = theVPSizeY;
}
//! Bind frame buffer (to render into the texture).
void BindBuffer()
{
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, myGlFBufferId);
}
//! Unbind frame buffer.
void UnbindBuffer()
{
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, NO_FRAMEBUFFER);
}
//! Bind the texture.
void BindTexture ()
{
glEnable (GL_TEXTURE_2D); // needed only for fixed pipeline rendering
glBindTexture (GL_TEXTURE_2D, myGlTextureId);
}
//! Unbind the texture.
void UnbindTexture()
{
glBindTexture (GL_TEXTURE_2D, NO_TEXTURE);
glDisable (GL_TEXTURE_2D); // needed only for fixed pipeline rendering
}
private:
//! Check texture could be created
Standard_Boolean IsProxySuccess() const;
//! Generate texture with undefined data
Standard_Boolean InitTrashTexture();
Standard_Boolean IsValidTexture() const
{
return myGlTextureId != NO_TEXTURE;
}
Standard_Boolean IsValidFrameBuffer() const
{
return myGlFBufferId != NO_FRAMEBUFFER;
}
Standard_Boolean IsValidDepthBuffer() const
{
return myGlTextureId != NO_RENDERBUFFER;
}
Standard_Boolean AreFBOFunctionsValid();
Standard_Boolean InitFBOFunctions();
private:
GLsizei mySizeX; // texture width
GLsizei mySizeY; // texture height
GLsizei myVPSizeX; // viewport width (should be <= texture width)
GLsizei myVPSizeY; // viewport height (should be <= texture height)
GLint myTextFormat; // GL_RGB, GL_RGBA,...
GLuint myGlTextureId; // GL texture ID
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
|