Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public GLImageFormat getImageFormatWithError(Format fmt, boolean isSrgb) {
}

private void setupTextureSwizzle(int target, Format format) {
// Swizzle state belongs to the cubemap, not to an individual image face.
// OpenGL defines the six face enums contiguously (0x8515 through 0x851A).
if (target >= GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X
Comment on lines +108 to +110

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, tight fix — normalizing the target only in setupTextureSwizzle means uploadTexture still hands each face target to glTexImage2D, which is exactly what cube maps need.

One small robustness note: this range check silently relies on the six face enums being numerically contiguous (0x8515–0x851A). It is today, but if that assumption ever breaks the swizzle would just be skipped instead of failing loudly. A one-line comment makes that explicit for the next reader.

Suggested change
// Swizzle state belongs to the cubemap, not to an individual image face.
if (target >= GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X
// glTexParameteri needs the cube map target, not an individual face target.
// The six face enums are contiguous (0x8515..0x851A).
if (target >= GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X
&& target <= GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) {

&& target <= GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) {
target = GL.GL_TEXTURE_CUBE_MAP;
}
// Needed for OpenGL 3.3 to support luminance / alpha formats
switch (format) {
case Alpha8:
Expand Down
Loading