PyOpenGL- 1D Automatic Tex Gen supported?

Mark Schmucker mark at sabinosoft.com
Sun Feb 2 12:26:18 EST 2003


Hi, I'm trying to apply a stripe to an image, like the striped teapot
example in the Red Book Example 9-8. I've followed example 9.8 as
closely as possible, adapting for Python as necessary, and can't get
any reasonable results.

The image does change when I apply this texture- it's doing
*something*- but the stripe is the wrong color and appears to be
interpolated, plus the orientation and spacing is not correct.

It could be a type issue, although I've tried different formats.

I have used 2D automatic texture generation with PyOpenGL
successfully. Does anyone know whether 1D is fully supported?

Here's my stripped-down code- any ideas are appreciated!


stripeWidth = 4
stripeImage = array.array('B', [0,0,0,255, 0,0,0,255, 0,0,0,255,
255,255,255,255]) # we'll spec RGBA format in glTexImage1D


glEnable(GL_TEXTURE_1D);
glDisable(GL_TEXTURE_2D);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

tex = glGenTextures(1)
glBindTexture(GL_TEXTURE_1D, tex)

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT);

glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, stripeImageWidth, 0, GL_RGBA,
GL_UNSIGNED_BYTE, stripeImage);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); # tried
GL_EYE_LINEAR too

# make a slanted object plane- should be able to see *something* like
this:

sp = 0.1 # I've tried a range of spacings
plane = (sp, sp, sp, 0.0)
glTexGenfv(GL_S, GL_OBJECT_PLANE, plane);

DrawStuff()



Thanks for any help,
Mark




More information about the Python-list mailing list