-
Sprites, Etc.
To add 2D sprites to a program, you could make a rectangle with the texture of the character, right? Well, how do you get rid of that background in the image of the character, leaving only the character?
Do you need some sort of mask?
Could someone explain how to do this? Plus, I'm still a little crappy on how to do bitmap textures...I read some of NeHe's tutorials, and some other ones, but I'm still kinda lost.
:(
I still don't really understand how exactly OpenGL and Win32 work. Does everyone actually remember all that crap you need to set up the window, or do they just usually copy and paste it?
From what I understand,(please correct me if I'm wrong) but OpenGL is a library you can use to 'tap' into your comp's GDI with a Rendering Context, via some sorta of Device Context?
Anywho, do you know where I could possibly find some OpenGL tutorials that even a total idiot would understand? I've done C++ for a little while, and I know how to make DOS apps and such, and I'm comfortable with the rules and regs of the language for the most part, but this whole OpenGL thing confuses me a little.(mainly the setting up of the window, I guess)
-
Copy and paste the window creation code.
You can use google just as well as anyone else...and if you can't, you should learn that before you try anything else.
You have to create a window for OpenGL to use. Try learning the WinAPI, at least in part, first. Before that, though, try learning C++ better. Program something relatively complex with classes, pointers, and dynamic memory allocation in console mode before trying OpenGL.
-
If you don't want to deal with Windows creation code, you could use GLUT. You can find GLUT here.
That way you can focus on learning OpenGL without having to mess around with the Win32 API. It is pretty straight forward to learn. The famous OpenGL Redbook uses GLUT to provide platform independant code listings.
I have recently been testing algorithms for displaying Isometric tiles in OpenGL using GLUT as the windowing interface which makes setting up a program very quick and easy.
Tutorials can be found here:
Gamedev.net
OpenGL.org
Learn how to load 32 Bit TGA files as this can simplify the process of creating transparent portions of a sprite. TGA images can contain a fourth color channel (only in 32 bit mode I believe), which is the alpha channel.
In the fourth channel you usually color the portion of the image you want to be transparent as black and the portion you wish to show through as being white. (So yes, you are using a mask of sorts).
Using the following code in your initialisation function, you tell OpenGL to treat the color white as the portion of the mask that will be visible.
Code:
glEnable(GL_BLEND);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I believe this will only work with lighting disabled however...
-
You sir, are the fourth coolest person ever.