applied the patch by Garrick Meeker
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,12 +35,21 @@ extern "C" {
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
||||
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) */
|
||||
/* these are enough constants for now, the remaining will be added later */
|
||||
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
|
||||
WX_GL_MIN_ALPHA, /* use blue 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 blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -35,12 +35,21 @@ extern "C" {
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
||||
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) */
|
||||
/* these are enough constants for now, the remaining will be added later */
|
||||
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
|
||||
WX_GL_MIN_ALPHA, /* use blue 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 blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@@ -27,6 +27,30 @@
|
||||
|
||||
#include <GL/glx.h>
|
||||
|
||||
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 blue 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 blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// classes
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
|
@@ -31,15 +31,28 @@
|
||||
// Constants for attriblist
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
// The generic GL implementation doesn't support most of these options,
|
||||
// such as stereo, auxiliary buffers, alpha channel, and accum buffer.
|
||||
// Other implementations may actually support them.
|
||||
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
|
||||
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) */
|
||||
/* these are enough constants for now, the remaining will be added later */
|
||||
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
|
||||
WX_GL_MIN_ALPHA, /* use blue 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 blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxGLCanvas; /* forward reference */
|
||||
@@ -104,7 +117,7 @@ class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
|
||||
inline wxGLContext* GetContext() const { return m_glContext; }
|
||||
|
||||
inline WXHDC GetHDC() const { return m_hDC; }
|
||||
void SetupPixelFormat();
|
||||
void SetupPixelFormat(int *attribList = (int*) NULL);
|
||||
void SetupPalette(const wxPalette& palette);
|
||||
wxPalette CreateDefaultPalette();
|
||||
|
||||
@@ -118,56 +131,6 @@ protected:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Give extensions proper function names. */
|
||||
|
||||
/* N.B. - this is not completely implemented as yet */
|
||||
|
||||
/* EXT_vertex_array */
|
||||
void glArrayElementEXT(GLint i);
|
||||
void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count);
|
||||
void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer);
|
||||
void glGetPointervEXT(GLenum pname, GLvoid* *params);
|
||||
void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
|
||||
|
||||
/* EXT_color_subtable */
|
||||
void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
|
||||
|
||||
/* EXT_color_table */
|
||||
void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
|
||||
void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
|
||||
void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table);
|
||||
void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params);
|
||||
void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params);
|
||||
|
||||
/* SGI_compiled_vertex_array */
|
||||
void glLockArraysSGI(GLint first, GLsizei count);
|
||||
void glUnlockArraysSGI();
|
||||
|
||||
/* SGI_cull_vertex */
|
||||
void glCullParameterdvSGI(GLenum pname, GLdouble* params);
|
||||
void glCullParameterfvSGI(GLenum pname, GLfloat* params);
|
||||
|
||||
/* SGI_index_func */
|
||||
void glIndexFuncSGI(GLenum func, GLclampf ref);
|
||||
|
||||
/* SGI_index_material */
|
||||
void glIndexMaterialSGI(GLenum face, GLenum mode);
|
||||
|
||||
/* WIN_swap_hint */
|
||||
void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
#endif
|
||||
|
@@ -44,14 +44,10 @@ static int bitcount( unsigned long n )
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
int *attrib_list, const wxPalette& palette)
|
||||
: wxScrolledWindow(parent, id, pos, size, style, name)
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxString& name, int *attribList, const wxPalette& palette):
|
||||
wxScrolledWindow(parent, id, pos, size, style, name)
|
||||
{
|
||||
XVisualInfo *vi, vi_templ;
|
||||
XWindowAttributes xwa;
|
||||
@@ -66,9 +62,51 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
return;
|
||||
}
|
||||
|
||||
if(attrib_list) {
|
||||
if(attribList) {
|
||||
int data[512], arg=0, p=0;
|
||||
|
||||
while( (attribList[arg]!=0) && (p<512) )
|
||||
{
|
||||
switch( attribList[arg++] )
|
||||
{
|
||||
case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
|
||||
case WX_GL_BUFFER_SIZE:
|
||||
data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_LEVEL:
|
||||
data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
|
||||
case WX_GL_STEREO: data[p++] = GLX_STEREO; break;
|
||||
case WX_GL_AUX_BUFFERS:
|
||||
data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_RED:
|
||||
data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_GREEN:
|
||||
data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_BLUE:
|
||||
data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_ALPHA:
|
||||
data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_DEPTH_SIZE:
|
||||
data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_STENCIL_SIZE:
|
||||
data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_ACCUM_RED:
|
||||
data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_ACCUM_GREEN:
|
||||
data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_ACCUM_BLUE:
|
||||
data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
|
||||
case WX_GL_MIN_ACCUM_ALPHA:
|
||||
data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
data[p] = 0;
|
||||
|
||||
attribList = (int*) data;
|
||||
// Get an appropriate visual
|
||||
vi = glXChooseVisual(display, DefaultScreen(display), attrib_list);
|
||||
vi = glXChooseVisual(display, DefaultScreen(display), attribList);
|
||||
if(!vi) return;
|
||||
|
||||
// Here we should make sure that vi is the same visual as the
|
||||
@@ -76,6 +114,7 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||
// there is currently no mechanism for this in wx_canvs.cc.
|
||||
} else {
|
||||
// By default, we use the visual of xwindow
|
||||
// NI: is this really senseful ? opengl in e.g. color index mode ?
|
||||
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
|
||||
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
|
||||
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
|
||||
|
@@ -58,7 +58,7 @@ wxGLContext::wxGLContext(
|
||||
bool isRGB, wxGLCanvas *win,
|
||||
const wxPalette& palette,
|
||||
const wxGLContext *other /* for sharing display lists */
|
||||
)
|
||||
)
|
||||
{
|
||||
m_window = win;
|
||||
|
||||
@@ -98,10 +98,10 @@ void wxGLContext::SetCurrent()
|
||||
wglMakeCurrent((HDC) m_hDC, m_glContext);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
setupPixelFormat(hDC);
|
||||
setupPalette(hDC);
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
void wxGLContext::SetColour(const char *colour)
|
||||
@@ -134,8 +134,7 @@ END_EVENT_TABLE()
|
||||
|
||||
wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name,
|
||||
int *attribList /* not used yet! */, const wxPalette& palette):
|
||||
wxScrolledWindow()
|
||||
int *attribList, const wxPalette& palette) : wxScrolledWindow()
|
||||
{
|
||||
m_glContext = (wxGLContext*) NULL;
|
||||
|
||||
@@ -149,7 +148,7 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPixelFormat(attribList);
|
||||
SetupPalette(palette);
|
||||
|
||||
m_glContext = new wxGLContext(TRUE, this, palette);
|
||||
@@ -173,7 +172,7 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent,
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPixelFormat(attribList);
|
||||
SetupPalette(palette);
|
||||
|
||||
m_glContext = new wxGLContext(TRUE, this, palette, shared );
|
||||
@@ -198,7 +197,7 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID i
|
||||
|
||||
m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
|
||||
|
||||
SetupPixelFormat();
|
||||
SetupPixelFormat(attribList);
|
||||
SetupPalette(palette);
|
||||
|
||||
wxGLContext *sharedContext=0;
|
||||
@@ -218,23 +217,26 @@ wxGLCanvas::~wxGLCanvas()
|
||||
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
{
|
||||
/* Suggestion from Kelly Brock <kbrock@8cs.com> (not yet implemented):
|
||||
/*
|
||||
Suggestion from Kelly Brock <kbrock@8cs.com> (not yet implemented):
|
||||
|
||||
OpenGL corruption fix is simple assuming it doesn't screw anything else
|
||||
up. Add the following line to the top of the create function:
|
||||
|
||||
OpenGL corruption fix is simple assuming it doesn't screw anything else
|
||||
up. Add the following line to the top of the create function:
|
||||
wxSize parentSize = GetClientSize();
|
||||
|
||||
All locations within the function that use 'size' are changed to
|
||||
'parentSize'.
|
||||
'parentSize'.
|
||||
The above corrects the initial display corruption with the GeForce and
|
||||
TNT2, not sure about other NVidia cards yet.
|
||||
*/
|
||||
TNT2, not sure about other NVidia cards yet.
|
||||
*/
|
||||
|
||||
static bool registeredGLCanvasClass = FALSE;
|
||||
|
||||
// We have to register a special window class because we need
|
||||
// the CS_OWNDC style for GLCanvas.
|
||||
|
||||
/*
|
||||
/*
|
||||
From Angel Popov <jumpo@bitex.com>
|
||||
|
||||
Here are two snips from a dicussion in the OpenGL Gamedev list that explains
|
||||
@@ -249,7 +251,7 @@ TNT2, not sure about other NVidia cards yet.
|
||||
do), Win95 will actually "steal" it from you. MakeCurrent fails,
|
||||
apparently, because Windows re-assigns the HDC to a different window. The
|
||||
only way to prevent this, the only reliable means, is to set CS_OWNDC."
|
||||
*/
|
||||
*/
|
||||
|
||||
if (!registeredGLCanvasClass)
|
||||
{
|
||||
@@ -274,9 +276,9 @@ TNT2, not sure about other NVidia cards yet.
|
||||
if ( !RegisterClass(&wndclass) )
|
||||
{
|
||||
wxLogLastError(wxT("RegisterClass(wxGLCanvasClass)"));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
registeredGLCanvasClass = TRUE;
|
||||
}
|
||||
|
||||
@@ -293,16 +295,16 @@ TNT2, not sure about other NVidia cards yet.
|
||||
if ( style & wxTHICK_FRAME )
|
||||
msflags |= WS_THICKFRAME;
|
||||
|
||||
/*
|
||||
/*
|
||||
A general rule with OpenGL and Win32 is that any window that will have a
|
||||
HGLRC built for it must have two flags: WS_CLIPCHILDREN & WS_CLIPSIBLINGS.
|
||||
You can find references about this within the knowledge base and most OpenGL
|
||||
books that contain the wgl function descriptions.
|
||||
*/
|
||||
*/
|
||||
|
||||
msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
|
||||
// if ( style & wxCLIP_CHILDREN )
|
||||
// msflags |= WS_CLIPCHILDREN;
|
||||
// if ( style & wxCLIP_CHILDREN )
|
||||
// msflags |= WS_CLIPCHILDREN;
|
||||
msflags |= WS_CLIPCHILDREN;
|
||||
|
||||
bool want3D;
|
||||
@@ -330,11 +332,11 @@ TNT2, not sure about other NVidia cards yet.
|
||||
msflags, NULL, exStyle);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetupPixelFormat() // (HDC hDC)
|
||||
void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
|
||||
{
|
||||
int pixelFormat;
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), /* size */
|
||||
1, /* version */
|
||||
@@ -355,8 +357,79 @@ void wxGLCanvas::SetupPixelFormat() // (HDC hDC)
|
||||
0, /* reserved */
|
||||
0, 0, 0, /* no layer, visible, damage masks */
|
||||
};
|
||||
int pixelFormat;
|
||||
|
||||
if (attribList) {
|
||||
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_COLORINDEX;
|
||||
pfd.cColorBits = 0;
|
||||
int arg=0;
|
||||
|
||||
while( (attribList[arg]!=0) )
|
||||
{
|
||||
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_OVERLAY_PLANE;
|
||||
} else if (attribList[arg] < 0) {
|
||||
pfd.iLayerType = PFD_UNDERLAY_PLANE;
|
||||
} else {
|
||||
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.cRedBits = attribList[arg++]);
|
||||
break;
|
||||
case WX_GL_MIN_GREEN:
|
||||
pfd.cColorBits += (pfd.cGreenBits = attribList[arg++]);
|
||||
break;
|
||||
case WX_GL_MIN_BLUE:
|
||||
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.cAccumRedBits = attribList[arg++]);
|
||||
break;
|
||||
case WX_GL_MIN_ACCUM_GREEN:
|
||||
pfd.cAccumBits += (pfd.cAccumGreenBits = attribList[arg++]);
|
||||
break;
|
||||
case WX_GL_MIN_ACCUM_BLUE:
|
||||
pfd.cAccumBits += (pfd.cAccumBlueBits = attribList[arg++]);
|
||||
break;
|
||||
case WX_GL_MIN_ACCUM_ALPHA:
|
||||
pfd.cAccumBits += (pfd.cAccumAlphaBits = attribList[arg++]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
|
||||
if (pixelFormat == 0) {
|
||||
MessageBox(WindowFromDC((HDC) m_hDC), wxT("ChoosePixelFormat failed."), wxT("Error"),
|
||||
@@ -575,7 +648,6 @@ void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
|
||||
{
|
||||
proc = (PFNGLVERTEXPOINTEREXTPROC) wglGetProcAddress("glVertexPointerEXT");
|
||||
}
|
||||
|
||||
if ( proc )
|
||||
(* proc) (size, type, stride, count, pointer);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user