Need to apply a texture on a given path. The path is a set of points.
Tell me how to do or where to read about how to do it on Opengl ES?
Need to apply a texture on a given path. The path is a set of points.
Tell me how to do or where to read about how to do it on Opengl ES?
I will consider you have enough points for the shape to look good enough, otherwise you should do some interpolation get more of them..
I suggest you create a 2D vertex array from the points (an array of rectangles if you wish). At each point you need 2 vertices (v1, v2):
vector position = currentPoint;
vector way = nextPoint - currentPoint;
vector normal = normalized(way.y, -way.x);
v1 = position + normal*(ropeWidth*.5);
v1 = position - normal*(ropeWidth*.5);
You will probably put this in a for
loop where you also need to set texture coordinates where X is always set to 1.0 and -1.0, Y goes for iterator i
as i/pointCount
(i
needs to be floating though)
At this point you may just bind the texture and draw a triangle strip.