SFML community forums
Help => Graphics => Topic started by: Moonkis on April 19, 2012, 10:59:21 pm
-
Hello to the SFML forum how are you all doing?
I'm very new to the SFML library and to game programming as well though I'm slowly learning.
I just recently finished making all the linking work ( Debug and Release ) and wrote "the" basic RenderWindow layout to make sure it worked correctly.
Now I'm running into some issues drawing Images to the screen, the "magenta color" or well the color I wan't to be transparent is not.
I figured out by goggling that I could use the "createMaskFromColor(sf::Color::Magenta)" to make it invisible thus only displaying what I want. But I need to call that function for every image that I want to apply it to.
I was just curious if this was the "standard" or "right" way of doing it? And if so, what it is it called in programming terms? Is it the same as "Masking" sprites?
Slightly Off-Topic
To be able to draw sprites to the screen I need to use the "RenderWindow.draw()" method. The object is not copy-able so passing it is no choice ( if not by reference or with a pointer ).
How does people usually draw lot of game objects that are inside a vector? Do thy pass it to an "Object Managers" draw function? The same with Event do people pass it to every objects Update function as well? Since the RenderWindow is the only object that is able to poll for the keyboard events and stuff.
The structure of SFML is a bit wonky for me since I'm coming from C# and XNA. Hopefully someone will explain the "generic" flow of an SFML game that is "bigger" than pong for example.
Kind regards Moonkis
-
If you don't want to hit your head against a wall (exagerated), you can simply use .png images with transparancy.
I think there is a way to mask colors, but I can't answer that
-
If you don't want to hit your head against a wall (exagerated), you can simply use .png images with transparancy.
I think there is a way to mask colors, but I can't answer that
Wait, how does that work? I have the images I want to be the "magenta" color to be transparent in but it still shows the color when I'm trying to draw the image to the screen.
-
If you don't want to hit your head against a wall (exagerated), you can simply use .png images with transparancy.
I think there is a way to mask colors, but I can't answer that
Wait, how does that work? I have the images I want to be the "magenta" color to be transparent in but it still shows the color when I'm trying to draw the image to the screen.
The PNG image files have an alpha canal. So in photoshop, or paint or whatever, you can put transparancy on your image. Images with transparent areas are well displayed by SFML.
You can use your method too (transform a certain color in transparent). But I can't help you in that way, because I just don't know how to do.
IMO it's easiest to do your images with transparency from the beggining (in your image editor), 'cause there's nothing to do to handle it with SFML later.
-
Editing the transparency inside an editor is a solution I guess but I just want to clarify something
does "createMaskFromColor()" affect the performance in any way after it has been used on an image?
Also does it affect memory greatly?
In other words would I expect performance issues using "createMaskFromColor()" in larger projects?
Sorry for the "noob" questions but as I said I'm new to SFML and the way it works.
-
Editing the transparency inside an editor is a solution I guess but I just want to clarify something
does "createMaskFromColor()" affect the performance in any way after it has been used on an image?
Also does it affect memory greatly?
In other words would I expect performance issues using "createMaskFromColor()" in larger projects?
Sorry for the "noob" questions but as I said I'm new to SFML and the way it works.
I'm note able to answer that question, anyway the answer interest me ^^
-
does "createMaskFromColor()" affect the performance in any way after it has been used on an image?
No, it just transforms the alpha component of pixels from 255 to 0. In other words, it does what you'd do in an image editor.
Also does it affect memory greatly?
No, all pixels have an alpha component, this function just change their value.
In other words would I expect performance issues using "createMaskFromColor()" in larger projects?
Absolutely zero impact.