View Full Version : Question on pattern-fill drawing for polygons.

04-28-2005, 04:29 AM
I'm wanting to rewrite an old game called PowerMonger in OpenGL. Just for nostalgia, really,

Anyway, I don't want to use regular texture mapping. I want to fill each polygon with a particular pattern, just like in the original game.

I've looked into the documentation and found glPolygonStipple, but this isn't really suitable as it only supports 1-bit masking patterns.

Is the only alternative to use shaders? Or is there some way I can keep it compatible with regular OpenGL functionality?

Perhaps use environment mapping with a projection from the camera viewpoint?

04-28-2005, 01:27 PM
You should do a texgen in eye space linear to produce texture effects like this.

You'll probably also need to load a glFrustum on the texture matrix to project from the eye if it's truly a screenspace texture operation.

04-29-2005, 03:32 AM
dorbie: Thanks, using GL_EYE_LINEAR in glTexGeni() certainly seems to do the trick!

I found an example called texgen in the OpenGL Guidebook which does this to the glutSolidTeaPot object.

Cheers. :)

04-29-2005, 06:36 AM
Oh, I've just realised that the effect only works when using an Orthogonal camera. :(

Is this what you were meaning by the glFrustum call?

// in the main draw function
glOrtho(-10, 10, -10, 10, 0, 100);

gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 1000.0f);


// and then draw the actual geometry.The texture is correctly projected in screenspace (e.g., remains static as the landscape rotates) but is still distorted by perspective depth. :confused:


05-05-2005, 11:33 AM
This is why I suggested putting a projective glFrustum call (gluProjection) on the texture matrix.

You need to texgen r along eye z and make the texture frustum match the one on your projection matrix.

That should do the trick.