Creating Ring

BlitzMax Forums/BlitzMax OpenGL Programming/Creating Ring

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I had to think about this for a while but then it occurred to me.

You are right that it is to do with the fact that the quad is made of triangles, in that if you draw a diagonal line between opposite corners of each quad you'll see where the dividing line is of the triangle. The interpolation of the texture image is stretched across the triangle evenly. The problem is, your texture coordinates are a square but you are mapping the texture onto a non-square shape. The texture therefore HAS to stretch to fill the space and will warp in the way you are seeing.

If your quads were perfect squares you would not see the warping, because the texture coordinates then would match exactly the shape on the screen.
But because you have these trapezium shaped objects, GL has no choice but to stretch the texture over the shape in whatever way it can. It no longer directly maps to the shape so each triangle has to stretch out the texture. Then when you see both triangles next to each other they each have their own stretching.

To properly fill a trapezium shape, your texture coordinates must also be in the shape of a trapezium. While I said before that you step across your image horizontally, I'm sorry but in hindsight that won't work. You will have to store your `tiles` in the same shape as your disc, ie in a circle, within a texture, and as you step around the circle to define the vertices, you use basically the same position (converted from pixel coordinates to the 0..1 texel coordinates) to refer to where within the texture you are pulling from.

Alternatively you can use GL_QUADS, and store each segment as a trapezium shape (ie the shape it will be when you draw it), like tiles with gaps between (like a sprite-sheet). Then you can reference the exact corners of each trapezium in the texture and it will then map onto the object drawn without stretching.