One Perl/OpenGL texture

One Perl/OpenGL texture

am 24.11.2006 12:36:07 von weer1

Hi,

I want to do a texture on a polygon but I think I am missing something
here.
Nowhere in the code I see a connection with my polygon but the polygon
turns flickering black and green when I do enable the texture. I have
the code below now.

Any ideas?

MD
---------
...
glBegin(GL_POLYGON);
glVertex3f(0, 0, 1);
glVertex3f(0, 0.5, 1);
glVertex3f(1, 0, 1);
glEnd();

# make texture
my $img = new Imager;
$img->open(file=>'check.png', type=>'png'); # initializes
from file
my $texid = glGenTextures_p(1);
glBindTexture(GL_TEXTURE_2D, $texid);
glTexImage2D_c(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_BYTE,

$img); # not sure its _c
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glEnable(GL_TEXTURE_2D);
# glClearColor(0, 0.3, 0.6, 1);
#end texture

glPopMatrix();
glutSwapBuffers();