All pastes #610016 Raw Edit

Someone

public text v1 · immutable
·published 2007-07-09 06:24 UTC
rendered paste body
/* Keep in mind these are only the relevant parts of the source */

SDL_Surface *screen, *image, *temp;
SDL_Rect src, dest;
SDL_Rect msg, loc;


void draw_image(int x, int y, char *file);


/* Draw Image */
void draw_image(int x, int y, char *file)
{
	temp = IMG_Load(file);
	if (temp == NULL) {
		printf("OSGC Error: Unable to load image: %s\n", SDL_GetError());
		SDL_Quit();
	}

	if (image != NULL)
		SDL_FreeSurface(image);

	image = SDL_DisplayFormat(temp);
	
	SDL_FreeSurface(temp);

	src.x = 0;
	src.y = 0;
	src.w = image->w;
	src.h = image->h;

	dest.x = x;
	dest.y = y;
	dest.w = image->w;
	dest.h = image->h;
	
	SDL_BlitSurface(image, &src, screen, &dest);
}


int main(int argc, char *argv[])
{
	draw_image(0, 0, "background.png");
}