SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLDepthBuffer.h
Go to the documentation of this file.
1 /**
2  * \file SLGLDepthBuffer.h
3  * \brief Uses an OpenGL framebuffer object as a depth-buffer
4  * \date May 2020
5  * \authors Michael Schertenleib
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLGLDEPTHBUFFER_H
12 #define SLGLDEPTHBUFFER_H
13 
14 #include <SLObject.h>
15 #include <SLGLState.h>
16 #include <SL.h>
17 
18 //-----------------------------------------------------------------------------
20 {
21 public:
23  SLenum magFilter = GL_NEAREST,
24  SLenum minFilter = GL_NEAREST,
25  SLint wrap = GL_REPEAT,
26  SLfloat borderColor[] = nullptr,
27  SLenum target = GL_TEXTURE_2D,
28  SLstring name = "SM-DepthBuffer");
30 
31  SLint texID() { return _texID; }
32  SLint target() { return _target; }
33  void bindActive(SLuint texUnit) const;
34  void bind();
35  void unbind();
36  void bindFace(SLenum face) const;
37  SLfloat* readPixels() const;
39 
40 private:
41  SLVec2i _dimensions; //!< Size of the texture
42  SLuint _fboID; //!< ID of the FB object
43  SLint _prevFboID; //!< ID of the previously bound FB
44  SLuint _texID; //!< ID of the texture
45  SLenum _target; //!< GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
46 };
47 //-----------------------------------------------------------------------------
48 typedef std::vector<SLGLDepthBuffer*> SLGLVDepthBuffer;
49 //-----------------------------------------------------------------------------
50 #endif // SLGLDEPTHBUFFER_H
float SLfloat
Definition: SL.h:173
unsigned int SLenum
Definition: SL.h:176
unsigned int SLuint
Definition: SL.h:171
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
std::vector< SLGLDepthBuffer * > SLGLVDepthBuffer
Singleton class for global render state.
void bindActive(SLuint texUnit) const
Sets the active texture unit within the shader and binds the texture.
void bindFace(SLenum face) const
Binds a specific texture face of a cube map depth buffer.
SLuint _fboID
ID of the FB object.
SLint _prevFboID
ID of the previously bound FB.
SLVec2i dimensions()
SLenum _target
GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
SLVec2i _dimensions
Size of the texture.
void bind()
Binds the OpenGL frame buffer object for the depth buffer.
SLuint _texID
ID of the texture.
void unbind()
Ends the usage of the depth buffer frame buffer.
SLfloat * readPixels() const
SLGLDepthBuffer(const SLVec2i &dimensions, SLenum magFilter=GL_NEAREST, SLenum minFilter=GL_NEAREST, SLint wrap=GL_REPEAT, SLfloat borderColor[]=nullptr, SLenum target=GL_TEXTURE_2D, SLstring name="SM-DepthBuffer")
Base class for all other classes.
Definition: SLObject.h:23
const SLstring & name() const
Definition: SLObject.h:38