PDA

View Full Version : Texturing help



01-02-2005, 02:20 PM
I want to texture a quad, which I have drawn in 3 dimensions. After researching I found I need to use the glBindTexture, glPixelStorei, glTexParameteri, glTexEnvf, glTexImage2D calls, and before someone says it I have enabled texturing. My problem is specifying the texture I want to draw onto the shape, I have specified the co-ordinates, but do not know how to load my bitmap file, could some please help?

01-02-2005, 02:24 PM
Currently I have


glEnable (GL_TEXTURE_2D);
}

glBindTexture(GL_TEXTURE_2D, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData); I think instead of 'imagedata' should be the file name, but I have tried that and it didn't work.

and for my shape co-ordinates is as follows


glColor3f(0.9f, 0.8f, 0.5f);
glBindTexture (GL_TEXTURE_2D, 1);
glTexCoord3f (- 100.0f, 0.0f, - 100.0f);
glVertex3f (- 100.0f, 0.0f, - 100.0f);
glTexCoord3f (- 100.0f, 0.0f, 100.0f);
glVertex3f (- 100.0f, 0.0f, 100.0f);
glTexCoord3f ( 100.0f, 0.0f, 100.0f);
glVertex3f ( 100.0f, 0.0f, 100.0f);
glTexCoord3f ( 100.0f, 0.0f, - 100.0f);
glVertex3f ( 100.0f, 0.0f, - 100.0f); any help/advice, would be greatly appreciated

01-03-2005, 06:14 PM
Come on, does no one have any answers?

malancha
01-03-2005, 06:50 PM
Take a look at NeHe (http://nehe.gamedev.net) , Lesson 7.

01-05-2005, 09:41 AM
I think that should be glTexCoord2f instead of glTexCoord3f.

But, we need more code to see what your doing. For example, what are you doing in your init() function......to mention just one .

01-05-2005, 09:19 PM
Lesson 7 concentrates more on lighting, and although texturing is there, it's only for texturing one object, and I have about 30 that I need to texture with different textures.

I don't have an Init, which is probably part of the problem. Can someone help?

01-05-2005, 09:26 PM
Lesson 7 concentrates more on lighting, and although texturing is there, it's only for texturing one object, and I have about 30 that I need to texture with different textures.

I don't have an Init, which is probably part of the problem. Can someone help?

And as for the glCoord3f, I assumed 2f wouldn't work as it would need all 3 dimensions as it's a 3d shape?

plasmonster
01-05-2005, 10:07 PM
Enicomb, have a look at this chapter in the RedBook. Included is a complete texture mapping example:
http://fly.cc.fer.hr/~unreal/theredbook/chapter09.html

I hope this helps.

01-05-2005, 10:20 PM
Thanks, but that doesn't really answer my qeustion, as it seems to assume the bitmap has already been loaded. I can't load a bitmap, change it to a texture, but I know how to load it onto a shape.

So, how can I load the bitmap?

plasmonster
01-06-2005, 12:01 AM
OpenGL doesn't deal with image loading; that's up to you. But it's only a google away:
http://www.gametutorials.com/Tutorials/Win32/Win32_Pg4.htm

Hope this helps.