Thanks alot for taking interest in my question. Win32 is not easy to learn these days unless you can afford to buy a reference book. I can't find much on the internet at all.
All my code is plain C because I can't stand OOP.
This is my game loop:
START OF LOOP
Code:
curTime = timeGetTime();
frameCount++;
//frame counting stuff
if(curTime - lastTally > 1000){
lastTally = curTime;
sprintf(theTitle, "%i fps", frameCount);
SetWindowText(theWind, theTitle);
frameCount=0;
}
//doSomething does all the game math.
//It's repeated 3 times so that the sprites move several
//times before the redraw
for(a=0;a<3;a++) doSomething();
//Draw all renders the sprites on the window.
drawAll();
while(timeGetTime() - curTime < 1000.0f / 60.0f);
END OF LOOP
It's very possible that the problem is the way I handle the device contexts. The code is pretty self explainatory. The rendering code is below:
Code:
void drawAll(){
HDC hdc = GetDC(theWind);
HDC hdcBuffer = CreateCompatibleDC(hdc);
HBITMAP hbmBuffer = CreateCompatibleBitmap(hdc, 640, 480);
HBITMAP hbmOldBuffer = SelectObject(hdcBuffer, hbmBuffer);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = SelectObject(hdcMem, theMap);
if(showBG) BitBlt(hdcBuffer, 0, 0, 640, 480, hdcMem, 0, 0, SRCCOPY);
//draw all sprites in the array
int a; for(a=0;a<20;a++){
if(act[a].alive==0) continue;
SelectObject(hdcMem, theMask);
BitBlt(hdcBuffer, act[a].left, act[a].top, act[a].selW, act[a].selH, hdcMem, act[a].selX, act[a].selY, SRCAND);
SelectObject(hdcMem, theImg);
BitBlt(hdcBuffer, act[a].left, act[a].top, act[a].selW, act[a].selH, hdcMem, act[a].selX, act[a].selY, SRCPAINT);
}
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
BitBlt(hdc, 0, 0, 640, 480, hdcBuffer, 0, 0, SRCCOPY);
ReleaseDC(theWind, hdc);
SelectObject(hdcBuffer, hbmOldBuffer);
DeleteObject(hbmBuffer);
DeleteDC(hdcBuffer);
}
There isn't anything happening other than the game loop and the rendering. Keyboard input is done with the windows message pump. Code compiled with Mingw.
Any help is appreciated.