// Constants for attributes list
// ----------------------------------------------------------------------------
-// The generic OpenGL implementation doesn't support most of these options,
-// such as stereo, auxiliary buffers, alpha channel, and accumulator buffer.
-// Other implementations may actually support them.
+// Notice that not all implementation support options such as stereo, auxiliary
+// buffers, alpha channel, and accumulator buffer, use IsDisplaySupported() to
+// check for individual attributes support.
enum
{
- WX_GL_RGBA=1, /* use true color palette */
- WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
- WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
- WX_GL_DOUBLEBUFFER, /* use doublebuffer */
- WX_GL_STEREO, /* use stereoscopic display */
- WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
- WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
- WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
- WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
- WX_GL_MIN_ALPHA, /* use alpha buffer with most bits (> MIN_ALPHA bits) */
- WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
- WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
- WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
- WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
- WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
- WX_GL_MIN_ACCUM_ALPHA /* use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits) */
+ WX_GL_RGBA = 1, // use true color palette (on if no attrs specified)
+ WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA
+ WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay
+ WX_GL_DOUBLEBUFFER, // use double buffering (on if no attrs specified)
+ WX_GL_STEREO, // use stereoscopic display
+ WX_GL_AUX_BUFFERS, // number of auxiliary buffers
+ WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits)
+ WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits)
+ WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits)
+ WX_GL_MIN_ALPHA, // use alpha buffer with most bits (> MIN_ALPHA bits)
+ WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32)
+ WX_GL_STENCIL_SIZE, // bits for stencil buffer
+ WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits)
+ WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits)
+ WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
+ WX_GL_MIN_ACCUM_ALPHA // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
};
#define wxGLCanvasName _T("GLCanvas")
void SetCurrent(const wxGLCanvas& win);
};
+/**
+ Constants for use with wxGLCanvas.
+
+ Notice that not all implementation support options such as stereo,
+ auxiliary buffers, alpha channel, and accumulator buffer, use
+ wxGLCanvas::IsDisplaySupported() to check for individual attributes support.
+ */
+enum
+{
+ /// Use true color palette (on if no attributes at all specified).
+ WX_GL_RGBA = 1,
+
+ /// Specifies the number of bits for buffer if not WX_GL_RGBA.
+ WX_GL_BUFFER_SIZE,
+
+ /// Must be followed by 0 for main buffer, >0 for overlay, <0 for underlay.
+ WX_GL_LEVEL,
+
+ /// Use double buffering if present (on if no attributes specified).
+ WX_GL_DOUBLEBUFFER,
+
+ /// Use stereoscopic display.
+ WX_GL_STEREO,
+
+ /// Specifies number of auxiliary buffers.
+ WX_GL_AUX_BUFFERS,
+
+ /// Use red buffer with most bits (> MIN_RED bits)
+ WX_GL_MIN_RED,
+
+ /// Use green buffer with most bits (> MIN_GREEN bits)
+ WX_GL_MIN_GREEN,
+ /// Use blue buffer with most bits (> MIN_BLUE bits)
+ WX_GL_MIN_BLUE,
+
+ /// Use alpha buffer with most bits (> MIN_ALPHA bits)
+ WX_GL_MIN_ALPHA,
+
+ /// Specifies number of bits for Z-buffer (typically 0, 16 or 32).
+ WX_GL_DEPTH_SIZE,
+
+ /// Specifies number of bits for stencil buffer.
+ WX_GL_STENCIL_SIZE,
+
+ /// Specifies minimal number of red accumulator bits.
+ WX_GL_MIN_ACCUM_RED,
+
+ /// Specifies minimal number of green accumulator bits.
+ WX_GL_MIN_ACCUM_GREEN,
+
+ /// Specifies minimal number of blue accumulator bits.
+ WX_GL_MIN_ACCUM_BLUE,
+
+ /// Specifies minimal number of alpha accumulator bits.
+ WX_GL_MIN_ACCUM_ALPHA
+
+};
/**
@class wxGLCanvas
@param name
Window name.
@param attribList
- Array of integers. With this parameter you can set the device context
- attributes associated to this window.
- This array is zero-terminated: it should be set up with constants described
- in the table above.
- If a constant should be followed by a value, put it in the next array
- position.
- For example, the WX_GL_DEPTH_SIZE should be followed by the value that
- indicates the number of
- bits for the depth buffer, so:
+ Array of integers. With this parameter you can set the device
+ context attributes associated to this window. This array is
+ zero-terminated: it should be set up with constants described in
+ the table above. If a constant should be followed by a value, put
+ it in the next array position. For example, the WX_GL_DEPTH_SIZE
+ should be followed by the value that indicates the number of bits
+ for the depth buffer, e.g:
+ @code
+ attribList[n++] = WX_GL_DEPTH_SIZE;
+ attribList[n++] = 32;
+ attribList[n] = 0; // terminate the list
+ @endcode
+ If the attribute list is not specified at all, i.e. if this
+ parameter is @NULL, the default attributes including @c WX_GL_RGBA
+ and @c WX_GL_DOUBLEBUFFER are used. But notice that if you do
+ specify some attributes you also need to explicitly include these
+ two default attributes in the list if you need them.
@param palette
Palette for indexed colour (i.e. non WX_GL_RGBA) mode.
Ignored under most platforms.
if ( !attribList )
return;
+ // remove default attributes
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_COLORINDEX;
- pfd.cColorBits = 0;
- int arg=0;
- while ( attribList[arg] )
+ for ( int arg = 0; attribList[arg]; )
{
switch ( attribList[arg++] )
{
case WX_GL_RGBA:
pfd.iPixelType = PFD_TYPE_RGBA;
break;
+
case WX_GL_BUFFER_SIZE:
pfd.cColorBits = attribList[arg++];
break;
+
case WX_GL_LEVEL:
// this member looks like it may be obsolete
if ( attribList[arg] > 0 )
pfd.iLayerType = PFD_MAIN_PLANE;
arg++;
break;
+
case WX_GL_DOUBLEBUFFER:
pfd.dwFlags |= PFD_DOUBLEBUFFER;
break;
+
case WX_GL_STEREO:
pfd.dwFlags |= PFD_STEREO;
break;
+
case WX_GL_AUX_BUFFERS:
pfd.cAuxBuffers = attribList[arg++];
break;
+
case WX_GL_MIN_RED:
- pfd.cColorBits = (pfd.cColorBits +
- (pfd.cRedBits = attribList[arg++]));
+ pfd.cColorBits += (pfd.cRedBits = attribList[arg++]);
break;
+
case WX_GL_MIN_GREEN:
- pfd.cColorBits = (pfd.cColorBits +
- (pfd.cGreenBits = attribList[arg++]));
+ pfd.cColorBits += (pfd.cGreenBits = attribList[arg++]);
break;
+
case WX_GL_MIN_BLUE:
- pfd.cColorBits = (pfd.cColorBits +
- (pfd.cBlueBits = attribList[arg++]));
+ pfd.cColorBits += (pfd.cBlueBits = attribList[arg++]);
break;
+
case WX_GL_MIN_ALPHA:
// doesn't count in cColorBits
pfd.cAlphaBits = attribList[arg++];
break;
+
case WX_GL_DEPTH_SIZE:
pfd.cDepthBits = attribList[arg++];
break;
+
case WX_GL_STENCIL_SIZE:
pfd.cStencilBits = attribList[arg++];
break;
+
case WX_GL_MIN_ACCUM_RED:
- pfd.cAccumBits = (pfd.cAccumBits +
- (pfd.cAccumRedBits = attribList[arg++]));
+ pfd.cAccumBits += (pfd.cAccumRedBits = attribList[arg++]);
break;
+
case WX_GL_MIN_ACCUM_GREEN:
- pfd.cAccumBits = (pfd.cAccumBits +
- (pfd.cAccumGreenBits = attribList[arg++]));
+ pfd.cAccumBits += (pfd.cAccumGreenBits = attribList[arg++]);
break;
+
case WX_GL_MIN_ACCUM_BLUE:
- pfd.cAccumBits = (pfd.cAccumBits +
- (pfd.cAccumBlueBits = attribList[arg++]));
+ pfd.cAccumBits += (pfd.cAccumBlueBits = attribList[arg++]);
break;
+
case WX_GL_MIN_ACCUM_ALPHA:
- pfd.cAccumBits = (pfd.cAccumBits +
- (pfd.cAccumAlphaBits = attribList[arg++]));
+ pfd.cAccumBits += (pfd.cAccumAlphaBits = attribList[arg++]);
break;
}
}
1, // version
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
- PFD_DOUBLEBUFFER, // support double-buffering
- PFD_TYPE_RGBA, // color type
- 16, // preferred color depth
- 0, 0, 0, 0, 0, 0, // color bits (ignored)
- 0, // no alpha buffer
- 0, // alpha bits (ignored)
- 0, // no accumulation buffer
- 0, 0, 0, 0, // accumulator bits (ignored)
+ PFD_DOUBLEBUFFER, // use double-buffering by default
+ PFD_TYPE_RGBA, // default pixel type
+ 0, // preferred color depth (don't care)
+ 0, 0, 0, 0, 0, 0, // color bits and shift bits (ignored)
+ 0, 0, // alpha bits and shift (ignored)
+ 0, // accumulation total bits
+ 0, 0, 0, 0, // accumulator RGBA bits (not used)
16, // depth buffer
0, // no stencil buffer
0, // no auxiliary buffers