Opengl mipmapping


it is probably a very stupid question, but I cannot solve the issue

this code works perfectly and displays a mesh with its texture:

OpenGL.glTexParameteri (OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP, opengl.GL_TRUE)



Dim miplevel as integer = 0

OpenGL.glTexImage2d(OpenGL.GL_TEXTURE_2D, miplevel, 4, imageWidth , imageheight, 0, OpenGL.GL_BGRA, OpenGL.GL_UNSIGNED_BYTE, textureBitmap)

If I set miplevel = 1 or higher, with the aim of using a reduced size texture, I only see a white mesh.

I believe that changing the mesh reduced size image also requires a set of images that are also reduced in size. Here is an excerpt from OpenGL Programming Fuid, 2nd Edition, OpenGL Architecture Review Board, Addison-Wesley, 1998.

I believe that when a miplevel of 0 is used then the original size is automatically created for the reduced sizes.

1 Like

Thanks a lot,
just resolved the whole issue of slow rendering with big textures, it appears that the mipmap pyramid is not created automatically when calling OpenGL.glTexParameteri (OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP, opengl.GL_TRUE)
To create the differet mipmap level, glTexImage2d must be called at least two times,
one for maximum resolution (level 0) and one for another generic level N, e.g.:

OpenGL.glTexImage2d(OpenGL.GL_TEXTURE_2D, 0, 4, imageWidth , imageheight, 0, OpenGL.GL_BGRA, OpenGL.GL_UNSIGNED_BYTE, textureBitmap)

OpenGL.glTexImage2d(OpenGL.GL_TEXTURE_2D, N, 4, imageWidth/2^N , imageheight/2^N, 0, OpenGL.GL_BGRA, OpenGL.GL_UNSIGNED_BYTE, textureBitmap2)

in which the size of texturebitmap2=size texturebitmap/(2*2^N)