Think I need Multithreading? How

Started by
4 comments, last by DanG 22 years, 5 months ago
I have a simple non game graphics program with OpenGL written as an SDI app in VC6. It requires drawing a bouncing ball as quickly as possible. To do this I got an OnTimer event and had it invalidate the screen. However this was not fast enough, (i guess OnTimer doesn''t get called often). So i changed my drawing code to an endless loop. This greatly helped drawing performance, but made it imposible to get user input, because the drawing always had control of the process. To fix this i tried to create a seperate thread in MFC. After some struggling i got it to compile everything, but there is no drawing happening, although i verified that the draw code is running. What the heck is wrong? I have the draw code in a memeber function of the view class, and the ThreadMain endlessly calls the view''s Draw code. Again its running, but the OpenGL calls don''t seem to be working. WHY? Secondly i wanted to make sure people thought i needed the seperate thread. I couldn''t get the redraw rate i wanted with onTimer, even set to most frequent interval. How do you do your draw code that needs refresh by time, not by input? Is there another way to redraw and get input without 2 threads? All answers are great! Daniel RELIGION IS THE ROOT OF ALL EVIL
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Advertisement
Have you tried other timing functions, like QueryPerformanceTimer()? Also, you need to keep all OpenGL code to one thread, since OpenGL is not reentrant.

[EDIT:] GameDev, we have a _VERY_ buggy bold tag!


I wanna work for Microsoft!

Edited by - Oluseyi on November 11, 2001 11:06:14 PM
quote:Original post by DanG
RELIGION IS THE ROOT OF ALL EVIL


Hmm... would you care to discuss this in the lounge? I''m not religious, but I believe in spirituality.


I wanna work for Microsoft!
If you are trying to get good performance, you shouldn''t be using MFC. You should use lower-level Win32 API stuff which gives u ''total'' control of the system. This will then allow u to use PeekMessage etc. to get user input while drawing the bouncy, bouncy balls.

---------------

I finally got it all together...
...and then forgot where I put it.
Try putting your drawing code in an OnIdle() callback.
You could try looking at the modified mesage pump in
this article

http://www.gamedev.net/reference/articles/article1249.asp

I know it''s a DirectX tutorial but It should give you some ideas

This topic is closed to new replies.

Advertisement