Sprites, Etc.

This is a discussion on Sprites, Etc. within the Game Programming forums, part of the General Programming Boards category; To add 2D sprites to a program, you could make a rectangle with the texture of the character, right? Well, ...

  1. #1
    People Love Me
    Join Date
    Jan 2003
    Posts
    412

    Question 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)

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    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.
    Away.

  3. #3
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    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...
    Last edited by dalek; 05-18-2003 at 05:51 AM.

  4. #4
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    You sir, are the fourth coolest person ever.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making sprites
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 02-20-2010, 06:00 AM
  2. DirectX and Sprites
    By andyhunter in forum Game Programming
    Replies: 6
    Last Post: 12-24-2004, 05:40 PM
  3. I Found some nice sprites but need more...
    By BigCheese in forum C++ Programming
    Replies: 1
    Last Post: 03-23-2004, 05:03 PM
  4. drawing sprites with the windows gdi
    By lambs4 in forum Game Programming
    Replies: 10
    Last Post: 08-14-2003, 09:06 AM
  5. Animating Multiple Sprites
    By Tommaso in forum Game Programming
    Replies: 2
    Last Post: 10-11-2002, 12:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21