PDA

View Full Version : texture mapping



sidesprang
03-18-2010, 04: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

ZbuffeR
03-18-2010, 04:20 PM
http://www.google.com/search?q=opengl+texture+tutorial

maedhros777
03-18-2010, 05: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).

sidesprang
03-18-2010, 06: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()

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


glGenTextures(3, &texture[2]);


isn't


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.

sidesprang
03-18-2010, 06: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 :)

maedhros777
03-18-2010, 07: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.

sidesprang
03-18-2010, 09: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?

http://pastebin.com/bKckWEsF

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