Back to index

nux  3.0.0
Public Member Functions | Protected Attributes | Private Member Functions
nux::PBuffer Class Reference

#include <GLPBuffer.h>

List of all members.

Public Member Functions

 PBuffer (const char *strMode, bool managed=false)
 ~PBuffer ()
bool Initialize (int iWidth, int iHeight, bool bShareContexts, bool bShareObjects)
void Destroy ()
void Activate (PBuffer *current=NULL)
void Deactivate ()
unsigned int GetSizeInBytes ()
 return the total size in bytes of the PBuffer
unsigned int CopyToBuffer (void *ptr, int w=-1, int h=-1)
 make a copy the entire PBuffer in the memory.
int GetNumComponents ()
int GetBitsPerComponent ()
int GetWidth ()
int GetHeight ()
bool IsSharedContext ()

Protected Attributes

int m_iWidth
int m_iHeight
int m_iNComponents
int m_iBitsPerComponent
const char * m_strMode
bool m_bSharedContext
bool m_bShareObjects

Private Member Functions

std::string getStringValue (std::string token)
int getIntegerValue (std::string token)

Detailed Description

Definition at line 69 of file GLPBuffer.h.


Constructor & Destructor Documentation

nux::PBuffer::PBuffer ( const char *  strMode,
bool  managed = false 
)

Member Function Documentation

void nux::PBuffer::Activate ( PBuffer current = NULL)
unsigned int nux::PBuffer::CopyToBuffer ( void *  ptr,
int  w = -1,
int  h = -1 
)

make a copy the entire PBuffer in the memory.

You have to allocate this area (ptr). if ever you want to read a smaller size : specify it through w,h. otherwise w=h=-1

Definition at line 1008 of file GLPBuffer.cpp.

  {
    GLenum format = 0;
    GLenum type = 0;

    switch (m_iNComponents)
    {
      case 1: //
        format = GL_LUMINANCE; // is it right to ask for Red only component ?
        break;
      case 2:
        format = GL_LUMINANCE_ALPHA; //How to ask for GL_RG ??
        break;
      case 3:
        format = GL_RGB;
        break;
      case 4:
        format = GL_RGBA;
        break;
    }

    switch (m_iBitsPerComponent)
    {
      case 8:
        type = GL_UNSIGNED_BYTE;
        break;
      case 32:
        type = GL_FLOAT;
        break;
#ifdef GL_NV_half_float
      case 16:
        type = GL_HALF_FLOAT_NV;
        break;
#endif
      default:
        nuxDebugMsg ("unknown m_iBitsPerComponent\n");
#      if defined(WIN32)
        __debugbreak();
#      endif
    }

    Activate();

    if ( (w < 0) || (w > m_iWidth) )
      w = m_iWidth;

    if ( (h < 0) || (h > m_iHeight) )
      h = m_iHeight;

    glReadPixels (0, 0, w, h, format, type, ptr);
    Deactivate();
    return w * h * (m_iNComponents / 8);
  }

Definition at line 98 of file GLPBuffer.h.

    {
      return m_iBitsPerComponent;
    }
int nux::PBuffer::GetHeight ( ) [inline]

Definition at line 108 of file GLPBuffer.h.

    {
      return m_iHeight;
    }
int nux::PBuffer::getIntegerValue ( std::string  token) [private]

Definition at line 976 of file GLPBuffer.cpp.

  {
    size_t pos;

    if ( (pos = token.find ("=") ) != token.npos)
    {
      std::string value = token.substr (pos + 1, token.length() - pos + 1);

      if (value.empty() )
        return 1;

      return atoi (value.c_str() );
    }
    else
      return 1;
  }

Definition at line 93 of file GLPBuffer.h.

    {
      return m_iNComponents;
    }
unsigned int nux::PBuffer::GetSizeInBytes ( )

return the total size in bytes of the PBuffer

Definition at line 998 of file GLPBuffer.cpp.

  {
    return m_iWidth * m_iHeight * (m_iNComponents / 8);
  }
std::string nux::PBuffer::getStringValue ( std::string  token) [private]

Definition at line 963 of file GLPBuffer.cpp.

  {
    size_t pos;

    if ( (pos = token.find ("=") ) != token.npos)
    {
      std::string value = token.substr (pos + 1, token.length() - pos + 1);
      return value;
    }
    else
      return "";
  }
int nux::PBuffer::GetWidth ( ) [inline]

Definition at line 103 of file GLPBuffer.h.

    {
      return m_iWidth;
    }
bool nux::PBuffer::Initialize ( int  iWidth,
int  iHeight,
bool  bShareContexts,
bool  bShareObjects 
)
bool nux::PBuffer::IsSharedContext ( ) [inline]

Definition at line 113 of file GLPBuffer.h.

    {
      return m_bSharedContext;
    }

Member Data Documentation

Definition at line 161 of file GLPBuffer.h.

Definition at line 162 of file GLPBuffer.h.

Definition at line 158 of file GLPBuffer.h.

int nux::PBuffer::m_iHeight [protected]

Definition at line 156 of file GLPBuffer.h.

Definition at line 157 of file GLPBuffer.h.

int nux::PBuffer::m_iWidth [protected]

Definition at line 155 of file GLPBuffer.h.

const char* nux::PBuffer::m_strMode [protected]

Definition at line 160 of file GLPBuffer.h.


The documentation for this class was generated from the following files: