PDA

View Full Version : WxGLCanvas errors after Update



yodakohl
12-18-2010, 03:19 PM
Hi Community,
heres my Problem.

I'm using a wxGLCanvas Window for OpenGl rendering. Everything worked fine but after updating my Linux Distribution from 10.04 to Ubuntu 10.10 some Problems occured.

First of all SwapBuffers threw a runtime Error saying something like "Bad Drawable" and xWindow Error.

I commented SwapBuffers and it worked but the Box I drew had totally wrong walls, which seem to dissappear randomly depending on the viewing edge. If the Viewing-point is inside the Box, everything looks fine.

Here the most important Source Code.As i dont use Lightning the box is drawn by some modified Code from freeGlut.

CGL_MAP::render()
<div class="ubbcode-block"><div class="ubbcode-header">Click to reveal.. <input type="button" class="form-button" value="Show me!" onclick="toggle_spoiler(this, 'Yikes, my eyes!', 'Show me!')" />]<div style="display: none;">


void CGL_MAP::render()
{

SetCurrent();
wxPaintDC(this);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST); // activate Z-Buffer

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glPushMatrix(); //Just setting "Cameras Position"
glRotatef (rotx, 1,0,0);
glRotatef (roty, 0,1,0);
glRotatef (rotz, 0,0,1);
glTranslatef (-mx,-my,-mz);

glPushMatrix();
glScalef(lx,ly,lz);
double size = 1;
# define V(a,b,c) glVertex3d( a size, b size, c size );
# define N(a,b,c) glNormal3d( a, b, c );
glBegin( GL_QUADS );
N( 1.0, 0.0, 0.0);
glColor3f(1,0,0);
V(+,-,+);
V(+,-,-);
V(+,+,-);
V(+,+,+);
N( 0.0, 1.0, 0.0);
glColor3f(0,1,0);
V(+,+,+);
V(+,+,-);
V(-,+,-);
V(-,+,+);
N( 0.0, 0.0, 1.0);
glColor3f(0,0,1);
V(+,+,+);
V(-,+,+);
V(-,-,+);
V(+,-,+);
N(-1.0, 0.0, 0.0);
glColor3f(1,0,1);
V(-,-,+);
V(-,+,+);
V(-,+,-);
V(-,-,-);
N( 0.0,-1.0, 0.0);
glColor3f(0,1,1);
V(-,-,+);
V(-,-,-);
V(+,-,-);
V(+,-,+);
N( 0.0, 0.0,-1.0);
glColor3f(1,0,1);
V(-,-,-);
V(-,+,-);
V(+,+,-);
V(+,-,-);
glEnd();
# undef V
# undef N
glPopMatrix();


glPopMatrix();


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
projection( 25, 1, 5, 30000);

glViewport(0, 0, (GLint)GetSize().x, (GLint)GetSize().y);

glFlush();
//glFinish();
//SwapBuffers();
}

[/QUOTE]</div>




GL_CAM::projection
<div class="ubbcode-block"><div class="ubbcode-header">Click to reveal.. <input type="button" class="form-button" value="Show me!" onclick="toggle_spoiler(this, 'Yikes, my eyes!', 'Show me!')" />]<div style="display: none;">


void GL_CAM::projection(double fovy, double aspect, double zNear, double zFar) const
{
double xmin,xmax,ymin,ymax;
ymax = zNear*tan(fovy *PI_D); //PI/360
ymin = -ymax;
xmin = ymin*aspect;
xmax = ymax*aspect;
glFrustum(xmin,xmax,ymin,ymax,zNear,zFar);
}

[/QUOTE]</div>



Can anyone see any Mistakes? I'm grateful for any advices, concerning code as well as the basic design.

Maby someone already had similar Troubles.
Maby there is a better way for Coloring the Sides of the boxes (Does not have to look beautiful, just for orientation)

Thanks for any help

Greets Yoda

ZbuffeR
12-19-2010, 01:50 AM
Do you ask for a double buffered GL window ? You should do that and use swapbuffers.
Otherwise, check your drivers, because probably when updating your disrib version, you may well have changed from a proprietary to an opensource driver, or vice-versa.