compilation error with non-gcc fixed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@6972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
// Created: 1995, 1999
|
// Created: 1995, 1999
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart, Wolfram Gloger
|
// Copyright: (c) Julian Smart, Wolfram Gloger
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@@ -31,8 +31,8 @@ static int bitcount( unsigned long n )
|
|||||||
{
|
{
|
||||||
int bits;
|
int bits;
|
||||||
for (bits=0; n>0;) {
|
for (bits=0; n>0;) {
|
||||||
if(n & 1) bits++;
|
if(n & 1) bits++;
|
||||||
n = n >> 1;
|
n = n >> 1;
|
||||||
}
|
}
|
||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
@@ -44,10 +44,14 @@ static int bitcount( unsigned long n )
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
|
||||||
|
|
||||||
wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos,
|
wxGLCanvas::wxGLCanvas(wxWindow *parent,
|
||||||
const wxSize& size, long style,
|
wxWindowID id,
|
||||||
const wxString& name, int *attrib_list, const wxPalette& palette):
|
const wxPoint& pos,
|
||||||
wxScrolledWindow(parent, id, pos, size, style, name)
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name,
|
||||||
|
int *attrib_list, const wxPalette& palette)
|
||||||
|
: wxScrolledWindow(parent, id, pos, size, style, name)
|
||||||
{
|
{
|
||||||
XVisualInfo *vi, vi_templ;
|
XVisualInfo *vi, vi_templ;
|
||||||
XWindowAttributes xwa;
|
XWindowAttributes xwa;
|
||||||
@@ -58,53 +62,53 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos,
|
|||||||
glx_cx = 0;
|
glx_cx = 0;
|
||||||
// Check for the presence of the GLX extension
|
// Check for the presence of the GLX extension
|
||||||
if(!glXQueryExtension(display, NULL, NULL)) {
|
if(!glXQueryExtension(display, NULL, NULL)) {
|
||||||
wxDebugMsg("wxGLCanvas: GLX extension is missing\n");
|
wxDebugMsg("wxGLCanvas: GLX extension is missing\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(attrib_list) {
|
if(attrib_list) {
|
||||||
// Get an appropriate visual
|
// Get an appropriate visual
|
||||||
vi = glXChooseVisual(display, DefaultScreen(display), attrib_list);
|
vi = glXChooseVisual(display, DefaultScreen(display), attrib_list);
|
||||||
if(!vi) return;
|
if(!vi) return;
|
||||||
|
|
||||||
// Here we should make sure that vi is the same visual as the
|
// Here we should make sure that vi is the same visual as the
|
||||||
// one used by the xwindow drawable in wxCanvas. However,
|
// one used by the xwindow drawable in wxCanvas. However,
|
||||||
// there is currently no mechanism for this in wx_canvs.cc.
|
// there is currently no mechanism for this in wx_canvs.cc.
|
||||||
} else {
|
} else {
|
||||||
// By default, we use the visual of xwindow
|
// By default, we use the visual of xwindow
|
||||||
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
|
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
|
||||||
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
|
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
|
||||||
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
|
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
|
||||||
if(!vi) return;
|
if(!vi) return;
|
||||||
glXGetConfig(display, vi, GLX_USE_GL, &val);
|
glXGetConfig(display, vi, GLX_USE_GL, &val);
|
||||||
if(!val) return;
|
if(!val) return;
|
||||||
// Basically, this is it. It should be possible to use vi
|
// Basically, this is it. It should be possible to use vi
|
||||||
// in glXCreateContext() below. But this fails with Mesa.
|
// in glXCreateContext() below. But this fails with Mesa.
|
||||||
// I notified the Mesa author about it; there may be a fix.
|
// I notified the Mesa author about it; there may be a fix.
|
||||||
#ifdef OLD_MESA
|
#ifdef OLD_MESA
|
||||||
// Construct an attribute list matching the visual
|
// Construct an attribute list matching the visual
|
||||||
int a_list[32];
|
int a_list[32];
|
||||||
n = 0;
|
n = 0;
|
||||||
if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual
|
if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual
|
||||||
a_list[n++] = GLX_RGBA;
|
a_list[n++] = GLX_RGBA;
|
||||||
a_list[n++] = GLX_RED_SIZE;
|
a_list[n++] = GLX_RED_SIZE;
|
||||||
a_list[n++] = bitcount(vi->red_mask);
|
a_list[n++] = bitcount(vi->red_mask);
|
||||||
a_list[n++] = GLX_GREEN_SIZE;
|
a_list[n++] = GLX_GREEN_SIZE;
|
||||||
a_list[n++] = bitcount(vi->green_mask);
|
a_list[n++] = bitcount(vi->green_mask);
|
||||||
a_list[n++] = GLX_BLUE_SIZE;
|
a_list[n++] = GLX_BLUE_SIZE;
|
||||||
a_list[n++] = bitcount(vi->blue_mask);
|
a_list[n++] = bitcount(vi->blue_mask);
|
||||||
glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val);
|
glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val);
|
||||||
a_list[n++] = GLX_ALPHA_SIZE;
|
a_list[n++] = GLX_ALPHA_SIZE;
|
||||||
a_list[n++] = val;
|
a_list[n++] = val;
|
||||||
} else { // Color index visual
|
} else { // Color index visual
|
||||||
glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val);
|
glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val);
|
||||||
a_list[n++] = GLX_BUFFER_SIZE;
|
a_list[n++] = GLX_BUFFER_SIZE;
|
||||||
a_list[n++] = val;
|
a_list[n++] = val;
|
||||||
}
|
}
|
||||||
a_list[n] = None;
|
a_list[n] = None;
|
||||||
XFree(vi);
|
XFree(vi);
|
||||||
vi = glXChooseVisual(display, DefaultScreen(display), a_list);
|
vi = glXChooseVisual(display, DefaultScreen(display), a_list);
|
||||||
if(!vi) return;
|
if(!vi) return;
|
||||||
#endif /* OLD_MESA */
|
#endif /* OLD_MESA */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,28 +142,28 @@ void wxGLCanvas::SetColour(const char *col)
|
|||||||
{
|
{
|
||||||
wxColour *the_colour = wxTheColourDatabase->FindColour(col);
|
wxColour *the_colour = wxTheColourDatabase->FindColour(col);
|
||||||
if(the_colour) {
|
if(the_colour) {
|
||||||
GLboolean b;
|
GLboolean b;
|
||||||
glGetBooleanv(GL_RGBA_MODE, &b);
|
glGetBooleanv(GL_RGBA_MODE, &b);
|
||||||
if(b) {
|
if(b) {
|
||||||
glColor3ub(the_colour->Red(),
|
glColor3ub(the_colour->Red(),
|
||||||
the_colour->Green(),
|
the_colour->Green(),
|
||||||
the_colour->Blue());
|
the_colour->Blue());
|
||||||
} else {
|
} else {
|
||||||
GLint pix = (GLint)the_colour->m_pixel;
|
GLint pix = (GLint)the_colour->m_pixel;
|
||||||
if(pix == -1) {
|
if(pix == -1) {
|
||||||
XColor exact_def;
|
XColor exact_def;
|
||||||
exact_def.red = (unsigned short)the_colour->Red() << 8;
|
exact_def.red = (unsigned short)the_colour->Red() << 8;
|
||||||
exact_def.green = (unsigned short)the_colour->Green() << 8;
|
exact_def.green = (unsigned short)the_colour->Green() << 8;
|
||||||
exact_def.blue = (unsigned short)the_colour->Blue() << 8;
|
exact_def.blue = (unsigned short)the_colour->Blue() << 8;
|
||||||
exact_def.flags = DoRed | DoGreen | DoBlue;
|
exact_def.flags = DoRed | DoGreen | DoBlue;
|
||||||
if(!XAllocColor((Display*) GetXDisplay(), (Colormap) wxTheApp->GetMainColormap(GetXDisplay()), &exact_def)) {
|
if(!XAllocColor((Display*) GetXDisplay(), (Colormap) wxTheApp->GetMainColormap(GetXDisplay()), &exact_def)) {
|
||||||
wxDebugMsg("wxGLCanvas: cannot allocate color\n");
|
wxDebugMsg("wxGLCanvas: cannot allocate color\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pix = the_colour->m_pixel = exact_def.pixel;
|
pix = the_colour->m_pixel = exact_def.pixel;
|
||||||
}
|
}
|
||||||
glIndexi(pix);
|
glIndexi(pix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user