glMakeCurrent causes x server to crash
glMakeCurrent causes x server to crash
- Subject: glMakeCurrent causes x server to crash
- From: Joe Miller <email@hidden>
- Date: Fri, 1 Sep 2006 12:22:07 -0700 (PDT)
Hi,
I'm having a problem with glXMakeCurrent. It seems to
cause my x-server to crash when ever I switch my
current context from being one that is associated with
pixmap to a context that is associated to a window.
The other direction (window to pixmap) doesn't have
this problem. I was wondering if anyones had this
problem and found a resolution.
Here's a sample program I put together. I'm not an X
programmer so please mind any niceties that I may have
not included. The basic idea is that I need to be able
to switch my context from a pixmap (so it's not
displayed to the terminal) to one with a window (so
that it is displayed). If there's other ways to
accomplish this, I'd be happy to entertain those ideas
as well. The same actually also happens if you do
glXMakeCurrent (display, glxpixmap, context);
glxMakeCurrent (display, None, NULL);
Just some more info this only happens on my OS X (in
particular I'm running 10.4). I don't have the problem
on linux or solaris. It has to be something with
specificly because I don't have any problem ssh'ing
into my mac from my linux box either.
Any help would be great. Thanks
-joe
#include <X11/X.h>
#include <GL/glx.h>
#include <stdio.h>
static XVisualInfo *visualInfo=0;
static int glxVisualAttrs[]={
GLX_RGBA,
GLX_RED_SIZE,4,
GLX_GREEN_SIZE,4,
GLX_BLUE_SIZE,4,
None
};
void drawBox() {
printf("Drawing a box\n");
}
int glxPixmapXErrorHandler(Display
*display,XErrorEvent *event) {
char errorStr[256];
XGetErrorText(display,event->serial,errorStr,256);
printf("X serial error: %d
%s\n",event->serial,errorStr);
XGetErrorText(display,event->error_code,errorStr,256);
printf("X error code: %d
%s\n",event->serial,errorStr);
XGetErrorText(display,event->request_code,errorStr,256);
printf("X request code: %d
%s\n",event->request_code,errorStr);
XGetErrorText(display,event->serial,errorStr,256);
printf("X minor code: %d
%s\n",event->minor_code,errorStr);
return 0;
}
int main(int argc,char **argv) {
Display *display=0,*display2=0;
XVisualInfo *visual=0,*visual2=0;
Pixmap xPixmap=None;
GLXPixmap glxPixmap=None;
GLXContext glxContext=0, glxContext2=0;
Window window=0,window2=0;
int width=100,height=100;
XSetErrorHandler(glxPixmapXErrorHandler);
printf("Make GLX objects\n");
if ((display =XOpenDisplay(NULL)) == NULL)
return -1;
XSynchronize(display,1);
if
(!(visual=glXChooseVisual(display,DefaultScreen(display),glxVisualAttrs)))
{
return -1;
}
if
((xPixmap=XCreatePixmap(display,RootWindow(display,visual->screen),
width,height,visual->depth)) == None) {
return -1;
}
if
((glxPixmap=glXCreateGLXPixmap(display,visual,xPixmap))
== None)
return -1;
if
((glxContext=glXCreateContext(display,visual,0,GL_FALSE))
== 0)
return -1;
if(!glXMakeCurrent(display,glxPixmap,glxContext))
return -1;
drawBox();
// WINDOW 2
printf ("WINDOW 2\n");
if ((display2 =XOpenDisplay(NULL)) == NULL)
return -1;
if
(!(visual2=glXChooseVisual(display2,DefaultScreen(display2),glxVisualAttrs)))
{
return -1;
}
if ((window2 =
XCreateSimpleWindow(display2,
RootWindow( display2,
visual2->screen),
300, 300, 200, 200, 0, 1, 1)) ==
None){
return -1;
}
if
((glxContext2=glXCreateContext(display2,visual2,0,GL_TRUE))
== 0)
return -1;
if(!glXMakeCurrent(display2,window2,glxContext2))
return -1;
drawBox();
//Clean up
glXDestroyGLXPixmap(display,glxPixmap);
XFreePixmap(display,xPixmap);
glXDestroyContext( display, glxContext);
glxContext = NULL;
if (display)
XSync(display,0);
// if we create the display, we'll delete it
if (display){
XCloseDisplay(display);
display = NULL;
}
// Destroy window2
glXDestroyContext( display2, glxContext2);
glxContext2 = NULL;
XDestroyWindow(display2, window2);
if (display2)
XSync(display2,0);
// if we create the display, we'll delete it
if (display2){
XCloseDisplay(display2);
display2 = NULL;
}
printf("Success\n");
return 0;
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden