J
jannikolas.jansen
Hello,
I am trying to develop a simple game engine in C++ for Windows using
the DirectX SDK 2010 (June). However, when running an application
using my game engine that does nothing but display a text (the actual
framerate), I get maximum framerates of around 70. If I use other game
engines, such as Allegro, or IndieLib I usually get framerates around
300 on my system. Obviously, my approach here is completely
unefficient and I am looking for a way to speed things up.
My current approach is as naive as possible: I initialize stuff,
create a window, and start a timer that calls my main loop. In this
main loop I calculate what's necessary and then render everything to
screen.
To give you an impression of what it looks like in C++ source code:
SetTimer( hWnd, IDT_MAINLOOP, 0, MainLoop ); // this is how I set my
timer up
// this is pretty much what my timerproc function looks like
void WINAPI CALLBACK MainLoop( HWND hWnd, UINT uiMessage, UINT
uiTimerId, DWORD dwTime ) {
static DWORD dwActualFramerate = 0;
static DWORD dwTimeOfLastCall = 0;
if( uiTimerId == IDT_MAINLOOP ) { // if the main loop timer called
// calculate actual framerate
if( dwTimeOfLastCall > 0 )
dwActualFramerate = 1000 / (dwTime - dwTimeOfLastCall);
dwTimeOfLastCall = dwTime;
// do what i actually want to do
think(); // calculate everything
render(); // render everything
}
}
I would really appreciate if someone experienced in this matter could
push me in the right direction of how to improve this design.
Thanks in advance,
Jan Nikolas Jansen
I am trying to develop a simple game engine in C++ for Windows using
the DirectX SDK 2010 (June). However, when running an application
using my game engine that does nothing but display a text (the actual
framerate), I get maximum framerates of around 70. If I use other game
engines, such as Allegro, or IndieLib I usually get framerates around
300 on my system. Obviously, my approach here is completely
unefficient and I am looking for a way to speed things up.
My current approach is as naive as possible: I initialize stuff,
create a window, and start a timer that calls my main loop. In this
main loop I calculate what's necessary and then render everything to
screen.
To give you an impression of what it looks like in C++ source code:
SetTimer( hWnd, IDT_MAINLOOP, 0, MainLoop ); // this is how I set my
timer up
// this is pretty much what my timerproc function looks like
void WINAPI CALLBACK MainLoop( HWND hWnd, UINT uiMessage, UINT
uiTimerId, DWORD dwTime ) {
static DWORD dwActualFramerate = 0;
static DWORD dwTimeOfLastCall = 0;
if( uiTimerId == IDT_MAINLOOP ) { // if the main loop timer called
// calculate actual framerate
if( dwTimeOfLastCall > 0 )
dwActualFramerate = 1000 / (dwTime - dwTimeOfLastCall);
dwTimeOfLastCall = dwTime;
// do what i actually want to do
think(); // calculate everything
render(); // render everything
}
}
I would really appreciate if someone experienced in this matter could
push me in the right direction of how to improve this design.
Thanks in advance,
Jan Nikolas Jansen