Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[SDL] Transparent entityes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Alex_kir   Members   -  Reputation: 299

Like
0Likes
Like

Posted 05 January 2012 - 02:57 PM

Hello all.
First of all happy new year to everyone. I hope someone can help me with this:
Basickly I have a draw function, a transparent function and a function for loading entityes. My problem is that whenever I try to apply my transparent function on an entity it just keeps its color, nothing changes. Here are the functions :
//Draw Function
bool GameSurface::OnDraw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y) {
	if(Surf_Dest == NULL || Surf_Src == NULL) {
		return false;
	}

	SDL_Rect DestR;

	DestR.x = X;
	DestR.y = Y;

	SDL_BlitSurface(Surf_Src, NULL, Surf_Dest, &DestR);
}

//Load Function

SDL_Surface* GameSurface::OnLoad(std::string filename) {
	SDL_Surface* Surf_Temp = NULL;
	SDL_Surface* Surf_Return = NULL;

	if((Surf_Temp = IMG_Load(filename.c_str())) == NULL) {
		return NULL;
	}

	Surf_Return = SDL_DisplayFormatAlpha(Surf_Temp);
	SDL_FreeSurface(Surf_Temp);

	return Surf_Return;
}

//Transparent function
bool GameSurface::Transparent(SDL_Surface* Surf_Dest, int R, int G, int B)
{
if(Surf_Dest == NULL) return true;
SDL_SetColorKey(Surf_Dest, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(Surf_Dest->format, R, G, B));
return true;
}

//Entity load function
bool Entity::OnLoad(std::string filename, int Widght, int Height, int MaxFrames){
if((Surf_Entity = GameSurface::OnLoad(filename.c_str())) == NULL) return false;

GameSurface::Transparent(Surf_Entity, 255, 0, 255);

this->Widght = Widght;
this->Height = Height;
Anim_Control.MaxFrames = MaxFrames;

return true;
}
Thanks in advance ! PS: I know there isnt much commenting going on but if needed I will provide some

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS