Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:35:22+00:00 2026-05-25T22:35:22+00:00

I’ve got a simple (I think) question about OpenGL texture arrays. I create my

  • 0

I’ve got a simple (I think) question about OpenGL texture arrays. I create my texture array with something like the following:

glTexImage3D(   GL_TEXTURE_2D_ARRAY,
        0,
        formatGL,
        width,
        height,
        slices,
        0,
        GL_RGBA, 
        GL_UNSIGNED_BYTE, 
        nullptr);

Note that I don’t want to actually load any images into it yet. I’m just creating the structure that I’ll be filling with data later on.

So my questions are:

  1. How do I generate the mip chain for each “slice” of the texture array? I don’t want to physically generate the mip, I just want to complete the texture by telling it about the mip. I can do this with 2D textures simply by calling the glTexImage2D function with the mip level, size and also passing in a nullptr. I can’t see how to do this with the glTexImage3D function given there’s no “slice” parameter. The OpenGL superbible example only loads a .bmp into the first mip level for each texture in the array. Is it correct to say that using glTexSubImage3D, passing in a nullptr, will create the mip level I want for a given texture in the array?

  2. Documentation at khronos.org on glGenerateMipMap specifies GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP only. So is it correct to say I can’t use this method for 2D texture arrays?

Here’s what I do with 2D textures to create the mip chain:

    size_t i = 0, mipSizeX = width, mipSizeY = height;

    while(mipSizeX >= 1 || mipSizeY >= 1)
    {
        // Generate image for this mip level

        glTexImage2D(   GL_TEXTURE_2D,
                        i,
                        formatGL,
                        mipSizeX,
                        mipSizeY,
                        0,
                        GL_RGBA, 
                        GL_UNSIGNED_BYTE, 
                        nullptr);

        // Go to the next mip size.

        mipSizeX >>= 1;
        mipSizeY >>= 1;

        // and the next mipmap level.

        i++;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:35:23+00:00Added an answer on May 25, 2026 at 10:35 pm

    I can do this with 2D textures simply by calling the glTexImage2D function with the mip level, size and also passing in a nullptr. I can’t see how to do this with the glTexImage3D function given there’s no “slice” parameter.

    Why not? glTexImage3D takes a mipmap level, just like glTexImage2D. It takes a size, which in 2D is two dimensions, but in 3D is three dimensions.

    Indeed, the only difference between the two functions is the number of dimensions that they take (and therefore the possible target parameters). And there is a “slice” parameter; you used it with glTexImage3D in the call you showed us. There, it’s called depth.

    The difference between 3D textures and 2D array textures is that the depth does not change in lower mipmaps for 2D arrays. Each mipmap of the array has the same number of “slices” as every other mipmap.

    Documentation at khronos.org

    If it’s at “khronos.org” and not “opengl.org”, then it’s almost certainly talking about OpenGL ES, which does not have array textures (later note: ES 3.0 added array textures).


    I honestly don’t know how to be any clearer without actually writing your code for you.

    size_t i = 0, mipSizeX = width, mipSizeY = height;
    
    while(mipSizeX >= 1 || mipSizeY >= 1)
    {
        // Generate image for this mip level
    
        glTexImage3D(   GL_TEXTURE_2D_ARRAY,
                        i,
                        formatGL,
                        mipSizeX,
                        mipSizeY,
                        arrayCount,
                        0,
                        GL_RGBA, 
                        GL_UNSIGNED_BYTE, 
                        nullptr);
    
        // Go to the next mip size.
    
        mipSizeX >>= 1;
        mipSizeY >>= 1;
    
        // and the next mipmap level.
    
        i++;
    }
    

    Also, you need to check that the mipmap sizes have a minimum value of 1. Because (1 >> 1) == 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.