Mahadevan Sreenivasan
Mahadevan Sreenivasan

Reputation: 1132

OpenGL ES - Repeating same texture over different vertices

Suppose I have a polygon ( a lengthy rectangle ) made up of several triangles using GL_TRIANGLE_STRIP.

enter image description here

Now imagine I have a square texture that should be mapped against each of the small square that make up the rectangle. How do I accomplish this?

Upvotes: 2

Views: 786

Answers (1)

rotoglup
rotoglup

Reputation: 5238

You need to repeat your texture along the geometry. For this, you need to setup your texture's GL_TEXTURE_WRAP_S to GL_REPEAT.

Then you can assign texture coordinates for your vertices :

  • (0,0), (0,1) for the 2 vertices on the first column
  • (1,0), (1,1) for the 2 vertices on the 2nd column
  • (2,0), (2,1) for 3rd column
  • and so on

Upvotes: 4

Related Questions