Archived

This topic is now archived and is closed to further replies.

DanG

Think I need Multithreading? How

Recommended Posts

DanG    122
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

Share this post


Link to post
Share on other sites
Oluseyi    2116
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

Share this post


Link to post
Share on other sites
AdmiralBinary    100
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites