Original Post
Hi guy, i would ask u a thing really simple but for me really important that is where put the gameLoop (what draw the scene) function in the main .cpp file?
tnx for answer.
WPARAM StartMessageLoop()
{
MSG msg;
while(1)
{
if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//first determine how many seconds elapsed
g_Engine.timerdiff = timeGetTime() - g_Engine.timer;
//the function reads in milliseconds so convert to seconds by dividing by 1000
g_Engine.secsperframe=(float)(g_Engine.timerdiff/1000.0f);
//now compute the movement value
g_Engine.movementvalue = (float)(g_Engine.desireddistance*g_Engine.secsperframe);
//get the new time
g_Engine.timer = (float)timeGetTime();
g_Engine.ProcessGame();
}
}
return msg.wParam;
}
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_PAINT:
g_Engine.ProcessGame(); //disegna per il primo frame il gioco
ValidateRect(g_hWnd, NULL);
return 0;
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
case WM_ACTIVE:
ValidateRect(g_hWnd, NULL);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more