Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Generate mipmaps using few textures

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    3

    Generate mipmaps using few textures

    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:

    Code :
    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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,470
    Quote Originally Posted by kamac496 View Post
    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:

    Code :
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •