croping sprite

Started by
4 comments, last by frob 9 months, 3 weeks ago

how do I crop the black triangles

Advertisement

what sprite software should I use?

pbivens67 said:
how do I crop the black triangles

Change the color from black to transparent.

-- Tom Sloper -- sloperama.com

how do I use paint to do that or what software should I use?

The vast majority of drawing programs out there support transparency if the graphics format support it. If you're looking for something free, the Gnu Image Manipulation Program (gimp) is available on Windows, Mac, and Linux/Unix systems.

Since I recall you're using png files for your textures, you can store the data with alpha enabled so those images contain transparency information.

Exactly how you add it depends on the format you're using and the program you're using. If you're using an image with Red, Green, and Blue (RGB) you'll need to add an Alpha (A) value to it, so it becomes an RGBA format. For most programs 100% alpha means it is fully visible, 0% alpha means it is fully transparent, 50% means half of the layer shows through. Every pixel of the texture can have it's own alpha value, just like it can have it's own red, green, and blue value. In some programs you'll use an eraser tool and it will modify the alpha values, in most programs you can modify the alpha directly.

In your past posts, you've used the SOIL library and allowed the library to decide automatically if alpha is included or not, using SOIL_LOAD_AUTO instead of SOIL_LOAD_RGB or SOIL_LOAD_RGBA. That means it should automatically detect the alpha channel is present and include it in the texture data. You can use the RGB or RGBA versions to force loading with or without alpha.

You'll need to enable alpha blending in your rendering and set a blending function, which will probably look like this:

...
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_BLEND );
...

Once you do that, you might also start to modify your color settings. Calls to glColor3f(r,g,b) take three parameters, assuming full intensity or 1.0 or 100% alpha. Calls to glColor4f(r,g,b,a) take four parameters, the fourth one is an alpha, which you can set anywhere between 1.0 (fully visible) and 0.0 (fully transparent).

If you are using partial transparency, with values other than 100% and 0%, you'll also need to ensure your drawing order is back-to-front since partially-transparent things need to be drawn on top of things. Since your project is drawing everything yourself with direct forward rendering,, you'll want to be sure to everything is drawn back-to-front so partial transparency shows through. If you don't sort things, anything that is partially transparent (not 100% or 0%) will not draw correctly over the items behind it.

This topic is closed to new replies.

Advertisement