23
#ifndef __PBUFFERS_H__
24
#define __PBUFFERS_H__
27
#include "GLResource.h"
29
# pragma warning (disable : 4786)
32
# include <GL/glxext.h>
33
#elif defined(__APPLE__)
40
// The pixel format for the pbuffer is controlled by the mode string passed
41
// into the PBuffer constructor. This string can have the following attributes:
43
// r - r pixel format (for float buffer).
44
// rg - rg pixel format (for float buffer).
45
// rgb - rgb pixel format. 8 bit or 16/32 bit in float buffer mode
46
// rgba - same as "rgb alpha" string
47
// alpha - must have alpha channel
48
// depth - must have a depth buffer
49
// depth=n - must have n-bit depth buffer
50
// stencil - must have a stencil buffer
51
// double - must support double buffered rendering
52
// samples=n - must support n-sample antialiasing (n can be 2 or 4)
53
// float=n - must support n-bit per channel floating point
57
// textureCUBE - must support binding pbuffer as texture to specified target
58
// - binding the depth buffer is also supporting by specifying
59
// '=depth' like so: texture2D=depth or textureRECT=depth
60
// - the internal format of the texture will be rgba by default or
61
// float if pbuffer is floating point
69
// see above for documentation on strMode format
70
// set managed to true if you want the class to cleanup OpenGL objects in destructor
71
PBuffer(const char *strMode, bool managed = false);
74
bool Initialize(int iWidth, int iHeight, bool bShareContexts, bool bShareObjects);
77
void Activate(PBuffer *current = NULL); // to switch between pbuffers, pass active pbuffer as argument
81
int Bind(int iBuffer);
82
int Release(int iBuffer);
84
void HandleModeSwitch();
87
unsigned int GetSizeInBytes();
88
unsigned int CopyToBuffer(void *ptr, int w=-1, int h=-1);
90
inline int GetNumComponents()
91
{ return m_iNComponents; }
93
inline int GetBitsPerComponent()
94
{ return m_iBitsPerComponent; }
99
inline int GetHeight()
100
{ return m_iHeight; }
102
inline bool IsSharedContext()
103
{ return m_bSharedContext; }
106
inline bool IsTexture()
107
{ return m_bIsTexture; }
112
HDC m_hDC; ///< Handle to a device context.
113
HGLRC m_hGLRC; ///< Handle to a GL context.
114
HPBUFFERARB m_hPBuffer;///< Handle to a pbuffer.
119
std::vector<int> m_pfAttribList;
120
std::vector<int> m_pbAttribList;
125
GLXPbuffer m_glxPbuffer;
126
GLXContext m_glxContext;
128
Display *m_pOldDisplay;
129
GLXPbuffer m_glxOldDrawable;
130
GLXContext m_glxOldContext;
132
std::vector<int> m_pfAttribList;
133
std::vector<int> m_pbAttribList;
134
#elif defined(__APPLE__)
135
AGLContext m_context;
137
std::vector<int> m_pfAttribList;
143
int m_iBitsPerComponent;
145
const char *m_strMode;
146
bool m_bSharedContext;
147
bool m_bShareObjects;
150
std::string getStringValue(std::string token);
151
int getIntegerValue(std::string token);
152
#if defined(UNIX) || defined(WIN32)
153
void parseModeString(const char *modeString, std::vector<int> *pfAttribList, std::vector<int> *pbAttribList);
162
#endif // __PBUFFERS_H__
23
#ifndef __PBUFFERS_H__
24
#define __PBUFFERS_H__
27
#include "GLResource.h"
29
# pragma warning (disable : 4786)
32
# include <GL/glxext.h>
33
#elif defined(__APPLE__)
40
// The pixel format for the pbuffer is controlled by the mode string passed
41
// into the PBuffer constructor. This string can have the following attributes:
43
// r - r pixel format (for float buffer).
44
// rg - rg pixel format (for float buffer).
45
// rgb - rgb pixel format. 8 bit or 16/32 bit in float buffer mode
46
// rgba - same as "rgb alpha" string
47
// alpha - must have alpha channel
48
// depth - must have a depth buffer
49
// depth=n - must have n-bit depth buffer
50
// stencil - must have a stencil buffer
51
// double - must support double buffered rendering
52
// samples=n - must support n-sample antialiasing (n can be 2 or 4)
53
// float=n - must support n-bit per channel floating point
57
// textureCUBE - must support binding pbuffer as texture to specified target
58
// - binding the depth buffer is also supporting by specifying
59
// '=depth' like so: texture2D=depth or textureRECT=depth
60
// - the internal format of the texture will be rgba by default or
61
// float if pbuffer is floating point
69
// see above for documentation on strMode format
70
// set managed to true if you want the class to cleanup OpenGL objects in destructor
71
PBuffer(const char *strMode, bool managed = false);
74
bool Initialize(int iWidth, int iHeight, bool bShareContexts, bool bShareObjects);
77
void Activate(PBuffer *current = NULL); // to switch between pbuffers, pass active pbuffer as argument
81
int Bind(int iBuffer);
82
int Release(int iBuffer);
84
void HandleModeSwitch();
87
unsigned int GetSizeInBytes();
88
unsigned int CopyToBuffer(void *ptr, int w=-1, int h=-1);
90
inline int GetNumComponents()
91
{ return m_iNComponents; }
93
inline int GetBitsPerComponent()
94
{ return m_iBitsPerComponent; }
99
inline int GetHeight()
100
{ return m_iHeight; }
102
inline bool IsSharedContext()
103
{ return m_bSharedContext; }
106
inline bool IsTexture()
107
{ return m_bIsTexture; }
112
HDC m_hDC; ///< Handle to a device context.
113
HGLRC m_hGLRC; ///< Handle to a GL context.
114
HPBUFFERARB m_hPBuffer;///< Handle to a pbuffer.
119
std::vector<int> m_pfAttribList;
120
std::vector<int> m_pbAttribList;
125
GLXPbuffer m_glxPbuffer;
126
GLXContext m_glxContext;
128
Display *m_pOldDisplay;
129
GLXPbuffer m_glxOldDrawable;
130
GLXContext m_glxOldContext;
132
std::vector<int> m_pfAttribList;
133
std::vector<int> m_pbAttribList;
134
#elif defined(__APPLE__)
135
AGLContext m_context;
137
std::vector<int> m_pfAttribList;
143
int m_iBitsPerComponent;
145
const char *m_strMode;
146
bool m_bSharedContext;
147
bool m_bShareObjects;
150
std::string getStringValue(std::string token);
151
int getIntegerValue(std::string token);
152
#if defined(UNIX) || defined(WIN32)
153
void parseModeString(const char *modeString, std::vector<int> *pfAttribList, std::vector<int> *pbAttribList);
162
#endif // __PBUFFERS_H__