Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using Windows 7 and most people in the group of this specific OpenGL project is too, there's only one member on Windows XP. We are all using Visual Studio 2010 though. I don't know if the OpenGL headers come with VS or with Windows but I would assume it's VS. And since we are all using the same VS version, albeit not the same SKU, I'm also assuming we all have the same OpenGL headers and version running on our systems.

That said, the version installed on my system (note that I haven't installed anything OpenGL related) is 2.1 and it does support GL_GENERATE_MIPMAP, I don't need to resort ot the SGIS extension.

However, the Windows headers only support version 1.1. To work around that, I'm using GLEW. I also noticed that both GL_GENERATE_MIPMAP_SGIS and GL_GENERATE_MIPMAP have the same exact values defined.

So my question is, should I do the following on my texture loading routine:

if(GLEW_SGIS_generate_mipmap) {
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
    glTexImage2D(GL_TEXTURE_2D, 0, glFormat, texWidth, texHeight, 0, glFormat,
        GL_UNSIGNED_BYTE, texPixels);
} else {
    gluBuild2DMipmaps(GL_TEXTURE_2D, glFormat, texWidth, texHeight, glFormat,
        GL_UNSIGNED_BYTE, texPixels);
}

...or can I just assume everything will work and just do this:

glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, glFormat, texWidth, texHeight, 0, glFormat,
    GL_UNSIGNED_BYTE, texPixels);

?

I would think that this code would fail (and the game wouldn't probably run) if the OpenGL version doesn't support mipmapping generation like that, but nowadays, most people probably have OpenGL 2.1 on their systems right, probably in Windows XP too (without any development tools installed)?

Also, another small question...

My laptop has 2 graphics card, one integrated (Intel) and the other dedicated (NVIDIA), with NVIDIA Optimus technology. Mipmapping using the dedicated GPU seems to have better quality. I mean, the integrated card mipmapping seems more pixelized in near planes (I'm talking about a plane terrain texture) than the dedicated one. And when I move the camera, the near pixels "blink" a little (with the integrated card) and it's distracting, while the far pixels look nicely linear. Yes, I'm using GL_LINEAR_MIPMAP_LINEAR for the minifying filter. Anyway to fix this?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Available OpenGL functionality is determined by the graphics hardware/driver revision; it is independent of installed developer tools.

If you want to be super-safe, use your first version and test for GLEW_VERSION_1_4 too:

if(GLEW_VERSION_1_4 || GLEW_SGIS_generate_mipmap)

That will take care of the cases where either 1) the SGIS extension is reported by a driver/card that reports a GL version before the extension became part of the core, 2) where the GL version is sufficient but the SGIS extension is not reported (which I haven't seen in the wild, but I suppose it could happen) or 3) neither condition is met and you fall back to GLU. GL_GENERATE_MIPMAP_SGIS and GL_GENERATE_MIPMAP are the same, so it doesn't matter which one you use in your code (assuming one is available, so is the other; it all looks the same to the runtime).

As to your other question: a difference in the setting for anisotropic filtering or anti-aliasing would be my guess.

share|improve this answer
    
I've updated both cards drivers and the mipmapping pixelization is no longer visible. The NVIDIA card seems to have better mipmapping quality though. –  Ricardo Amaral Apr 21 '11 at 19:43
    
I should add; and I upvoted the answer from 5ound because it's broadly what he's getting at- hardware (for some loose definition of 'hardware', that includes a reasonably up to date software driver) that doesn't support GL 1.4 has got to be pretty rare at this point. So your second approach should also be fine. But like I said, super-safe and so forth. –  boat365 Apr 21 '11 at 20:01
add comment

Here's a link which has good information about automatic mipmap generation: http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation

In short:

if OpenGL >= 3.0, use glGenerateMipmap

else if OpenGL >= 1.4, use glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

else video card is pretty old at this point, fall back to gluBuild2DMipmaps?

else cut off support
share|improve this answer
    
As far as I know, GL_GENERATE_MIPMAP_SGIS was an extension and now is part of the OpenGL core as GL_GENERATE_MIPMAP, they have the same defines as I said above. You answer has little to do with my question... That's not what I asked. –  Ricardo Amaral Apr 13 '11 at 20:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.