Surface to opengl texture problem

The following code I use to convert a surface to opengl texture works
fine when compiled with old gcc.When compiled with VC Express 2005 or gcc
4.1 I got an error:

tmp=IMG_Load(“data/green.jpg”);

glGenTextures(1, &grass);
glBindTexture(GL_TEXTURE_2D, grass); // 2d texture (x and y size)

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB,tmp->w, tmp->h, GL_RGB,
GL_UNSIGNED_BYTE, tmp->pixels);

No matter what image type I use, jpg or png it is the same. Can somebody
suggest me some more reliable way to do this?–
Roger D. Vargas

Hello Roger,

Wednesday, November 8, 2006, 5:36:03 PM, you wrote:

The following code I use to convert a surface to opengl texture works
fine when compiled with old gcc.When compiled with VC Express 2005 or gcc
4.1 I got an error:

tmp=IMG_Load(“data/green.jpg”);

glGenTextures(1, &grass);
glBindTexture(GL_TEXTURE_2D, grass); // 2d texture (x and y size)

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB,tmp->w, tmp->h, GL_RGB,
GL_UNSIGNED_BYTE, tmp->pixels);

No matter what image type I use, jpg or png it is the same. Can somebody
suggest me some more reliable way to do this?

You got “an error”? A compile error? A runtime error ? A crash,
wrong-looking texture?

Be more specific.–
Best regards,
Peter mailto:@Peter_Mulholland

El mi?, 08-11-2006 a las 17:38 +0000, Peter Mulholland escribi?:

Hello Roger,

You got “an error”? A compile error? A runtime error ? A crash,
wrong-looking texture?

Be more specific.
Sorry, under linux i got a segmentation fault. Under windows simply a
crash and the usual windows asking to report to microsoft. In bot cases
when I debug I find that the crashing code is the texture creation line,
no matter if it is glTexImage2D or gluBuild2DMipmaps. I have found this
problem in all my projects.–
Roger D. Vargas
Formatur Santiago