PDA

View Full Version : How would I go about texturing this?



Steve Chow
10-26-2008, 06:22 AM
Basically, I'm drawing something like this:
http://img147.imageshack.us/img147/8550/shapeslb5.png
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:
http://img126.imageshack.us/img126/7112/shapesxw0.png
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

MarkS
10-26-2008, 08:03 AM
You are going to have to decompose each section into triangles and texture the triangles. Or you can use the Stencil buffer.

Steve Chow
10-26-2008, 08:20 AM
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?

dletozeun
10-26-2008, 10:05 AM
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.