Archived

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

Kiroke

Another Newby question...

Recommended Posts

Kiroke    122
Hi all again. i got some problems with my first attempting to code in openGL. I''ve printed the tutorial 7 code and tried to type it(wanted to look at every line to be sure i understand), so they might be some errors somwhere. The part ive really changed is the GrawGLScene fonction int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(0.0f, 1.0f, 0.0f); //oeil haut gauche glLoadIdentity(); glTranslatef(-2.0f, 4.0f, -45.0f); glBegin(GL_QUADS); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f); glEnd(); //bouche bas glLoadIdentity(); glTranslatef(0.0f, -7.0f, -45.0f); glBegin(GL_POLYGON); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f(-1.0f, 2.0f, 0.0f); glVertex3f(1.0f, 2.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glEnd(); //plaquette glColor3f(0.0f, 0.0f, 1.0f); glLoadIdentity(); glTranslatef(0.0f, 0.0f, -45.5f); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-5.0f, -10.0f,0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-5.0f, 10.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(5.0f, 10.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(5.0f, -10.0f, 0.0f); glEnd(); return TRUE; } The problem is : The texture wont load on the quad called "plaquette". I got no error message(i guess the texture loaded all well and that LoadGLTexture and LoadBMP did their job). I''ve putted the Texture in the right place and it should be loaded. Now, im almost sure i did a newby error in that code so im asking u experimented guys to help me a little:-) Kiroke PS: by the way i appreciated alot the help u gave me.. i think i couldnt make it without this forum...thx alot

Share this post


Link to post
Share on other sites
Null and Void    1088
You have to enable texturing to use textures. Put a single glEnable(GL_TEXTURE_2D) before drawing textured stuff and a glDisable(GL_TEXTURE_2D) when you're done. Also: "Newby" is normally spelled "Newbie" .

[Resist Windows XP's Invasive Production Activation Technology!]

Edited by - Null and Void on December 15, 2001 7:47:01 PM

Share this post


Link to post
Share on other sites
Kiroke    122
mmm it doesnt seem to works... in the NeHe tutorial 7 glEnable is in the InitGL()

ive tried to put in the enable and the disable : no error message but still no texturing.

Thx anyway

Kiroke the NewbEE :-)

Share this post


Link to post
Share on other sites
Null and Void    1088
quote:
Original post by Anonymous Poster
actually, newbie

Yeah, it figures I''d make a typo in a spelling correction . I fixed my post.
quote:
Original post by Kiroke
Just thought about somthing...Could it be related to the fact that my Texture is not a square??

How is your texture not a square (I assume it is a 2D texture)? If it''s a rectangle, that''s fine. However, the dimensions (width and height) must be powers of two for some video cards.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Lord FlatHead    122
Unless you''re mipmapping your textures, the sides have to be 2^n long. Like 64*64, 128*128, etc.

I believe you have to set "filter" to 1 or 2 to use mipmapped textures in that tutorial. And you should be able to switch filters while the program is running - by pressing F.

_________
"Maybe this world is another planet''''s hell." -- Aldous Huxley

Share this post


Link to post
Share on other sites
Kiroke    122
Thx guys!

it works nice with mipmapping... my bmp was a rectangular one so now ill use that. thinking about it...u must always have a square texture when ur not using mipmap textures?? if so, is the only way to apply a texture on a rectangular object is to use a 64*64 bmp and to use glTexCoord2f(0.0f, 0.5f); , for example?

i really like that feeling u get when ur problem is resolved:-)

Kiroke

Share this post


Link to post
Share on other sites
Null and Void    1088
Mipmapping is inefficient (with video memory) unless your texture will be suspended in the Z dimension (that''s a general rule, it doesn''t always apply however). You can use gluScaleImage to do what mipmapping does without the inefficiency in those cases.

About dimensions of images: As long as both sides are powers of 2 it doesn''t matter what size the sides are or if they''re the same. The minimum size length is normally 16 pixels (although it can vary), and the maximum varies a lot with what video card you''re using. Some Voodoo cards have a 256x256 maximum texture size, but most (not all) modern cards go to at least 2048x2048.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
t0y    122
The problem is probably in the texture loading code. The dimensions of the bitmap must indeed be a power of 2. If you have an old voodoo card this restriction won''t be noticed because since it only supports 256x256 textures they always get resized.

if you use mipmapping and the gluBuildBitmaps() function (hope it''s spelled correctly), the scaling is made automatically so you don''t have to worry about it.

There are no restritions when using rectangular quads and square textures and vice-verse. The texture always get scaled to whatever coordinates you pass to gl.

You can try nate robins''s tutorials to answer your questions about texture coordinates in

http://www.xmission.com/~nate/tutors.html

hope it helps!

Share this post


Link to post
Share on other sites