Jump to content
  • Advertisement
Sign in to follow this  
rpg gamer 17

Humm... SDL_CreateRGBSurface problem

This topic is 3337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is how I create and show the surface:
	x[0] = 0;
	y[0] = 0;
	w[0] = 240;
	h[0] = 120;
	Image[0] = SDL_CreateRGBSurface(SDL_HWSURFACE, w[0], h[0], 32, 255, 255, 0, a[0]);
	if(Image[0] == NULL)
		return false;
	Image[1] = SDL_LoadBMP("Foo.bmp");
	x[1] = SDL_GetVideoSurface()->w/2-Image[1]->w/2;
	y[1] = SDL_GetVideoSurface()->h/2-Image[1]->h/2;
	w[1] = Image[1]->w;
	h[1] = Image[1]->h;
	a[1] = 100;
	SDL_SetAlpha(Image[1], SDL_HWSURFACE|SDL_SRCALPHA, a[1]);
	if(Image[1] == NULL)
		return false;
//setting on video surface
	SDL_Rect offset;
	for(int i = 0; i < 10; i++)
		if(Image != NULL)
			offset.x = x;
			offset.y = y;
			SDL_BlitSurface(Image, NULL, SDL_GetVideoSurface(), &offset);
	return true;
//flipping the screen
	SDL_FillRect(SDL_GetVideoSurface(), &SDL_GetVideoSurface()->clip_rect, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 0, 0));

Foo shows up but not the box. Am I doing something wrong? Thanks

Share this post

Link to post
Share on other sites
Have you checked some docs? It looks like you think the Rmask, Gmask, Bmask, and Amask parameters specify the initial colour for the surface, when they don't - they specify the masks for each colour component. You could do this, as mentioned:

Using zeros for the RGB masks sets a default value, based on the depth.

however note the caveat about the alpha mask.

After you've got that fixed up, you could use SDL_FillRect to fill the surface with the orange colour you want.

(Hah.. it seems like I'm playing hide-and-seek with this thread! ;) )

Share this post

Link to post
Share on other sites
I've looked at several tutorials and never realized that it wasn't supposed to be numbers. >.<

I'm not graphically advance so everything in my game is going to be made of colored squares. It's going to be awesome...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!