PDA

View Full Version : 2D rectangle w/ unique fill



Papaya King
04-18-2005, 07:35 AM
Howdy Folks,

I'm somewhat new to OpenGL, so apologies if this is just downright simple. I need to draw a 2D rectangle that is filled with diagonal lines. The kicker is that the diagonal lines must alternate color: red, white, red, white, etc.

Now, I could certainly draw this using a brute force method but I was hoping there might be a more efficient way: perhaps defining a texture for the red and white lines or even a stipple mask? Can anyone tell me if either of those is a good idea? Or, any other good ideas to solve this problem efficiently?

Thanks much.

dorbie
04-18-2005, 07:40 AM
Put the stripes in a texture and draw the rectangle with that texture applied. You can orient the stripes at 45 degrees by chosing texture coordinates that are oriented that way or simply apply a rotation to the texture matrix.