Window not rendering

Hi,

I wrote a simple program with SDL which works fine on every computer it’s been
run on, so far, with one exception, a Dell; P4 2.4GHz , 512 MB, Win XP Pro SP2.
I’ve run it without problems on much less powerful computers, so that’s not
the problem. The window stays black for a while and then only refreshes when a
window-manager action happens, like when windows is displaying “hints.” While
"hints" are being displayed, the window is refreshed frequently and it works
fine, but when the “hints” disappear it stops refreshing.

I’m pasting my entire program (150 lines) because I honestly have no idea where
the problem could be. Thanks a lot to anyone who can help…–

#include <stdio.h>
#include <stdlib.h>
#include “SDL/SDL.h”

SDL_Surface *screen, *back, *image, *sun;

double xpos=0,ypos=0;
double xvel=0, yvel=0;
double sxpos=300,sypos=152;
double sxvel=0, syvel=0;

double g=1;

int InitImages()
{
back = SDL_LoadBMP(“bg.bmp”);
image = SDL_LoadBMP(“bunny.bmp”);
sun = SDL_LoadBMP(“sunflower.bmp”);
SDL_SetColorKey(image, SDL_SRCCOLORKEY,
SDL_MapRGB(image->format, 255, 255, 255));
SDL_SetColorKey(sun, SDL_SRCCOLORKEY,
SDL_MapRGB(sun->format, 255, 255, 255));
return 0;
}

void DrawIMG(SDL_Surface *img, int x, int y)
{
SDL_Rect dest;
dest.x = x;
dest.y = y;
SDL_BlitSurface(img, NULL, screen, &dest);
}

void DrawIMG(SDL_Surface *img, int x, int y,
int w, int h, int x2, int y2)
{
SDL_Rect dest;
dest.x = x;
dest.y = y;
SDL_Rect dest2;
dest2.x = x2;
dest2.y = y2;
dest2.w = w;
dest2.h = h;
SDL_BlitSurface(img, &dest2, screen, &dest);
}
void DrawBG()
{
DrawIMG(back, 0, 0);
}

void DrawScene()
{
DrawBG();
DrawIMG(image, xpos, ypos);
DrawIMG(sun, sxpos, sypos);

SDL_Flip(screen);
}

int main(int argc, char *argv[])
{
Uint8 *keys;
int ymax = 250;
int xmax = 440;
int sxmax = 400;
int symax = 152;
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
printf(“Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
SDL_WM_SetCaption(“Bunny!”, “Bunny!”);
screen=SDL_SetVideoMode(640,480,16,SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( screen == NULL )
{
printf(“Unable to set 640x480 video: %s\n”, SDL_GetError());
exit(1);
}
InitImages();
DrawBG();

int done=0;
while(done == 0)
{
SDL_Event event;

while ( SDL_PollEvent(&event) ) 

{
if ( event.type == SDL_QUIT ) { done = 1; }

  if ( event.type == SDL_KEYDOWN )
  {
    if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
  }
}
keys = SDL_GetKeyState(NULL);
if ( keys[SDLK_UP] ) { yvel -= 3; }
if ( keys[SDLK_LEFT] ) { xvel -= 1; }
if ( keys[SDLK_RIGHT] ) { xvel += 1; }

if ( keys[SDLK_w] ) { syvel -= 2; }
if ( keys[SDLK_a] ) { sxvel -= 1; }
if ( keys[SDLK_d] ) { sxvel += 1; }

	if (xpos < 0) {
		xvel = -xvel * 0.3;
		xpos = 0;
	}
	else if (xpos > xmax) {
		xvel = -xvel * 0.3;
		xpos = xmax;
	}
	else xpos += xvel;
	if (ypos > ymax) {
		ypos = ymax;
		yvel = -yvel * 0.5;
	}
	else {
		ypos += yvel;
		yvel += g;
	}

	if (sxpos < 0) {
		sxvel = -sxvel * 0.3;
		sxpos = 0;
	}
	else if (sxpos > sxmax) {
		sxvel = -sxvel * 0.3;
		sxpos = sxmax;
	}
	else sxpos += sxvel;
	if (sypos > symax) {
		sypos = symax;
		syvel = -syvel * 0.2;
	}
	else {
		sypos += syvel;
		syvel += g;
	}



DrawScene();

}

return 0;

}