• Advertisement

Archived

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

Screen only renders if mouse moves?

This topic is 5158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Do you call your rendering code at the event of WM_PAINT?

EDIT: Because that's probably not what you'd want to do in an action game

[edited by - Nik02 on January 11, 2004 7:18:59 PM]

Share this post


Link to post
Share on other sites
well yea i was.. but I also had this
App.UpdateScene();
in my main file which called the window class function UpdateScene() which "updated the scene" in this loop

// WinMain.cpp

App.SetInstance(hInstance);
App.SetWndClassName(TEXT("WndClass"));
App.SetWndCaption(TEXT("Game"));
App.SetWndStyle(WS_OVERLAPPEDWINDOW&~WS_THICKFRAME&~WS_MAXIMIZEBOX);

if(App.Create())
{
MSG msg;
//DWORD time;

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
//time = timeGetTime();

App.ProcessInput();
App.UpdateScene();
}
return (int)msg.wParam;
}
// WinMainClass.cpp

void CWndMain::UpdateScene()
{
game.Update();
}
// GameMain.h

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "DXMain.h"
#include "DXInput.h"
#ifndef _GAME_MAIN_H_
#define _GAME_MAIN_H_
class CGameMain : private DXMain
{
public:
CGameMain();
~CGameMain();
void InitGame(HWND);
void Update();
private:
protected:
};
#endif
// GameMain.cpp

void CGameMain::Update()
{
RenderScene();
}

and DXMain funciton rendersceene renders the scene

Share this post


Link to post
Share on other sites
I believe GetMessage doesn''t return until it recieves a message.

tj963

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Move :
App.ProcessInput();
App.UpdateScene();

outside of the loop, right after:

return (int)msg.wParam;

Share this post


Link to post
Share on other sites
There is only one loop if i moved it out there it would erm.. not be executed until the window closed? Maybe its set up wrong x.x its rather laggy

[edited by - DevLiquidKnight on January 11, 2004 7:43:56 PM]

Share this post


Link to post
Share on other sites
You will generally want to use PeekMessage in your loop. The loop would look similar to this:

while( WM_QUIT != msg.message )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
App.ProcessInput();
App.UpdateScene();
}
}

You can also look at the DirectX SDK samples'' implementation.

Share this post


Link to post
Share on other sites

  • Advertisement