Added support for ETC1 compression (regular OGL only for now)

experimental
shadowislord 10 years ago
parent 8d406380b0
commit b83603cd8f
  1. 7
      jme3-core/src/main/java/com/jme3/renderer/Caps.java
  2. 9
      jme3-core/src/main/java/com/jme3/texture/Image.java
  3. 7
      jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/LwjglRenderer.java
  4. 12
      jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java

@ -251,7 +251,12 @@ public enum Caps {
/**
* Supports anisotropic texture filtering.
*/
TextureFilterAnisotropic;
TextureFilterAnisotropic,
/**
* Supports {@link Format#ETC1} texture compression.
*/
TextureCompressionETC1;
/**
* Returns true if given the renderer capabilities, the texture

@ -317,7 +317,14 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
* It is also a required format, so you can count on it
* being present.
*/
RGB10_A2(32, false);
RGB10_A2(32, false),
/**
* Ericsson Texture Compression. Typically used on Android.
*
* Requires {@link Caps#TextureCompressionETC1}.
*/
ETC1(4, false, true, false);
private int bpp;
private boolean isDepth;

@ -357,6 +357,10 @@ public class LwjglRenderer implements Renderer {
caps.add(Caps.TextureCompressionLATC);
}
if (hasExtension("GL_ARB_ES3_compatibility")) {
caps.add(Caps.TextureCompressionETC1);
}
if (hasExtension("GL_EXT_packed_float") || caps.contains(Caps.OpenGL30)) {
// This format is part of the OGL3 specification
caps.add(Caps.PackedFloatColorBuffer);
@ -2208,6 +2212,9 @@ public class LwjglRenderer implements Renderer {
throw new UnsupportedOperationException("Unknown buffer format.");
}
} else {
// Invalidate buffer data (orphan) before uploading new data.
switch (vb.getFormat()) {
case Byte:
case UnsignedByte:

@ -42,10 +42,10 @@ import java.util.EnumSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.lwjgl.opengl.ARBDepthBufferFloat.*;
import org.lwjgl.opengl.ARBES3Compatibility;
import static org.lwjgl.opengl.ARBHalfFloatPixel.*;
import static org.lwjgl.opengl.ARBTextureFloat.*;
import static org.lwjgl.opengl.ARBTextureMultisample.*;
import org.lwjgl.opengl.ContextCapabilities;
import static org.lwjgl.opengl.EXTPackedDepthStencil.*;
import static org.lwjgl.opengl.EXTPackedFloat.*;
import static org.lwjgl.opengl.EXTTextureArray.*;
@ -142,6 +142,11 @@ class TextureUtil {
// LTC/LATC/3Dc formats
setFormat(Format.LTC, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE, true);
setFormat(Format.LATC, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, true);
// ETC1 support on regular OpenGL requires ES3 compatibility extension.
// NOTE: ETC2 is backwards compatible with ETC1, so we can
// upload ETC1 textures as ETC2.
setFormat(Format.ETC1, ARBES3Compatibility.GL_COMPRESSED_RGB8_ETC2, GL_RGB, GL_UNSIGNED_BYTE, true);
}
//sRGB formats
@ -160,6 +165,11 @@ class TextureUtil {
public static GLImageFormat getImageFormat(EnumSet<Caps> caps, Format fmt, boolean isSrgb){
switch (fmt){
case ETC1:
if (!caps.contains(Caps.TextureCompressionETC1)) {
return null;
}
break;
case DXT1:
case DXT1A:
case DXT3:

Loading…
Cancel
Save