OpenGL Sprites

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

OpenGL Sprites

Post by Moosader »

So, as some peoples know, I'm attempting to remake ET in OpenGL and SDL. o_o
Instead of having 3D models or anything for ET and the baddies, I want to have flat 2D sprites like this:

Image

I know how to load textures, but I don't know how to set a certain area to transparent. Do I need to figure out how to check each pixel on a texture and replace, say, (1.0, 0.0, 1.0) with ... nothingness. 0.o;
I don't know. I assume there's a function in OpenGL to turn an image partially or fully transparent, and I just need to do that for the appropriate pixels.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Post by eatcomics »

Oh look, a Gay Pride Square!!! those are growing indangered...
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

. . . I have a certain fondness for that square.

The way we did it was really easy. Our PNG library: glpng handles transparencies itself. You just load it as being a transparent PNG. That's what I recommend you look into, because I'm not a big fan of hardcoding transparencies.
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Post by Moosader »

Ah, sounds good then!

And yep, I colored it like a gay pride square on purpose. :D
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Post by MarauderIIC »

You can also do masking.

And you can use an 'alpha channel'
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Post by Moosader »

GyroVorbis wrote:. . . I have a certain fondness for that square.

The way we did it was really easy. Our PNG library: glpng handles transparencies itself. You just load it as being a transparent PNG. That's what I recommend you look into, because I'm not a big fan of hardcoding transparencies.
About GLPNG -- It requires GLUT as well? So are you using OpenGL, SDL, AND GLUT for the game?
marmalade
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 10
Joined: Fri Jul 11, 2008 3:41 am
Contact:

Post by marmalade »

:guffaw: The gay pride square, I remember someone commenting in one of the earlier Adventures in Game Development videos about that.

As for the question, I have no idea. I'm too horrible at programming to even think of coding in OpenGL.

I am not worthy! :worship:
Image
User avatar
cypher1554R
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1124
Joined: Sun Jun 22, 2008 5:06 pm

Post by cypher1554R »

I'm not sure.. can you load a .png format texture (which contains alpha values) and setup the program for alpha blending to achieve that..?

PS: As far as I know you can't geometrically modify the texture..
Post Reply