Click here to Skip to main content
16,006,477 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 10:43
Cyrilix18-Jun-07 10:43 
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 10:48
Force Code18-Jun-07 10:48 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 11:18
Cyrilix18-Jun-07 11:18 
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 12:10
Force Code18-Jun-07 12:10 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 12:29
Cyrilix18-Jun-07 12:29 
GeneralRe: Handling input and graphics in a game engine Pin
Matthew Faithfull18-Jun-07 10:55
Matthew Faithfull18-Jun-07 10:55 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 11:09
Cyrilix18-Jun-07 11:09 
GeneralRe: Handling input and graphics in a game engine Pin
Matthew Faithfull18-Jun-07 13:03
Matthew Faithfull18-Jun-07 13:03 
Your method should work fine for single threaded. When I was experimenting with this I was using DirectX 8 and that has a setting which redraws the actual screen exactly 60 times a second. I used this mode so I did the frames based on a timer. No point in drawing 2 frames in 1/60th of a second if the display will only show 1 Smile | :) . Something like this

<br />
while( !bFinished )<br />
{<br />
DWORD dwTickCount = GetTickCount();<br />
RenderFrame();<br />
if( GetTickCount() - dwTickCount < 1000/120 )//we've got loads of time<br />
{<br />
  //do some other stuff<br />
}<br />
<br />
while( GetTickCount() - dwTickCount < 1000/60 )<br />
{<br />
  //Process some user input<br />
}<br />
<br />
}<br />


For a real system you'd probably want to use a high resolution timer.

Multithreaded is much more difficult becuase you need the rendering thread to be on a higher priority so it doesn't get interrupted by every user input. Once it's on a higher priority then it tends to hog almost all the run time. As I said to make it work smoothly you'd need Dual Core or multiple processors. The best I managed was to get a very choppy approximation of 60 FPS for <1000 polygons, while playing a tune and taking simple keyboard input. Not spectaclar even 3 years ago.Laugh | :laugh: I used a class representing the game state which was shared data for all the threads. Each thread had a set of functions it called within any state, like Render or CalculateMoves or PlaySample. By tuning each state with delays or synchronisation it could roughly be made to work. Communication between the threads was by means of a subsciber queue. The states were kept on a stack which worked well for a game type situtation. If I ever get a Dual Core PC maybe I'll ressurect it and post it on CP Big Grin | :-D

Nothing is exactly what it seems but everything with seems can be unpicked.

QuestionMultiple bitmap in VMR9 Pin
houari_id18-Jun-07 7:30
houari_id18-Jun-07 7:30 
AnswerRe: Multiple bitmap in VMR9 Pin
Mark Salsbery18-Jun-07 7:45
Mark Salsbery18-Jun-07 7:45 
GeneralRe: Multiple bitmap in VMR9 Pin
houari_id18-Jun-07 8:00
houari_id18-Jun-07 8:00 
GeneralRe: Multiple bitmap in VMR9 Pin
Mark Salsbery18-Jun-07 8:47
Mark Salsbery18-Jun-07 8:47 
QuestionC++ Program with date and class Pin
berni2k18-Jun-07 6:41
berni2k18-Jun-07 6:41 
AnswerRe: C++ Program with date and class Pin
led mike18-Jun-07 7:10
led mike18-Jun-07 7:10 
GeneralRe: C++ Program with date and class Pin
berni2k18-Jun-07 8:36
berni2k18-Jun-07 8:36 
Questionstack overflow Pin
Lord_Vader18-Jun-07 6:26
Lord_Vader18-Jun-07 6:26 
AnswerRe: stack overflow Pin
led mike18-Jun-07 6:39
led mike18-Jun-07 6:39 
GeneralRe: stack overflow Pin
Lord_Vader18-Jun-07 6:44
Lord_Vader18-Jun-07 6:44 
GeneralRe: stack overflow Pin
Cyrilix18-Jun-07 6:46
Cyrilix18-Jun-07 6:46 
GeneralRe: stack overflow Pin
Lord_Vader18-Jun-07 6:52
Lord_Vader18-Jun-07 6:52 
GeneralRe: stack overflow Pin
James R. Twine18-Jun-07 7:14
James R. Twine18-Jun-07 7:14 
GeneralRe: stack overflow Pin
Lord_Vader18-Jun-07 7:58
Lord_Vader18-Jun-07 7:58 
GeneralRe: stack overflow Pin
James R. Twine18-Jun-07 11:37
James R. Twine18-Jun-07 11:37 
GeneralRe: stack overflow Pin
Lord_Vader19-Jun-07 5:38
Lord_Vader19-Jun-07 5:38 
GeneralRe: stack overflow Pin
#realJSOP19-Jun-07 3:41
professional#realJSOP19-Jun-07 3:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.