PBuffer Class Reference

#include <TAPsPBuffer.hpp>

List of all members.

Public Member Functions

void Activate (PBuffer *current=NULL)
unsigned int CopyToBuffer (void *ptr, int w=-1, int h=-1)
bool Create (int iWidth, int iHeight, bool bShareContexts, bool bShareObjects)
void Deactivate ()
void Destroy ()
int GetBitsPerComponent ()
int GetHeight ()
int GetNoOfComponents ()
unsigned int GetSizeInBytes ()
int GetWidth ()
bool IsSharedContext ()
 PBuffer (const char *strMode, bool managed=false)
 ~PBuffer ()

Protected Attributes

bool m_bSharedContextStatus
bool m_bShareObjectsStatus
const char * m_cpMode
int m_iBitsPerComponent
int m_iHeight
int m_iNoOfComponents
int m_iWidth

Private Member Functions

int GetIntValue (std::string sToken)
std::string GetStrValue (std::string sToken)

Friends

std::ostream & operator<< (std::ostream &output, PBuffer const &o)


Detailed Description

Before creating a PBuffer, the "OpenGL Extension Wrangler" library must be initialized first.

Example Code ---------------------------------------------------------------- Initialize the "OpenGL Extension Wrangler" library glewInit(); if (WGLEW_ARB_pbuffer) { std::cout << "OK, we can use pbuffers.\n"; } else { std::cout << "Sorry, pbuffers will not work on this platform.\n"; } ----------------------------------------------------------------

Definition at line 82 of file TAPsPBuffer.hpp.


Constructor & Destructor Documentation

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

PBuffer::~PBuffer (  ) 


Member Function Documentation

void PBuffer::Activate ( PBuffer current = NULL  ) 

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

Definition at line 669 of file TAPsPBuffer.cpp.

00670 {
00671     GLenum format;
00672     GLenum type;
00673     //----------------------------------------------------------------
00674     switch ( m_iNoOfComponents ) {
00675         case 1:
00676             format = GL_LUMINANCE;  // Is it right to ask for Red only component?
00677             break;
00678         case 2:
00679             format = GL_LUMINANCE_ALPHA;    // How to ask for GL_RG?
00680             break;
00681         case 3:
00682             format = GL_RGB;
00683             break;
00684         case 4:
00685             format = GL_RGBA;
00686             break;
00687     }
00688     //----------------------------------------------------------------
00689     switch ( m_iBitsPerComponent ) {
00690         case 8:
00691             type = GL_UNSIGNED_BYTE;
00692             break;
00693         case 32:
00694             type = GL_FLOAT;
00695             break;
00696     #ifdef GL_NV_half_float
00697         case 16:
00698             type = GL_HALF_FLOAT_NV;
00699         break;
00700     #endif
00701         default:
00702             DEBUG_MESSAGE_TAPS_PIXEL_BUFFER_HPP ( stdout, 
00703                 "PBuffer ERROR: call PBuffer::CopyToBuffer() failed - Unknown Bits Per Component!\n" 
00704             );
00705         #if defined ( WIN32 )
00706             _asm { int 3 }
00707         #endif
00708     }
00709     //----------------------------------------------------------------
00710     Activate();
00711     if ( w < 0 || m_iWidth < w )    w = m_iWidth;
00712     if ( h < 0 || m_iHeight < h )   h = m_iHeight;
00713     glReadPixels( 0, 0, w, h, format, type, ptr );
00714     Deactivate();
00715     return w * h * ( m_iNoOfComponents / 8 );
00716 }

bool PBuffer::Create ( int  iWidth,
int  iHeight,
bool  bShareContexts,
bool  bShareObjects 
)

void PBuffer::Deactivate (  ) 

void PBuffer::Destroy (  ) 

int PBuffer::GetBitsPerComponent (  )  [inline]

Definition at line 134 of file TAPsPBuffer.hpp.

00134 { return m_iBitsPerComponent; }

int PBuffer::GetHeight (  )  [inline]

Definition at line 136 of file TAPsPBuffer.hpp.

00136 { return m_iHeight; }

int PBuffer::GetIntValue ( std::string  sToken  )  [private]

Definition at line 728 of file TAPsPBuffer.cpp.

00729 {
00730     size_t pos;
00731     if ( ( pos = sToken.find( "=" ) ) != sToken.npos ) {
00732         std::string sValue = sToken.substr( pos+1, sToken.length() - pos + 1 );
00733         if ( sValue.empty() )   return 1;
00734         return atoi( sValue.c_str() );
00735     }
00736     else return 1;
00737 }

int PBuffer::GetNoOfComponents (  )  [inline]

Definition at line 133 of file TAPsPBuffer.hpp.

00133 { return m_iNoOfComponents; }

BEGIN_NAMESPACE_TAPs__OpenGL unsigned int PBuffer::GetSizeInBytes (  ) 

Definition at line 659 of file TAPsPBuffer.cpp.

00660 {
00661     return m_iWidth * m_iHeight * ( m_iNoOfComponents / 8 );
00662 }

std::string PBuffer::GetStrValue ( std::string  sToken  )  [private]

Definition at line 718 of file TAPsPBuffer.cpp.

00719 {
00720     size_t pos;
00721     if ( ( pos = sToken.find( "=" ) ) != sToken.npos ) {
00722         std::string sValue = sToken.substr( pos+1, sToken.length() - pos + 1 );
00723         return sValue;
00724     }
00725     else return "";
00726 }

int PBuffer::GetWidth (  )  [inline]

Definition at line 135 of file TAPsPBuffer.hpp.

00135 { return m_iWidth; }

bool PBuffer::IsSharedContext (  )  [inline]

Definition at line 137 of file TAPsPBuffer.hpp.

00137 { return m_bSharedContextStatus; }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
PBuffer const &  o 
) [friend]

Definition at line 89 of file TAPsPBuffer.hpp.

00091     {
00092         output  << "PBuffer with ..."
00093                 << "\n";
00094         return output;
00095     }


Member Data Documentation

Definition at line 154 of file TAPsPBuffer.hpp.

Definition at line 155 of file TAPsPBuffer.hpp.

const char* PBuffer::m_cpMode [protected]

Definition at line 153 of file TAPsPBuffer.hpp.

Definition at line 152 of file TAPsPBuffer.hpp.

int PBuffer::m_iHeight [protected]

Definition at line 150 of file TAPsPBuffer.hpp.

int PBuffer::m_iNoOfComponents [protected]

Definition at line 151 of file TAPsPBuffer.hpp.

int PBuffer::m_iWidth [protected]

Definition at line 150 of file TAPsPBuffer.hpp.


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

Generated on Mon Oct 13 11:45:51 2008 for TAPs by  doxygen 1.5.6