Click here to Skip to main content
15,913,130 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 8:10
Force Code18-Jun-07 8:10 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 8:29
Cyrilix18-Jun-07 8:29 
GeneralRe: Handling input and graphics in a game engine [modified] Pin
Force Code18-Jun-07 8:51
Force Code18-Jun-07 8:51 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 9:01
Cyrilix18-Jun-07 9:01 
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 9:15
Force Code18-Jun-07 9:15 
GeneralRe: Handling input and graphics in a game engine Pin
Cyrilix18-Jun-07 9:26
Cyrilix18-Jun-07 9:26 
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 9:51
Force Code18-Jun-07 9:51 
GeneralRe: Handling input and graphics in a game engine [modified] Pin
Cyrilix18-Jun-07 10:01
Cyrilix18-Jun-07 10:01 
Oh no, what I meant was... the graphics thread would be in a while loop constantly filling the frame buffer and putting it to the screen. On every iteration of filling this frame buffer, it would have to draw a bunch of shapes, and a set of variables that track your movement (say, x, y, z, and rotate), would determine how to redraw the scene. It would have to check these variables on every iteration. Basically, I'd have to know the translations and rotations that affect my camera every time I redraw.

The code would be very similar to what is on Nehe's OpenGL tutorial: Link to source

Here is the code that I'm pointing to, specifically:

	while(!done)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?
			{
				done=TRUE;							// If So done=TRUE
			}
			else									// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
			}
		}
		else										// If There Are No Messages
		{
			// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
			if (active)								// Program Active?
			{
				if (keys[VK_ESCAPE])				// Was ESC Pressed?
				{
					done=TRUE;						// ESC Signalled A Quit
				}
				else								// Not Time To Quit, Update Screen
				{
					DrawGLScene();					// Draw The Scene
					SwapBuffers(hDC);				// Swap Buffers (Double Buffering)
				}
			}

			if (keys[VK_F1])						// Is F1 Being Pressed?
			{
				keys[VK_F1]=FALSE;					// If So Make Key FALSE
				KillGLWindow();						// Kill Our Current Window
				fullscreen=!fullscreen;				// Toggle Fullscreen / Windowed Mode
				// Recreate Our OpenGL Window
				if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
				{
					return 0;						// Quit If Window Was Not Created
				}
			}
		}
	}


MODIFIED:

I guess my question is -- you would consider this bad design?

-- modified at 16:07 Monday 18th June, 2007
GeneralRe: Handling input and graphics in a game engine Pin
Force Code18-Jun-07 10:33
Force Code18-Jun-07 10:33 
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 
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 

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.