View Full Version : texture mapping

03-18-2010, 03:04 PM
Im not sure if you have a no homework help policy or not. If so i appologize.

But yea this is my homework. We got a framework and were supposed to make cubes, rotating spheres. moving camera and textures. Right now i only have the textures left, and im not sure how to do it. And was hoping you guys could give me some pointers.

Here is the code: http://pastebin.com/ASaEQppv

03-18-2010, 03:20 PM

03-18-2010, 04:10 PM
Well, it looks like you have texturing set up in the LoadGLTextures() function, and to texture something you use glTexCoord3f() or some other variation, see here (http://www.opengl.org/sdk/docs/man/xhtml/glTexCoord.xml).

03-18-2010, 05:27 PM
hmm yea, but my loadGLTextures loads several textures. i want to use building texture on the cubes. How do i specify which textures im gonna use. when using glTexCoord3f()

03-18-2010, 05:46 PM
Good question. Actually, do you know why the line

glGenTextures(3, &texture[2]);


glGenTextures(1, &texture[2]);

? Because you're making three textures per picture. But anyway, to set which texture you're using you use glBindTexture(GL_TEXTURE_2D, texture) where texture is a GLuint. So I guess you'd use glBindTexture(GL_TEXTURE_2D, texture[2]) for the building.

03-18-2010, 05:53 PM
hmm if i understand you correct. when you call glBindTexture(GL_TEXTURE_2d, texture[1]); you're saying to the compiler that any texture related thing after this is gonna be done on/with texture[1] ?

And thanks for helping :)

03-18-2010, 06:06 PM
Yeah, that's basically how it works (as far as I know). I'm actually pretty new to texture and OpenGL in general (notice the "newbie" title under my name :) ), but you can google texture in OpenGL if you'd like to know more or make sure of something.

03-18-2010, 08:16 PM
Well i got textures now, but the problem is that the textures is all the same. All get the building texture. Anyone had that problem before?


03-18-2010, 09:26 PM
never mind. found the error. copy pasted wrong function :P