nux-1.16.0
nux::GLFramebufferObject Class Reference

List of all members.

Public Member Functions

 GLFramebufferObject ()
 Ctor/Dtor.
void Bind ()
 Bind this FBO as current render target.
virtual void AttachTexture (GLenum attachment, GLenum texType, GLuint texId, int mipLevel=0, int zSlice=0)
 Bind a texture to the "attachment" point of this FBO.
virtual void AttachTextures (int numTextures, GLenum texTarget[], GLuint texId[], GLenum attachment[]=NULL, int mipLevel[]=NULL, int zSlice[]=NULL)
 Bind an array of textures to multiple "attachment" points of this FBO.
virtual void AttachRenderBuffer (GLenum attachment, GLuint buffId)
 Bind a render buffer to the "attachment" point of this FBO.
void Unattach (GLenum attachment)
 Free any resource bound to the "attachment" point of this FBO.
bool IsValid ()
 Is this FBO currently a valid render target?
GLenum GetAttachedType (GLenum attachment)
 BEGIN : Accessors Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?
GLuint GetAttachedId (GLenum attachment)
 What is the Id of Renderbuffer/texture currently attached to "attachement?".
GLint GetAttachedMipLevel (GLenum attachment)
 Which mipmap level is currently attached to "attachement?".
GLint GetAttachedCubeFace (GLenum attachment)
 Which cube face is currently attached to "attachment?".
GLint GetAttachedZSlice (GLenum attachment)
 Which z-slice is currently attached to "attachment?".

Static Public Member Functions

static int GetMaxColorAttachments ()
 END : Accessors.
static void Disable ()
 Disable all FBO rendering and return to traditional, windowing-system controlled framebuffer NOTE: This is NOT an "unbind" for this specific FBO, but rather disables all FBO rendering.

Detailed Description

Definition at line 85 of file GLDeviceFrameBufferObject.h.


Member Function Documentation

void nux::GLFramebufferObject::AttachTextures ( int  numTextures,
GLenum  texTarget[],
GLuint  texId[],
GLenum  attachment[] = NULL,
int  mipLevel[] = NULL,
int  zSlice[] = NULL 
) [virtual]

Bind an array of textures to multiple "attachment" points of this FBO.

  • By default, the first 'numTextures' attachments are used, starting with GL_COLOR_ATTACHMENT0_EXT

Definition at line 94 of file GLDeviceFrameBufferObject.cpp.

References AttachTexture().

  {
    for (int i = 0; i < numTextures; ++i)
    {
      AttachTexture ( texTarget[i], texId[i],
                      attachment ? attachment[i] : (GL_COLOR_ATTACHMENT0_EXT + i),
                      mipLevel ? mipLevel[i] : 0,
                      zSlice ? zSlice[i] : 0 );
    }
  }
void nux::GLFramebufferObject::Disable ( ) [static]

Disable all FBO rendering and return to traditional, windowing-system controlled framebuffer NOTE: This is NOT an "unbind" for this specific FBO, but rather disables all FBO rendering.

This call is intentionally "static" and named "Disable" instead of "Unbind" for this reason. The motivation for this strange semantic is performance. Providing "Unbind" would likely lead to a large number of unnecessary FBO enablings/disabling.

Definition at line 69 of file GLDeviceFrameBufferObject.cpp.

  {
    CHECKGL ( glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0) );
  }
GLenum nux::GLFramebufferObject::GetAttachedType ( GLenum  attachment)

BEGIN : Accessors Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?

Accessors.

Definition at line 272 of file GLDeviceFrameBufferObject.cpp.

Referenced by Unattach().

  {
    // Returns GL_RENDERBUFFER_EXT or GL_TEXTURE
    _GuardedBind();
    GLint type = 0;
    CHECKGL ( glGetFramebufferAttachmentParameterivEXT (GL_FRAMEBUFFER_EXT, attachment,
              GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,
              &type) );
    _GuardedUnbind();
    return GLenum (type);
  }
GLint nux::GLFramebufferObject::GetMaxColorAttachments ( ) [static]

END : Accessors.

BEGIN : Static methods global to all FBOs Return number of color attachments permitted

Definition at line 149 of file GLDeviceFrameBufferObject.cpp.

  {
    GLint maxAttach = 0;
    CHECKGL ( glGetIntegerv ( GL_MAX_COLOR_ATTACHMENTS_EXT, &maxAttach ) );
    return maxAttach;
  }
bool nux::GLFramebufferObject::IsValid ( )

Is this FBO currently a valid render target?

  • Sends output to std::cerr by default but can be a user-defined C++ stream

NOTE : This function works correctly in debug build mode but always returns "true" if NDEBUG is is defined (optimized builds)

Definition at line 210 of file GLDeviceFrameBufferObject.cpp.

  {
    _GuardedBind();

    bool isOK = false;

    GLenum status;
    status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
    CHECKGL_MSG (glCheckFramebufferStatusEXT);

    switch (status)
    {
      case GL_FRAMEBUFFER_COMPLETE_EXT: // Everything's OK
        isOK = true;
        break;
      case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT") );
        isOK = false;
        break;
      case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT") );
        isOK = false;
        break;
// See issue (87) of http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
//  case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
//      nuxError(TEXT("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT"));
//      isOK = false;
//      break;
      case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT") );
        isOK = false;
        break;
      case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT") );
        isOK = false;
        break;
      case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT") );
        isOK = false;
        break;
      case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT") );
        isOK = false;
        break;
//  case GL_FRAMEBUFFER_STATUS_ERROR_EXT:
//      nuxError(TEXT("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_STATUS_ERROR_EXT"));
//      isOK = false;
//      break;
      case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] GL_FRAMEBUFFER_UNSUPPORTED_EXT") );
        isOK = false;
        break;
      default:
        nuxError (TEXT ("[GLFramebufferObject::IsValid] Unknown ERROR") );
        isOK = false;
    }

    _GuardedUnbind();
    return isOK;
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends