bool Renderer::LoadGLTexture(string filename, int id) {
SDL_Surface *TextureImage[1];
if(!(TextureImage[0]=IMG_Load(filename.c_str()))) return false;
glGenTextures(1, &textures[id]);
glBindTexture(GL_TEXTURE_2D, textures[id]);
//glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->w,TextureImage[0]->h, 0, GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,TextureImage[0]->w,TextureImage[0]->h,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[0]->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if(TextureImage[0]) SDL_FreeSurface(TextureImage[0]);
return true;
}
If i comment the two lines between the two commented lines and uncomment the two commented ones everything works fine.
FYI: Nehe lesson07 compiles just fine and runs without problems, so I suppose the problem is within my code.
Any suggestions what might make the gluBuild2DMipmaps function segfault?
gluBuild2DMipmaps segfaults
I have got a problem with gluBuild2DMipmaps.
I created a simple OpenGL/SDL app in Linux and it worked fine until I tried to add mipmapped textures.
I just changed 2 lines and every time gluBuild2DMipmaps is called the program just segfaults.
Here is the code that is loading my textures:
Instead of using "id" in the arrays, try first with 0
[edited by - Leyder Dylan on September 29, 2003 7:01:46 PM]
[edited by - Leyder Dylan on September 29, 2003 7:01:46 PM]
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Using 0 instead of id has the same effect.
Segmentation fault when calling gluBuild2DMipmaps.
The thing that bugs me most is that the exact same code compiles and runs just fine on WinXP, but all of the linux machines I have tested this on just segfault.
Segmentation fault when calling gluBuild2DMipmaps.
The thing that bugs me most is that the exact same code compiles and runs just fine on WinXP, but all of the linux machines I have tested this on just segfault.
Are the same versions of the SDL and the SDL_image libraries installed on WinXP and Linux machines ?
EDIT : By the way, since the GLU source code is freely available (on sourceforge if memory deserves) you could trace what's going on inside the gluBluild2DMipMap() function with your debugger.
[edited by - Prosper/LOADED on September 30, 2003 9:52:33 AM]
EDIT : By the way, since the GLU source code is freely available (on sourceforge if memory deserves) you could trace what's going on inside the gluBluild2DMipMap() function with your debugger.
[edited by - Prosper/LOADED on September 30, 2003 9:52:33 AM]
In fact the linux machines I tested on had newer SDL libs installed (1.2.5) than the winxp machine(1.2.3).
I''ll test if that has an effect on my problem.
About the GLU source code: AFAIK glux is part of (in my case) Nvidias OpenGL implementation for linux and therefor closed source.
But I could try to trace back the error inside the library
(never did anything with strace or similar tools, though).
But gluBuild2DMipmap can''t be defective.
Nehe lesson07 runs flawlessly. And that lesson uses said function.
I''ll test if that has an effect on my problem.
About the GLU source code: AFAIK glux is part of (in my case) Nvidias OpenGL implementation for linux and therefor closed source.
But I could try to trace back the error inside the library
(never did anything with strace or similar tools, though).
But gluBuild2DMipmap can''t be defective.
Nehe lesson07 runs flawlessly. And that lesson uses said function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement