I’ve been programming with OpenGL for quite some time now – nothing too fancy, but I’ve got some experience. I’ve recently started trying to program a simple side scroller game. I figured I just needed to put in a backdrop, scatter a few textured quads around, animate a quad for a character, then simply move the camera from side to side. So I went ahead and programmed all this up only to be plagued by horrible choppy movement complete with tearing and jerkiness.
After much frustration I started over with some base code from NEHE. I popped a non-textured quad up on the screen and paned the camera back and forth – I couldn’t even do this smoothly.
The problem seems to be related to basing movement on time.
I.e.
// Process Application Loop
tickCount = GetTickCount ();
Update (tickCount -window.lastTickCount);
window.lastTickCount = tickCount;
Draw ();
void Update (DWORD milliseconds)
{
//pan right
if (g_keys->keyDown [VK_RIGHT] == TRUE)
{
g_playerPos[0]+=(float)(milliseconds)/5.0f;
g_lookAt[0] +=(float)(milliseconds)/5.0f;
}
//pan left
if (g_keys->keyDown [VK_LEFT] == TRUE)
{
g_playerPos[0]-=(float)(milliseconds)/5.0f;
g_lookAt[0] -=(float)(milliseconds)/5.0f;
}
}
I thought this would be so simple! Huh! I’ve tried it on a couple of Radeon 9000 series cards, and I’ve got lots of books on programming which all do a just as poor a job of rendering. I know I shouldn’t need more power for this! (The slower the card the worse the problem however)
I’ve looked at some of the older “Donut” code from the Directx SDKs, but it won’t compile, and the DX9 demo is way too complicated. Anyway, I’ve noticed they use “blits” a lot for speed. Does anyone know any OpenGL tricks for speed like this?
Please, if anyone is knows this problem, or even knows where I can get some side scroller code (that will compile with modern SDKs OpenGL or DX9), I would really like to hear from you! There must be something dead simple that I just don’t get.
I’d like to attach the code but I’m not sure there’s a way to do that - I’ll mail it to anyone that wants it though!
Rob.
robi250@hotmail.com