PDA

View Full Version : A problem on multithread OpenGL program on Windows98



hhzhang
08-30-2000, 02:45 AM
I am now developing an OpenGL application on Windows98 system with Visual C++.
First I built a class derived from CThreadWnd with distinct render context (GLHRC) in it. I test this class in a single view program and find it does work quite well.
But when I use it in a multi-view(actually a splitter window),every view's device context is relative to one thread class.
But when the program is running, it always
collapse, often make my system dead.

I take great effort to overwhelm this problem, but fail again and again. http://www.opengl.org/discussion_boards/ubb/frown.gif(
So I came here looking for help.

Thanks.

skw|d
08-30-2000, 04:09 AM
I would stay away from threads unless you really need to use them. It takes some time to switch tasks, plus it makes your code more complex and harder to debug.

If you must, it sounds like your device context is in a shared memory segment that all threads are trying to use. Try to create a new context for each thread. Not quite sure of any windows device context issues, because I mainly code in un|x.

/skw|d

hhzhang
08-30-2000, 04:22 AM
Originally posted by skw|d:
I would stay away from threads unless you really need to use them. It takes some time to switch tasks, plus it makes your code more complex and harder to debug.

If you must, it sounds like your device context is in a shared memory segment that all threads are trying to use. Try to create a new context for each thread. Not quite sure of any windows device context issues, because I mainly code in un|x.

/skw|d

Thanks.
But I am now working on Win98, no other choice, it's my work http://www.opengl.org/discussion_boards/ubb/frown.gif(
In my program, device context seems not shared. They should be distinctive for each view window.
And, I have try to avoid use the origin device context. So I create a new device context( memory DC) and create a bitmap and select the map to the dc.
But error emerges when program run to the the function SetPixelFormat, why does this happen?
I am really confused. sigh

skw|d
08-30-2000, 09:11 AM
I'm not sure, try to see if you can print out the address of the device contexts. See if they have the same address or invalid addresses.

/skw|d