Jump to content
  • Advertisement
Sign in to follow this  
DarkImp

OpenGL Texture Wrapping in OpenGL?

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

Is texture wrapping available in OpenGL though any extensions? I'm meaning where the texture co-ordinates take the shortest route between two co-ordinates even if it means 'wrapping' over the texture borders ... like what you get by setting... d3dDevice->SetRenderState(D3DRS_WRAP0, D3DWRAPCOORD_0); ...in DirectX. I don't seem to be able to find anything on this in OpenGL. Anyone know if it's possible? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_WRAP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_WRAP);

Doesn't need any extensions, works in 1.1.

Share this post


Link to post
Share on other sites
Sorry, I didn't mean wrapped textures, but texture wrapping (should have been more clear).

So, if you have x co-ordinates 0.9 and 0.1 on two vertices it'll wrap the texture as the shortest route between these points (Going up to 1.0 then on to 0.1, rather than backwards across the majority of the texture as it would by default)

Hope that makes a little more sense. Kinda hard to explain without a diagram.

Share this post


Link to post
Share on other sites
Er, thats not how texturing works. The shortest distance between 0.1 and 0.9 is via 0.5, and I'm surprised thats even possible in D3D. I think what you want is texture coords of 0.9 and 1.1 instead.

Share this post


Link to post
Share on other sites
Whan he's talking about is not texture wrapping as commonly known, and is, as far as I know, not possible in OpenGL.

Concider a cylinder, and you want to map a texture around this cylinder. Where the left and right (or top and bottom, whatever) meet on the cylinder, you have to duplicate the vertices so one set of vertices get the texture coordinate 0, and the other set 1. The idea behind the requested type of wrapping is that there is only need for one set of texture coordinates, but the texture coordinate interpolation is performed not through 0.5, but through 1.0, which would be the nearest path if the texture space wrapped around at the edges.

It eliminates the need for shared vertices where logical texture coordinates are the same (0 and 1 refers to the same texel), but where the physical texture coordinates must be separated due to non-wrapping interpolation.

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
Er, thats not how texturing works. The shortest distance between 0.1 and 0.9 is via 0.5, and I'm surprised thats even possible in D3D. I think what you want is texture coords of 0.9 and 1.1 instead.


Yeah, that's the way to do it. Or you could code it yourself manually and add 1 to the value as needed like in this example. I don't know what it would be for, but that is how I would do it.

Share this post


Link to post
Share on other sites
Brother Bob's got it spot-on there (wish I could explain things as well as that!). Ah well, guess it's just not possible then, which is a shame as it's a really handy feature of DX.

Back to the drawing board :)

Thanks for the help guys.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!