Currently I fill my texture with all the same values, so I would expect that the first level mipmap averages out to approximately the same value. I just can’t seem to get this to work. Did I forget something?
You should either use glTexImage2D in a loop or gluBuild2DMipmaps.
Try with gluBuild2DMipmaps.
With glTexImage2D you will have to downscale texture by yourself and make sure you generate proper mipmap sizes.
gluBuild2DMipmaps will do the above for you. If you use it you don’t have to use any kind of generate mipmap stuff.
By the way, you don’t have to enable texture to use TexImage nor GetTexImage, but it’s no problem if you do.
gluBuild2DMipmaps will crash if the source image is not power of two in size.
What you should do is use gluScaleImage when manually creating your mipmaps with glTexImage2D.
The generate mipmaps stuff is a driver level auto-generation capaility that might be hardware accelerated it generates based on level zero which could be rendered with the right extensions.
gluBuild2DMipmaps is a software utility that ultimately calls glTexImage for each level. You can also do your own calls to glTexImage.
If that software is crashing it is very probably because you have given image data that is not correctly described by your image parameters and/or is incompatible with the texture format you have bound.
You don’t say what your BUFFER_OFFSET() macro does but that whole build2dmipmaps call is hardcoded and may be incompatile with the internal and external texture format your non hardcoded teximage call.
RGB textures are not always RGB format internal and/or external and in this case size matters A LOT.
I was considering the gluScaleImage to manually do the mipmapping, not to resize to a 2^n texture.
The macro I use can be found is several OpenGL specs in the examples: #define BUFFER_OFFSET(i) ((char *)NULL + (i))
Nothing fancy there, except that I read from a PB. Since I receive my values back through a transform feedback I need to somehow turn this into a mipmapped texture.
Originally posted by ropel:
1.glTexImages allows to manually fill a texture at a certain level.
yes, stick it in google.
2.gluBuild2DMipmaps automates this resizing. (It crashes for me, I’m not sure why yet)
it doesn’t resize the initial image, but it progressively halves the size while calling teximage with a greater and greater value in the mipmap level parameter. It crashes on non-pow2 initial textures. For older hardware, you should use this function, but check the pow2 validity and call gluScaleImage beforehand if not pow2 (it should do this itself, but unfortunately it doesn’t). Software only.
3.glGenerateMipmapEXT can only be used for FBO rendered textures (?)
no, although its a function introduced in the FBO extension, it can be used on any texture. (only if FBO extension is supported though). Hardware accelerated.
4.glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE) I’m not sure about yet.
with this enabled, the mipmap pyramid is automatically re-generated every time a glteximage/gltexsubimage is called on that texture object. Hardware accelerated.