rTextureRenderTarget Class Reference

texture that can be used as a target for rendering More...

#include <rTextureRenderTarget.h>

Inheritance diagram for rTextureRenderTarget:

Inheritance graph
[legend]
Collaboration diagram for rTextureRenderTarget:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void Clear ()
 clears the texture
 ~rTextureRenderTarget ()
 rTextureRenderTarget (int width, int height)
 creates a render target texture of the specified dimensions
void Push ()
 makes this texture the active render target
void Pop ()
 removes this texture as the active render target
bool IsTarget () const
int GetHeight () const
int GetWidth () const

Static Public Member Functions

static void Restore ()
 restores current render target if it was overwritten by an evil manual glBindFramebuffer call

Protected Member Functions

virtual void OnSelect (bool)
 Selects the texture for rendering.
virtual void OnUnload ()
 Unloads the texture from OpenGL and memory.

Private Attributes

rGLuintObjectTexture texture_
 the texture render target
rGLuintObjectRenderbuffer depthBuffer_
 the depth buffer
rGLuintObjectFramebuffer frameBuffer_
 the frame buffer
rTextureRenderTargetprevious
int width_
int height_
GLenum colorMode
GLenum depthMode

Static Private Attributes

static rTextureRenderTargetanchor = 0


Detailed Description

texture that can be used as a target for rendering

Definition at line 36 of file rTextureRenderTarget.h.


Constructor & Destructor Documentation

rTextureRenderTarget::~rTextureRenderTarget (  ) 

Definition at line 59 of file rTextureRenderTarget.cpp.

References Clear(), IsTarget(), and Pop().

00060 {
00061     if ( IsTarget() )
00062     {
00063         Pop();
00064     }
00065 
00066     Clear();
00067 }

Here is the call graph for this function:

rTextureRenderTarget::rTextureRenderTarget ( int  width,
int  height 
)

creates a render target texture of the specified dimensions

Definition at line 69 of file rTextureRenderTarget.cpp.

References depthBuffer_, height_, NULL, Pop(), previous, Push(), sr_CheckGLError(), tASSERT, texture_, and width_.

00070 {
00071 #ifndef DEDICATED
00072     sr_CheckGLError();
00073 
00074     width_ = width;
00075     height_ = height;
00076     previous = 0;
00077 
00078 #ifdef GLEW_EXT_framebuffer_object
00079     if ( GLEW_EXT_framebuffer_object )
00080     {
00081         Push();
00082         sr_CheckGLError();
00083 
00084         // generate texture
00085         glBindTexture( GL_TEXTURE_2D, texture_ );
00086         sr_CheckGLError();
00087 
00088         // make texture
00089         glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
00090         sr_CheckGLError();
00091 
00092         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00093         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
00094         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
00095         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
00096 
00097         glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture_, 0 );
00098         sr_CheckGLError();
00099 
00100         glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depthBuffer_ );
00101         sr_CheckGLError();
00102 
00103         glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT32, width, height );
00104         sr_CheckGLError();
00105 
00106         glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer_ );
00107         sr_CheckGLError();
00108 
00109         GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT);
00110         switch ( status )
00111         {
00112         case GL_FRAMEBUFFER_COMPLETE_EXT:
00113             break;
00114         case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
00115             throw rExceptionGLEW( "Unsupported frame buffer operation" );
00116         default:
00117             tASSERT( 0 );
00118         }
00119 
00120         sr_CheckGLError();
00121 
00122         Pop();
00123 
00124         return;
00125     }
00126 #endif // GLEW_EXT_framebuffer_object
00127 
00128     throw rExceptionGLEW( "frame buffer extension not supported" );
00129 #endif
00130 }

Here is the call graph for this function:


Member Function Documentation

void rTextureRenderTarget::Clear ( void   ) 

clears the texture

texture that can be used as a target for rendering

Parameters:
@return 

Definition at line 50 of file rTextureRenderTarget.cpp.

References depthBuffer_, frameBuffer_, IsTarget(), tASSERT, and texture_.

Referenced by ~rTextureRenderTarget().

