One texture Perl / OpenGL

W

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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top