My framework is OK, but keeps the PC quite busy

Started by
4 comments, last by NaliXL 22 years, 5 months ago
Hi there, So, I''ve written the beginning of an OpenGL framework myself, in Borland Delphi personal edition 6. Did this because Marc Aart''s delphi-conversion of NeHe''s tutor used MFC code, and I wanted to use standard borland-code. Works quite OK, in this way that it initializes OpenGL, and displays things correctley. There''s just one problem from which I can''t find what I''m doing wrong. In Marc Aarts and NeHe''s version, he uses a loop in the WinMain function that keeps the screen updating every time. I do about the same, but I have made this loop in the formcreate procedure. This works quite well, except for the fact that my program seems to be so busy with this loop, that it can''t find any free time for other things. So I can''t resize my form (gives a busy-cursor), it won''t respond to keydown and keyup events etc. etc. I''m not 100% but quite sure that it''s this loop that''s causing it. Can anyone tell me what I''ve missed in NeHe''s tutors? Or if I didn''t miss anything, at least how I can fix this problem? Thanks a lot!
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
Advertisement
The loop that draws graphics MUST process and dispatch messages in order for your window to respond to anything.
Oh, thanks for your reply, but I guess I was a bit too quick in posting. I already fixed it. Using an timer now to update the screen 30x per second..
Newbie programmers think programming is hard.Amature programmers think programming is easy.Professional programmers know programming is hard.
Provide an event handler for the Application.OnIdle event. In the handler, set the Done parameter to False and you have yourself the same loop that those WinMain procedures have. OnIdle is triggered from within the message loop. If you set the Done parameter to False then it is constantly triggered while there are no messages queued.

Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Or you could try using threads. For me that would be the easiest thing to do (other people may disagree). Do you know how to use threads? Look it up in the Help file. It''s pretty easy.
DONT USE TIMERS!!!!!!

*g* Quake3 doesn''t use timers, Unreal Tournament doesn''t use timers and Max Payne doesn''t use timers and GAMES DONT USE TIMERS!!!

Ok that''s a sweeping statement - I don''t know for -sure- that they dont use timers... But I can safely assume!!! Timers fire messages at your application, when your app gets a timer message it processes the game loop, but the problem is that if your app isn''t running fast enough, it can get bogged down with timer messages and it generally sux...

I dont know what the equivalent would be in Delphi, but in VB I would put an infinite loop in the form load procedure which simply processed messages imbetween game cycles

This topic is closed to new replies.

Advertisement