setting invisible background
ok i have a object with an all black background how do i make it invisible (the background that is) what color do i need to cahnge the background to or how do i set the alpha color
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
*groan...
What API?
Unless it is a native one, good luck. Can't do it with SDL. Sorry.
What API?
Unless it is a native one, good luck. Can't do it with SDL. Sorry.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Quote:
Original post by PnP Bios
*groan...
What API?
Unless it is a native one, good luck. Can't do it with SDL. Sorry.
SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format, r, g,b) );
Or is this not what he's talking about?
for a background, like a transparent form, i guess.
better option is to steal a snapshot of the desktop.
better option is to steal a snapshot of the desktop.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
i think oneheap is right, assuming "object" refers to an image of some sort.
- stormrunner
Now that I read it again, yeah.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
yeah that dose it thanks alot my project is really comming together ill post it when im done
also heres a quick off topic question for you are these vector values going out of scope?
void Ship::Shoot(vector<SDL_Rect> Rects,vector<SDL_Surface*> Images,SDL_Surface* Weapon)
{
SDL_Surface* Image = Weapon;
SDL_Rect R_Laser = this->R_Ship;
Images.push_back(Image);
Rects.push_back(R_Laser);
};
also heres a quick off topic question for you are these vector values going out of scope?
void Ship::Shoot(vector<SDL_Rect> Rects,vector<SDL_Surface*> Images,SDL_Surface* Weapon)
{
SDL_Surface* Image = Weapon;
SDL_Rect R_Laser = this->R_Ship;
Images.push_back(Image);
Rects.push_back(R_Laser);
};
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Quote:
Original post by raptorstrike
yeah that dose it thanks alot my project is really comming together ill post it when im done
also heres a quick off topic question for you are these vector values going out of scope?
void Ship::Shoot(vector<SDL_Rect> Rects,vector<SDL_Surface*> Images,SDL_Surface* Weapon)
{
SDL_Surface* Image = Weapon;
SDL_Rect R_Laser = this->R_Ship;
Images.push_back(Image);
Rects.push_back(R_Laser);
};
Why your vector values are going out of scope...
When you pass a vector by value, you make a copy of the vector you are passing, so Rects and Images look, at the beginning of the function, just like whatever vectors you sent to the function.
For one thing, if these vectors are large, this is incredibly wasteful, and two, anything you do in the copies will be lost the moment you return from the function.
Another thing I noticed is that you have two vectors, one for rectangles, and the other for images. I would suggest making a class that contains a pointer to a surface as well as a rectangle as members, and having a single vector to contain them.
Yet another thing is that you are using a vector, and I have to presume that you do not need random access to the contents of it(i.e. you only access them by looping through them, not by actually using the [] operator). If I am right about the lack of need for random access, then you should make them lists instead, because you will get faster insertions and deletions (without the reallocation overhead that vector gives you), and since you probably don't need random access, the benefits of vector do you no good.
So, to keep your vector information from going out of scope, you need to pass the vectors by reference or by pointer. I suggest reference, but it is up to you. In either case, you don't have the expensive operation of copying the vector's contents, allocation of the vector on the stack, and subsequent deallocation of the vector from the stack. And in addition, you won't lose your data.
try this:
void Ship::Shoot(vector<SDL_Rect>& Rects,vector<SDL_Surface*>& Images,SDL_Surface* Weapon){ SDL_Surface* Image = Weapon; SDL_Rect R_Laser = this->R_Ship; Images.push_back(Image); Rects.push_back(R_Laser); };
Get off my lawn!
lol i took your advice and just kept going and didnt take the time to thanks you so thanks[grin] altho i did have to use pointers because my compiler didnt like the refrences any way thanks a ton!! every one on this thread
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement