| 28 | } |
| 29 | |
| 30 | void GL46TextureArray::Initialize() |
| 31 | { |
| 32 | // Save current binding for this texture target in order to restore it |
| 33 | // when done because the gl texture object is needed to be bound to this |
| 34 | // texture target for the operations to follow. |
| 35 | GLint prevBinding; |
| 36 | glGetIntegerv(mTargetBinding, &prevBinding); |
| 37 | glBindTexture(mTarget, mGLHandle); |
| 38 | |
| 39 | // The default is 4-byte alignment. This allows byte alignment when data |
| 40 | // from user buffers into textures and vice versa. |
| 41 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 42 | glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 43 | |
| 44 | // Set the range of levels. |
| 45 | glTexParameteri(mTarget, GL_TEXTURE_BASE_LEVEL, 0); |
| 46 | glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, mNumLevels-1); |
| 47 | |
| 48 | // Initialize with data? |
| 49 | auto texture = GetTexture(); |
| 50 | auto const numItems = texture->GetNumItems(); |
| 51 | if (texture->GetData()) |
| 52 | { |
| 53 | if (CanAutoGenerateMipmaps()) |
| 54 | { |
| 55 | // Initialize with the first mipmap level and then generate |
| 56 | // the remaining mipmaps. |
| 57 | for (uint32_t item = 0; item < numItems; ++item) |
| 58 | { |
| 59 | auto data = texture->GetDataFor(item, 0); |
| 60 | if (data) |
| 61 | { |
| 62 | LoadTextureLevel(item, 0, data); |
| 63 | } |
| 64 | } |
| 65 | GenerateMipmaps(); |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | // Initialize with each mipmap level. |
| 70 | for (uint32_t item = 0; item < numItems; ++item) |
| 71 | { |
| 72 | for (int32_t level = 0; level < mNumLevels; ++level) |
| 73 | { |
| 74 | auto data = texture->GetDataFor(item, level); |
| 75 | if (data) |
| 76 | { |
| 77 | LoadTextureLevel(item, level, data); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | glBindTexture(mTarget, prevBinding); |
| 85 | } |
| 86 | |
| 87 | bool GL46TextureArray::Update() |
nothing calls this directly
no test coverage detected