Jump to content
  • Advertisement
Sign in to follow this  
Mad_Koder

Texture Question

This topic is 4321 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

I dont understand something about textures, maby you guys can help. Say I wanted to have the same size squares on the screen with each of its own texture (I three textures in all -tex1,tex2,tex3- , how when I call i make it so i can have multiple quads and have em have different textures and have knows which texture object to use for that one , do i call the drawrect1 ...2 ...3 in the init() function so it can call what texture to use localy and then draw the square to which the texture is attached to. Like so..... void Initialize() { .... glEnable(GL_TEXTURE_2D); bitmapdata1 = LoadBitmapFile("tex1.bmp"), &bitmapinfoheader; glGenTexture(1, &tex1) glBitmap(GL_TEXTURE_2D, texture); ...... drawtex1(); .... } and do the same for tex2 and tex 3 in the func? thanks a bunch. ~Mad_Koder

Share this post


Link to post
Share on other sites
Advertisement
You need to bind the texture first for each quad using
glBindTexture

Then you need to map the UVs for the texture using
glTexCoord2f

draw quad1

bind a new texture
map uvs

draw quad 2

check this out.

Share this post


Link to post
Share on other sites
but when u have to functions that draw to different cubes like in the nehe example, how does it know which texture goes on that one? ( how does it know that you want bunnies.bmp to go on the first cube and osama.bmp to go on the second cube?)

Share this post


Link to post
Share on other sites
GLuint TexIDBunny;
GLuint TexIDOsama;

glGenTexture(1, &TexIDBunny);
glBindTexture(GL_TEXTURE_2D,TexIDBunny);
.... Load bunny texture .....

glGenTexture(1, &TexIDOsama);
glBindTexture(GL_TEXTURE_2D,TexIDOsama);
.... Load Osama texture .....

.....
... code ...


glBindTexture(GL_TEXTURE_2D,TexIDBunny);
... Draw quads with Bunny ...
...
...
glBindTexture(GL_TEXTURE_2D,TexIDOsama);
... Draw quads with Osama ...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!