From 7a22f8c9409c0a03d8bc3133381e4e19d6aa2851 Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Sat, 9 Sep 2017 13:10:38 -0400 Subject: [PATCH] Support ABGR8 using swizzle extension --- .../src/main/java/com/jme3/renderer/opengl/GL.java | 1 + .../java/com/jme3/renderer/opengl/TextureUtil.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java index 45e4ce715..19bdfffff 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL.java @@ -50,6 +50,7 @@ public interface GL { public static final int GL_ARRAY_BUFFER = 0x8892; public static final int GL_BACK = 0x405; public static final int GL_BLEND = 0xBE2; + public static final int GL_BLUE = 0x1905; public static final int GL_BYTE = 0x1400; public static final int GL_CLAMP_TO_EDGE = 0x812F; public static final int GL_COLOR_BUFFER_BIT = 0x4000; diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java index fb6032393..305da6d83 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java @@ -32,7 +32,6 @@ package com.jme3.renderer.opengl; import com.jme3.renderer.Caps; -import com.jme3.renderer.RenderContext; import com.jme3.renderer.RendererException; import com.jme3.texture.Image; import com.jme3.texture.Image.Format; @@ -91,7 +90,7 @@ final class TextureUtil { public GLImageFormat getImageFormatWithError(Format fmt, boolean isSrgb) { //if the passed format is one kind of depth there isno point in getting the srgb format; - isSrgb = isSrgb && fmt != Format.Depth && fmt != Format.Depth16 && fmt != Format.Depth24 && fmt != Format.Depth24Stencil8 && fmt != Format.Depth32 && fmt != Format.Depth32F; + isSrgb = isSrgb && !fmt.isDepthFormat(); GLImageFormat glFmt = getImageFormat(fmt, isSrgb); if (glFmt == null && isSrgb) { glFmt = getImageFormat(fmt, false); @@ -127,6 +126,14 @@ final class TextureUtil { gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_RED); gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_GREEN); break; + case ABGR8: + gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_R, GL.GL_ALPHA); + gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_G, GL.GL_BLUE); + gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_B, GL.GL_GREEN); + gl.glTexParameteri(target, GL3.GL_TEXTURE_SWIZZLE_A, GL.GL_RED); + break; + default: + throw new UnsupportedOperationException(); } }