00051 {
00052     tASSERT( !IsTarget() );
00053 
00054     texture_.Delete();
00055     depthBuffer_.Delete();
00056     frameBuffer_.Delete();
00057 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rTextureRenderTarget::Push (  ) 

makes this texture the active render target

Definition at line 132 of file rTextureRenderTarget.cpp.

References anchor, frameBuffer_, previous, and sr_CheckGLError().

Referenced by rTextureRenderTarget(), and sr_MotionBlurCore().

00133 {
00134 #ifndef DEDICATED
00135     previous = anchor;
00136     anchor = this;
00137 
00138 #ifdef GLEW_EXT_framebuffer_object
00139     sr_CheckGLError();
00140 
00141     glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, frameBuffer_ );
00142 
00143     sr_CheckGLError();
00144 #endif
00145 #endif
00146 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rTextureRenderTarget::Pop (  ) 

removes this texture as the active render target

Definition at line 148 of file rTextureRenderTarget.cpp.

References anchor, IsTarget(), previous, Restore(), and tASSERT.

Referenced by rTextureRenderTarget(), sr_MotionBlurCore(), and ~rTextureRenderTarget().

00149 {
00150 #ifndef DEDICATED
00151     tASSERT( IsTarget() );
00152 
00153     anchor = previous;
00154 
00155     Restore();
00156 #endif
00157 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rTextureRenderTarget::Restore (  )  [static]

restores current render target if it was overwritten by an evil manual glBindFramebuffer call

Definition at line 159 of file rTextureRenderTarget.cpp.

References anchor, frameBuffer_, and sr_CheckGLError().

Referenced by Pop().

00160 {
00161 #ifdef GLEW_EXT_framebuffer_object
00162     sr_CheckGLError();
00163     glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, anchor ? anchor->frameBuffer_ : 0 );
00164     sr_CheckGLError();
00165 #endif
00166 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool rTextureRenderTarget::IsTarget (  )  const [inline]

Definition at line 56 of file rTextureRenderTarget.h.

References anchor.

Referenced by Clear(), Pop(), sr_MotionBlurCore(), and ~rTextureRenderTarget().

00057     {
00058         return anchor == this;
00059     }

Here is the caller graph for this function:

int rTextureRenderTarget::GetHeight (  )  const [inline]

Definition at line 61 of file rTextureRenderTarget.h.

References height_.

Referenced by sr_MotionBlurCore().

00062     {
00063         return height_;
00064     }

Here is the caller graph for this function:

int rTextureRenderTarget::GetWidth (  )  const [inline]

Definition at line 66 of file rTextureRenderTarget.h.

References width_.

Referenced by sr_MotionBlurCore().

00067     {
00068         return width_;
00069     }

Here is the caller graph for this function:

void rTextureRenderTarget::OnSelect ( bool  enforce  )  [protected, virtual]

Selects the texture for rendering.

Parameters:
enforce enforce when set to true, the texture should be loaded even if the configuration says it should not

Implements rITexture.

Definition at line 168 of file rTextureRenderTarget.cpp.

References texture_.

00169 {
00170 #ifndef DEDICATED
00171     glBindTexture( GL_TEXTURE_2D, texture_ );
00172 #endif
00173 }

virtual void rTextureRenderTarget::OnUnload ( void   )  [inline, protected, virtual]

Unloads the texture from OpenGL and memory.

Implements rITexture.

Definition at line 74 of file rTextureRenderTarget.h.

00074 {}


Member Data Documentation

rGLuintObjectTexture rTextureRenderTarget::texture_ [private]

the texture render target

Definition at line 76 of file rTextureRenderTarget.h.

Referenced by Clear(), OnSelect(), and rTextureRenderTarget().

rGLuintObjectRenderbuffer rTextureRenderTarget::depthBuffer_ [private]

the depth buffer

Definition at line 77 of file rTextureRenderTarget.h.

Referenced by Clear(), and rTextureRenderTarget().

rGLuintObjectFramebuffer rTextureRenderTarget::frameBuffer_ [private]

the frame buffer

Definition at line 78 of file rTextureRenderTarget.h.

Referenced by Clear(), Push(), and Restore().

rTextureRenderTarget * rTextureRenderTarget::anchor = 0 [static, private]

Definition at line 81 of file rTextureRenderTarget.h.

Referenced by IsTarget(), Pop(), Push(), and Restore().

rTextureRenderTarget* rTextureRenderTarget::previous [private]

Definition at line 82 of file rTextureRenderTarget.h.

Referenced by Pop(), Push(), and rTextureRenderTarget().

int rTextureRenderTarget::width_ [private]

Definition at line 84 of file rTextureRenderTarget.h.

Referenced by GetWidth(), and rTextureRenderTarget().

int rTextureRenderTarget::height_ [private]

Definition at line 84 of file rTextureRenderTarget.h.

Referenced by GetHeight(), and rTextureRenderTarget().

GLenum rTextureRenderTarget::colorMode [private]

Definition at line 85 of file rTextureRenderTarget.h.

GLenum rTextureRenderTarget::depthMode [private]

Definition at line 85 of file rTextureRenderTarget.h.


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:54:33 2008 for Armagetron Advanced by  doxygen 1.5.4