PDA

View Full Version : Texture Wrapping



Andrea Doimo
04-18-2001, 02:58 AM
I've a problem when texturizing meshes shaped like a cylinder...
There is a "line" where the texture choord (u) can be 0, or 1, and despite my choose, the result is always a stretched texture...
I'm sorry, it's hard for me to explain this beaviour (english isn't my first language)...
I tought it was caused by my 3D engine (OpneGL) not being so smart, but while reading the DirectX SDK, I've seen the following text:

***
If texture wrapping isn't enabled, the rasterizer does not interpolate in the direction needed to generate a believable, reflected image. Rather, the area at the front of the pillar contains a horizontally compressed version of the texels between u- coordinates 0.175 and 0.875, as they pass through the center of the texture. The wrap effect is ruined

d3dDevice->SetRenderState(D3DRS_WRAP0, D3DWRAPCOORD_0);
***

The question is obvious:
Is there something similar in OpenGL ?

Thanks

Glossifah
04-18-2001, 04:43 AM
Andrea,

If I understand your question correctly, you need your texture to repeat across the face of an object. In that case, take a look at this documentation:
http://trant.sgi.com/opengl/docs/man_pages/hardcopy/GL/html/gl/texparameter.html

More specifically, I believe the function you are looking for is this:




glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


Does that help?

Glossifah

Andrea Doimo
04-18-2001, 05:29 AM
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


Does that help?

Glossifah[/B]<HR></BLOCKQUOTE>

Sorry, no.
Try imaging to bend a retangle at 360degrees to make a cylinder...

I want to do the same: "bend" a retangular texture around a cylinder.

The problem appears when applying the u-v coords to the points where the "texture" glues itself...

ascii graph:




------------------><-------------------
--------------|--------|---------------
0.5 0.9 0.1 0.5


These are the textel coords.
When texturing, between 0.9 and 0.1 there are the start and the end of the texture, but OpenGL calculates 0.5 between them...
Showing about the entire texture (0.8 units) in a so small space...
Instead, I want to see just the remaining part, that is 0.2 units long!


Hope someone understands all this... ;-)



[This message has been edited by Andrea Doimo (edited 04-18-2001).]

j
04-18-2001, 07:07 AM
In between the vertices with texture coords of 0.9 and 0.1, put in two vertices in the same place with values of 1.0 and 0.0.




------------------>|<-------------------
--------------|----|----|---------------
0.5 0.9 1.0 0.1 0.5
0.0


j

[This message has been edited by j (edited 04-18-2001).]