views:

46

answers:

2

I'm having problem at mipmapping the textures on different hardware. I use the following code:

char *exts = (char *)glGetString(GL_EXTENSIONS);

if(strstr(exts, "SGIS_generate_mipmap") == NULL){
    // use gluBuild2DMipmaps()
}else{
    // use GL_GENERATE_MIPMAP
}

But on some cards it says GL_GENERATE_MIPMAP is supported when its not, thus the gfx card is trying to read memory from where the mipamp is supposed to be, thus the card renders other textures to those miplevels.

I tried glGenerateMipmapEXT(GL_TEXTURE_2D) but it makes all my textures white, i enabled GL_TEXTURE_2D before using that function (as it was told to).

I could as well just use gluBuild2DMipmaps() for everyone, since it works. But i dont want to make new cards load 10x slower because theres 2 users who have really old cards.

So how do you choose mipmap method correctly?

+1  A: 

If drivers lie, there's not much you can do about it. Also remember that glGenerateMipmapEXT is part of the GL_EXT_framebuffer_object extension.

What you are doing wrong is checking for the SGIS_generate_mipmap extension and using GL_GENERATE_MIPMAP, since this enum belongs to core OpenGL, but that's not really the problem.

The issue you describe sounds like a very horrible OpenGL implementation bug, i would bypass it using gluBuild2DMipmaps on those cards (having a list and checking at startup).

Matias Valdenegro
+1 for the first part, but I wouln'd blame the drivers. Try with GL_GENERATE_MIPMAP_SGIS instead. You can also check for GL_EXT_framebuffer_object and use glGenerateMipmap if available.
Calvin1602
the problem is i dont know how to detect those cards.
Newbie
i think i got it working, gonna accept this one after some tests
Newbie
+2  A: 

glGenerateMipmap is supported at least by OpenGL 3.3 as a part of functionality, not as extension.

You have following options:

  1. Check OpenGL version, if it is more recent that the first one that ever supported glGenerateMipmap, use glGenerateMipmap.
  2. (I'd recommend this one) OpenGL 1.4..2.1 supports texParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE)(see this) Which will generate mipmaps from base level. This probably became "deprecated" in OpenGL 3, but you should be able to use it.
  3. Use GLEE or GLEW ans use glewIsSupported / gleeIsSupported call to check for extension.

Also I think that instead of using extensions, it should be easier to stick with OpenGL specifications. A lot of hardware supports OpenGL 3, so you should be able get most of required functionality (shaders, mipmaps, framebuffer objects, geometry shaders) as part of OpenGL specification, not as extension.

SigTerm
glGenerateMipmap doesnt work on me, suggestions?
Newbie
@Newbie: `texParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE)` http://www.opengl.org/sdk/docs/man/xhtml/glTexParameter.xml. Make sure you set this parameter BEFORE calling glTexImage2D.
SigTerm
it still just crashes for me, however glGenerateMipmapEXT doesnt crash, should i use glGenerateMipmapEXT then?
Newbie
i dont understand why i need to use glGenerateMipmapEXT() since it works with just GL_GENERATE_MIPMAP parameter. and it seems glGenerateMipmapEXT() crashing for some users...
Newbie
oh nvm i got it working now, i hope
Newbie