PDA

View Full Version : Generate mipmaps using few textures



kamac496
04-07-2015, 11:45 AM
Hey.

I've been trying to have my font rendered nice and crisp even when downscaled (by projection, for example), so I figured I should create handmade mipmaps. No big deal - I just made few textures with different character sizes, providing me with textures I'd use for mipmapping.

Now, the problem is, I can't find any good sources on generating a texture with custom mipmaps. What I basically have is something like this:


GLuint texture0, texture1, texture2, texture3; // textures of different sizes containing my character atlas'
GLuint mipmappedTexture; // texture I want to use that will use previous 4 textures as mipmaps

Maybe I'm getting something wrong, but how do I do it? Is that possible?

By the way, if you have any better suggestions on how to make my font look nice and sharp even when downscaled, I'd be happy to hear them.

GClements
04-07-2015, 12:56 PM
Now, the problem is, I can't find any good sources on generating a texture with custom mipmaps. What I basically have is something like this:


GLuint texture0, texture1, texture2, texture3; // textures of different sizes containing my character atlas'
GLuint mipmappedTexture; // texture I want to use that will use previous 4 textures as mipmaps

Maybe I'm getting something wrong, but how do I do it? Is that possible?
It's possible, but it's not normally how you go about it. You don't normally start by creating each mipmap level as a separate texture. Instead, you create a single texture then upload (or render) the data for each level directly into that level.

If you're generating the data for the mipmap levels in client memory, you use the level parameter of glTexImage2D, glTexSubImage2D, etc to specify which level you're uploading. If you're downsampling using render-to-texture, then you bind the appropriate level to the framebuffer by setting the level parameter for glFramebufferTexture or glFramebufferTexture2D accordingly.