How would I go about texturing this?

Basically, I’m drawing something like this:

Using something like this:


glBegin(GL_LINES)
for a in scanline
    glVertex2d(scanline[a].l, scanline[a].y)
    glVertex2d(scanline[a].r, scanline[a].y)
glEnd()

and I want to texture it something like this:

Everything I’ve read on texturing deals with simple quads, etc. I’m not sure how I should approach this, could anyone point me in the right direction?

Thanks

You are going to have to decompose each section into triangles and texture the triangles. Or you can use the Stencil buffer.

Please, bear with me. I’m not sure how to do most of these things but I can research if I know what I’m supposed to be researching.

You are going to have to decompose each section into triangles and texture the triangles.

What do you call this? Tessellation?

Or you can use the Stencil buffer

Am I looking for some particular manner / technique that uses the stencil buffer, or just the stencil buffer itself?

When you use GL_LINES, you draw just the black lines. Then, to fill each shape, you can use this GL_POLYGON in the glBegin call and you can define a polygon composed of 1 through N vertices. Take care that each shape is convex or divide it until you obtain several convex polygon.

To texture, each polygon, you have to compute texture coordinates at each vertex and give it to glTexCoord function.