PDA

View Full Version : OpenGL + POSIX thread = Segmentation fault



KOS
02-16-2004, 05:42 AM
When I try to draw some objects in pthread function programm breaks (segmentation fault)...

Same example:

void *compile_events(void *aSuper) {
class MainGL *super;
super = (class MainGL*) aSuper;
while(1) {
super->drawSomething();
}
}

MainGL is a simple class which has a display, reshape & other same openGL functions (friend functions of class).

Please, help me if you understand my problem.

Stonemaster
02-16-2004, 11:15 AM
It seems to me that either the maingl window class isn't initialized yet - invalid pointer - or the OpenGL display hasn't been setup correctly. Make sure the thread is created _after_ all necessary setup has been done.

Regards,
-stone.

--
http://www.steinsoft.net

02-18-2004, 08:37 PM
Perhaps it's worth mentioning that OpenGL is _not_ thead safe...

02-18-2004, 08:46 PM
Although "super = (class MainGL*) aSuper;" could be a problem if "void *aSuper" refuses to be a MainGL object. I don't understand why you are using a void pointer for your data in C++, as the language has usefull features to avoid such things.