Archived

This topic is now archived and is closed to further replies.

Lots Of Bitmap Texture Questions

This topic is 5272 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
1) Yes, glTexCoord2f() is to be placed before each vertex.

2) The two parameters are coordinates for mapping the texture on the quad/triangle/whatever. Look at this quad:

(0,1) (1,1)
|------------|
| |
| |
| |
| |
|------------|
(0,0) (1,0)


This are the glTexCoord2f() parameters for texture mapping this quad.

3) It genarates a texture object. The first parameter is the number of texture objects to generate and the second one is a reference to a GLuint (unsigned int). The second parameter is later used to bind that texture.

4) Filtering is how "nice" your texture will look.

5) No, but you will need it to read a texture from a file.

6) If you want it to hold more textures:
GLuint texture[NUM_TEXTURES_YOU_WILL_EVER_NEED];
Then when creating first texture:
glGenTextures(1, &texture[0]);
second texture:
glGenTextures(1, &texture[1]);
so on.
I think it should be unsigned int. I'm not sure you can just try setting it to int.
As I have already said, GLuint = unsigned int.

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

[edited by - shlomisteinberg on July 9, 2003 2:04:40 AM]

Share this post


Link to post
Share on other sites
You can also allocate all texture ''names'' at once

GLuint texture[NUM_TEXTURES_YOU_WILL_EVER_NEED];
glGenTextures(NUM_TEXTURES_YOU_WILL_EVER_NEED, &texture[0]);

Share this post


Link to post
Share on other sites
quote:
Original post by MazyNoc
You can also allocate all texture ''names'' at once

GLuint texture[NUM_TEXTURES_YOU_WILL_EVER_NEED];
glGenTextures(NUM_TEXTURES_YOU_WILL_EVER_NEED, &texture[0]);





Shouldn''t it be then?:
glGenTextures(NUM_TEXTURES_YOU_WILL_EVER_NEED, &texture);

I''m after two+ hours of Counter-Strike with friends and only knives and very weak gravity (!) so I''m a bit sick of people flying with their blood in all directions.

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
quote:
Original post by MazyNoc
im not a C++ coder

but doesnt &texture[0] and &texture points to the same address?
else i dont think &texture[0] should work..


You''ll get an error if you try to get the address of the address of an array(&texture). It should be this:

int texture[10];

if(&texture[0] == texture)
printf("They are equal");

Share this post


Link to post
Share on other sites
aha, thanks for clarification

then both
glGenTextures(NUM_TEXTURES_YOU_WILL_EVER_NEED, texture);
glGenTextures(NUM_TEXTURES_YOU_WILL_EVER_NEED, &texture[0]);

will work, but its easier to understand what you really want to do if you write the first one

Share this post


Link to post
Share on other sites