Thread: Lots Of Bitmap Texture Questions:

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

    Question Lots Of Bitmap Texture Questions:

    Bitmap textures are pretty important to learn if you want to make simple 2D games and such. Even after reading NeHe's tutorial, I still am having a little trouble with them...I don't think they dumbed it down enough for me.

    You can answer as few or as many as you want.
    Code:
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
    glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
    glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
    Few Questions:

    1.) Is glTexCoord2f() needed to be placed before each vertex in order for the texture to appear on the shape?

    2.) How exactly do the two parameters in glTexCoord2f() work? Is the first parameter for width, and the second for height or something?

    Code:
    glGenTextures(1, &texture[0]);
    3.) What exactly does that mean?

    4.) What's filtering mean? (<- Really dumb question)

    5.) Do you have to #include <stdio.h> to have bitmap textures?

    6.)GLuint texture[1]; ...
    - If this holds textures, does this mean I can only hold one texture unless I change the array?
    - Does it hafta be GLUint, or can it just be int?
    - What does the "u" stand for in "GLuint"? unsigned?

    I apprechiate any help you can give me...I know these questions are pretty stupid.
    Last edited by Krak; 07-08-2003 at 11:30 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Re: Lots Of Bitmap Texture Questions:

    >>1.) Is glTexCoord2f() needed to be placed before each vertex in order for the texture to appear on the shape?

    Yes you must specify texture coordinates for each vertex for the texture to display properly.

    >>2.) How exactly do the two parameters in glTexCoord2f() work? Is the first parameter for width, and the second for height or something?

    They are real values between 0 and 1. [0,1] inclusive. They are basically what part of the texture will be used for that vertex. Think of the cartesian coords Quad I. Usually these are called UV coords. U goes right V goes up on the graph.

    Code:
    glGenTextures(1, &texture[0]);
    >>3.) What exactly does that mean?

    It generates a texture name for one texture.

    >>4.) What's filtering mean? (<- Really dumb question)

    Its how the texture will be filtered There are a bunch of different methods, bi-linear filtering, antrioscopic. They have different performance/quality costs associated with them. Basically, how will the textures look when you are near and far.

    >>5.) Do you have to #include <stdio.h> to have bitmap textures?

    Nope.

    >>6.)GLuint texture[1]; ...
    >>- If this holds textures, does this mean I can only hold one texture unless I change the array?

    Yeah, it can only store one like that. You would need to change it to accomdate more textures.

    >>- Does it hafta be GLUint, or can it just be int?

    You should stick with OpenGL's convention.

    >>- What does the "u" stand for in "GLuint"? unsigned?

    Yes.

    >>I apprechiate any help you can give me...I know these questions are pretty stupid.

    There are no stupid questions.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Re: Re: Lots Of Bitmap Texture Questions:

    Originally posted by MrWizard
    There are no stupid questions.
    ....except for the ones you dont ask.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    >>5.) Do you have to #include <stdio.h> to have bitmap textures?
    Nope.
    One point....NEHE does use fopen etc to load the bitmap files....so if you use his loading functions you will need that header...

    But if you implement your own function, you can use whay you like (fopen(), iostreams, CreateFile()...etc)

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Originally posted by Fordy
    One point....NEHE does use fopen etc to load the bitmap files....so if you use his loading functions you will need that header...

    But if you implement your own function, you can use whay you like (fopen(), iostreams, CreateFile()...etc)
    Good point, I was thinking in the strictest since of the question. He may have meant the context of NeHe's tutorials in which case you are correct.

    >>....except for the ones you dont ask.

    Precisely

  6. #6
    Oh and a tip. If you have a big object, in you want to tile the textures on it instead of stretching the texture one time across a whole polygon, make sure you don't turn the texture clamping on, that you instead use repeating textures, and when you specify the texture coordinates for the polygon you want the texture to tile on, do something like this: glTexCoord2f(10.0f, 10.0f);. That basically means that you tile the texture 10 times to the right, and ten times down.

    Oh and another tip: if you want to have a texture "move" on the polygon, there is a matrix mode called GL_TEXTURE (I think that's the name) and you can apply matrix manipulations to the texture matrix. This would be a cool way to make a conveyor belt.

  7. #7
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    i'm not sure about the question...

    you're talking about making 2D games with bitmaps... so, i'm not sure why you'd bother with openGL in that case?

    it may be simpler to just work with bitmaps directly... just a thought anyway.
    "take the long road.... and walk it."

  8. #8
    You can some very interesting things using a 3D api to do 2D. Using 2D directly can sometimes make things harder. All he really has to do is make a set of functions to load graphics and display a bitmap on the screen. If you set the perspective to glOrtho2D it'll make things even easier.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  3. BMP Loading Questions, More OpenGL!!! :D
    By Shamino in forum Game Programming
    Replies: 13
    Last Post: 05-08-2005, 02:31 PM
  4. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM