Jump to content
  • Advertisement
Sign in to follow this  
Spahrep

OpenGL Opengl Quadtratic Texture Mapping

This topic is 4521 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

Thanks for the help on the last question guys, I have another easy one for you. In NeHe's lesson 18 the currently bound texture is nicely stretched over the shapes being used. Im actualy looking to have the texture repeated once per face of the quadratics (gluCylinder/sphpere/disk). Im sure there is an easy way to set the texture such that it does this, im just having a bit of trouble finding it. Previously i've been using polygones drawn myself where i can just use glTexCoord to acomplish what i need done. thanks again.

Share this post


Link to post
Share on other sites
Advertisement
I haven't tried this method before, but its the only one that will work I think:
change matrix mode to GL_TEXTURE, and apply scaling to the UVs.


// switch to texture matrix mode
glMatrixMode(GL_TEXTURE);
// save current state of texture matrix to stack
glPushMatrix();
// scale uvs to get texture repeating 2 for 1
glScalef(0.5f, 0.5f, 1.0f).

//draw
.....

// restore state of texture matrix
glPopMatrix();



HTH

Share this post


Link to post
Share on other sites
unfortunatly that didnt work. Doing that simply adjusts the texture over the quadratic, it does not cause the texture to appear on each facet of the object :(

Share this post


Link to post
Share on other sites
I dont have Nehe's lesson in front of me but you can set the texture param's to clamp in a certain direction. that way its not repeated across the whole object.
Jon

Share this post


Link to post
Share on other sites
Quote:
Original post by jon723
I dont have Nehe's lesson in front of me but you can set the texture param's to clamp in a certain direction. that way its not repeated across the whole object.
Jon


http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18

Im actualy trying to get the texture to repeate across the object.
there is a call to gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32);
This should draw a cylinder with 32 divisions around the X and Z axis. I want
the same texture to be applied to each of these 736 faces of the cylinder. By default the gluCylinder method does some math to stretch the pattern once nicely around the whole object (which is what I dont want).

How do i find the code behind the glu calls? Does anyone have a link? It looks like i might just have to make my own modified version of it.

thanks again.

Share this post


Link to post
Share on other sites
I was originally going to say you are better off creating your own cylinder that way its easier which parts you want textured. If you open up the glu.h header you should see the code for the quadratics somewhere inside.

Jon

Share this post


Link to post
Share on other sites
Quote:
Original post by jon723
I was originally going to say you are better off creating your own cylinder that way its easier which parts you want textured. If you open up the glu.h header you should see the code for the quadratics somewhere inside.

Jon


Either im looking in the wrong place or its not in the glu.h header. I dont see any code in the header, just declarations.

Share this post


Link to post
Share on other sites
Quote:
Original post by Spahrep
...
How do i find the code behind the glu calls? Does anyone have a link? It looks like i might just have to make my own modified version of it.
...
Go here and download the Mesa source. The source for SGI's sample GLU implementation is included.

EDIT: All-in-all it's pretty simple to create your own drawing routines for simple geometric shapes such as spheres and cylinders. It just takes a bit of paper and some knowledge (recollection) of trigonometry. However the GLU functions work fine so you can use a modified version of those if you don't feel like writing your own from scratch.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalidor
Quote:
Original post by Spahrep
...
How do i find the code behind the glu calls? Does anyone have a link? It looks like i might just have to make my own modified version of it.
...
Go here and download the Mesa source. The source for SGI's sample GLU implementation is included.

EDIT: All-in-all it's pretty simple to create your own drawing routines for simple geometric shapes such as spheres and cylinders. It just takes a bit of paper and some knowledge (recollection) of trigonometry. However the GLU functions work fine so you can use a modified version of those if you don't feel like writing your own from scratch.


TY for the link. Trigonometry and i were friends one time, years ago. Since then things have changed :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

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