Added support for ETC1 compression (regular OGL only for now)
This commit is contained in:
parent
8d406380b0
commit
b83603cd8f
@ -251,7 +251,12 @@ public enum Caps {
|
|||||||
/**
|
/**
|
||||||
* Supports anisotropic texture filtering.
|
* Supports anisotropic texture filtering.
|
||||||
*/
|
*/
|
||||||
TextureFilterAnisotropic;
|
TextureFilterAnisotropic,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports {@link Format#ETC1} texture compression.
|
||||||
|
*/
|
||||||
|
TextureCompressionETC1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if given the renderer capabilities, the texture
|
* 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
|
* It is also a required format, so you can count on it
|
||||||
* being present.
|
* 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 int bpp;
|
||||||
private boolean isDepth;
|
private boolean isDepth;
|
||||||
|
@ -357,6 +357,10 @@ public class LwjglRenderer implements Renderer {
|
|||||||
caps.add(Caps.TextureCompressionLATC);
|
caps.add(Caps.TextureCompressionLATC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasExtension("GL_ARB_ES3_compatibility")) {
|
||||||
|
caps.add(Caps.TextureCompressionETC1);
|
||||||
|
}
|
||||||
|
|
||||||
if (hasExtension("GL_EXT_packed_float") || caps.contains(Caps.OpenGL30)) {
|
if (hasExtension("GL_EXT_packed_float") || caps.contains(Caps.OpenGL30)) {
|
||||||
// This format is part of the OGL3 specification
|
// This format is part of the OGL3 specification
|
||||||
caps.add(Caps.PackedFloatColorBuffer);
|
caps.add(Caps.PackedFloatColorBuffer);
|
||||||
@ -2208,6 +2212,9 @@ public class LwjglRenderer implements Renderer {
|
|||||||
throw new UnsupportedOperationException("Unknown buffer format.");
|
throw new UnsupportedOperationException("Unknown buffer format.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Invalidate buffer data (orphan) before uploading new data.
|
||||||
|
|
||||||
|
|
||||||
switch (vb.getFormat()) {
|
switch (vb.getFormat()) {
|
||||||
case Byte:
|
case Byte:
|
||||||
case UnsignedByte:
|
case UnsignedByte:
|
||||||
|
@ -42,10 +42,10 @@ import java.util.EnumSet;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static org.lwjgl.opengl.ARBDepthBufferFloat.*;
|
import static org.lwjgl.opengl.ARBDepthBufferFloat.*;
|
||||||
|
import org.lwjgl.opengl.ARBES3Compatibility;
|
||||||
import static org.lwjgl.opengl.ARBHalfFloatPixel.*;
|
import static org.lwjgl.opengl.ARBHalfFloatPixel.*;
|
||||||
import static org.lwjgl.opengl.ARBTextureFloat.*;
|
import static org.lwjgl.opengl.ARBTextureFloat.*;
|
||||||
import static org.lwjgl.opengl.ARBTextureMultisample.*;
|
import static org.lwjgl.opengl.ARBTextureMultisample.*;
|
||||||
import org.lwjgl.opengl.ContextCapabilities;
|
|
||||||
import static org.lwjgl.opengl.EXTPackedDepthStencil.*;
|
import static org.lwjgl.opengl.EXTPackedDepthStencil.*;
|
||||||
import static org.lwjgl.opengl.EXTPackedFloat.*;
|
import static org.lwjgl.opengl.EXTPackedFloat.*;
|
||||||
import static org.lwjgl.opengl.EXTTextureArray.*;
|
import static org.lwjgl.opengl.EXTTextureArray.*;
|
||||||
@ -142,6 +142,11 @@ class TextureUtil {
|
|||||||
// LTC/LATC/3Dc formats
|
// LTC/LATC/3Dc formats
|
||||||
setFormat(Format.LTC, GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE, true);
|
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);
|
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
|
//sRGB formats
|
||||||
@ -160,6 +165,11 @@ class TextureUtil {
|
|||||||
|
|
||||||
public static GLImageFormat getImageFormat(EnumSet<Caps> caps, Format fmt, boolean isSrgb){
|
public static GLImageFormat getImageFormat(EnumSet<Caps> caps, Format fmt, boolean isSrgb){
|
||||||
switch (fmt){
|
switch (fmt){
|
||||||
|
case ETC1:
|
||||||
|
if (!caps.contains(Caps.TextureCompressionETC1)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DXT1:
|
case DXT1:
|
||||||
case DXT1A:
|
case DXT1A:
|
||||||
case DXT3:
|
case DXT3:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user