nux-1.14.0
|
Public Member Functions | |
PBuffer (const char *strMode, bool managed=false) | |
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 |
Definition at line 67 of file GLPBuffer.h.
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 1007 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); }