Jump to content
  • Advertisement


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


tiling a texture with glTexGen

This topic is 5818 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'm working on texture mapping the walls of a simple maze game. The maze walls are basically boxes, but each is of a different length and width (heights are the same). I don't have an array of corresponding texture coordinates for each vertex. Is there any way I can use the glTexGen() function to tile the textures simply and easily, or is there some algorithm for calculating the tex coordinates? For now I'm using glTexGen func, but it makes every wall different. Also, I'm not sure what array to pass to glTexCoordPointer. Currently I'm just using texCoords = { 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0}. Is this wrong?? Here's the relevant code. // in my CreateTextures() function glBindTexture(GL_TEXTURE_2D, textureNames[texID]); gluBuild2DMipmaps(GL_TEXTURE_2D, internalFormat, texti->width, texti->height, GL_RGB, GL_UNSIGNED_BYTE, texti->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); // in my Draw() function glBindTexture(GL_TEXTURE_2D, texture->getTextureID()); glTexCoordPointer(2, GL_FLOAT, 0, texCoords); glVertexPointer(3, GL_FLOAT, 0, vertices); for (int i = 0; i < nFaces; i++) { glDrawElements(GL_POLYGON, nVPerFace, GL_UNSIGNED_INT, indices[i]); } Thank you!! [edited by - jesskah on November 18, 2002 1:46:23 AM]

Share this post

Link to post
Share on other sites

  • 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!