Android: Initial commit to support FrameBuffers. This is still a work in progress. FilterPostProcessors currently don't work on Android devices that do not support NPOT.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10513 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
a1fd0272d4
commit
e26c86c794
File diff suppressed because it is too large
Load Diff
@ -24,16 +24,19 @@ public class TextureUtil {
|
|||||||
private static boolean ETC1support = false;
|
private static boolean ETC1support = false;
|
||||||
private static boolean DXT1 = false;
|
private static boolean DXT1 = false;
|
||||||
private static boolean DEPTH24 = false;
|
private static boolean DEPTH24 = false;
|
||||||
|
private static boolean DEPTH_TEXTURE = false;
|
||||||
|
|
||||||
public static void loadTextureFeatures(String extensionString) {
|
public static void loadTextureFeatures(String extensionString) {
|
||||||
ETC1support = extensionString.contains("GL_OES_compressed_ETC1_RGB8_texture");
|
ETC1support = extensionString.contains("GL_OES_compressed_ETC1_RGB8_texture");
|
||||||
DEPTH24 = extensionString.contains("GL_OES_depth24");
|
DEPTH24 = extensionString.contains("GL_OES_depth24");
|
||||||
NPOT = extensionString.contains("GL_OES_texture_npot") || extensionString.contains("GL_NV_texture_npot_2D_mipmap");
|
NPOT = extensionString.contains("GL_OES_texture_npot") || extensionString.contains("GL_NV_texture_npot_2D_mipmap");
|
||||||
DXT1 = extensionString.contains("GL_EXT_texture_compression_dxt1");
|
DXT1 = extensionString.contains("GL_EXT_texture_compression_dxt1");
|
||||||
|
DEPTH_TEXTURE = extensionString.contains("GL_OES_depth_texture");
|
||||||
logger.log(Level.FINE, "Supports ETC1? {0}", ETC1support);
|
logger.log(Level.FINE, "Supports ETC1? {0}", ETC1support);
|
||||||
logger.log(Level.FINE, "Supports DEPTH24? {0}", DEPTH24);
|
logger.log(Level.FINE, "Supports DEPTH24? {0}", DEPTH24);
|
||||||
logger.log(Level.FINE, "Supports NPOT? {0}", NPOT);
|
logger.log(Level.FINE, "Supports NPOT? {0}", NPOT);
|
||||||
logger.log(Level.FINE, "Supports DXT1? {0}", DXT1);
|
logger.log(Level.FINE, "Supports DXT1? {0}", DXT1);
|
||||||
|
logger.log(Level.FINE, "Supports DEPTH_TEXTURE? {0}", DEPTH_TEXTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildMipmap(Bitmap bitmap, boolean compress) {
|
private static void buildMipmap(Bitmap bitmap, boolean compress) {
|
||||||
@ -241,7 +244,7 @@ public class TextureUtil {
|
|||||||
throw new UnsupportedOperationException("The image format '" + fmt + "' is unsupported by the video hardware.");
|
throw new UnsupportedOperationException("The image format '" + fmt + "' is unsupported by the video hardware.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AndroidGLImageFormat getImageFormat(Format fmt) throws UnsupportedOperationException {
|
public static AndroidGLImageFormat getImageFormat(Format fmt) throws UnsupportedOperationException {
|
||||||
AndroidGLImageFormat imageFormat = new AndroidGLImageFormat();
|
AndroidGLImageFormat imageFormat = new AndroidGLImageFormat();
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case RGBA16:
|
case RGBA16:
|
||||||
@ -269,14 +272,17 @@ public class TextureUtil {
|
|||||||
case RGB565:
|
case RGB565:
|
||||||
imageFormat.format = GLES20.GL_RGB;
|
imageFormat.format = GLES20.GL_RGB;
|
||||||
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_6_5;
|
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_6_5;
|
||||||
|
imageFormat.renderBufferStorageFormat = GLES20.GL_RGB565;
|
||||||
break;
|
break;
|
||||||
case ARGB4444:
|
case ARGB4444:
|
||||||
imageFormat.format = GLES20.GL_RGBA4;
|
imageFormat.format = GLES20.GL_RGBA4;
|
||||||
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
|
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
|
||||||
|
imageFormat.renderBufferStorageFormat = GLES20.GL_RGBA4;
|
||||||
break;
|
break;
|
||||||
case RGB5A1:
|
case RGB5A1:
|
||||||
imageFormat.format = GLES20.GL_RGBA;
|
imageFormat.format = GLES20.GL_RGBA;
|
||||||
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
|
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
|
||||||
|
imageFormat.renderBufferStorageFormat = GLES20.GL_RGB5_A1;
|
||||||
break;
|
break;
|
||||||
case RGB8:
|
case RGB8:
|
||||||
imageFormat.format = GLES20.GL_RGB;
|
imageFormat.format = GLES20.GL_RGB;
|
||||||
@ -293,8 +299,12 @@ public class TextureUtil {
|
|||||||
case Depth:
|
case Depth:
|
||||||
case Depth16:
|
case Depth16:
|
||||||
case Depth24:
|
case Depth24:
|
||||||
|
if (!DEPTH_TEXTURE) {
|
||||||
|
unsupportedFormat(fmt);
|
||||||
|
}
|
||||||
imageFormat.format = GLES20.GL_DEPTH_COMPONENT;
|
imageFormat.format = GLES20.GL_DEPTH_COMPONENT;
|
||||||
imageFormat.dataType = GLES20.GL_UNSIGNED_BYTE;
|
imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT;
|
||||||
|
imageFormat.renderBufferStorageFormat = GLES20.GL_DEPTH_COMPONENT16;
|
||||||
break;
|
break;
|
||||||
case DXT1:
|
case DXT1:
|
||||||
if (!DXT1) {
|
if (!DXT1) {
|
||||||
@ -318,10 +328,11 @@ public class TextureUtil {
|
|||||||
return imageFormat;
|
return imageFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class AndroidGLImageFormat {
|
public static class AndroidGLImageFormat {
|
||||||
|
|
||||||
boolean compress = false;
|
boolean compress = false;
|
||||||
int format = -1;
|
int format = -1;
|
||||||
|
int renderBufferStorageFormat = -1;
|
||||||
int dataType = -1;
|
int dataType = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +345,7 @@ public class TextureUtil {
|
|||||||
+ "Use uploadTextureBitmap instead.");
|
+ "Use uploadTextureBitmap instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise upload image directly.
|
// Otherwise upload image directly.
|
||||||
// Prefer to only use power of 2 textures here to avoid errors.
|
// Prefer to only use power of 2 textures here to avoid errors.
|
||||||
Image.Format fmt = img.getFormat();
|
Image.Format fmt = img.getFormat();
|
||||||
ByteBuffer data;
|
ByteBuffer data;
|
||||||
@ -436,7 +447,7 @@ public class TextureUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise upload image directly.
|
// Otherwise upload image directly.
|
||||||
// Prefer to only use power of 2 textures here to avoid errors.
|
// Prefer to only use power of 2 textures here to avoid errors.
|
||||||
Image.Format fmt = img.getFormat();
|
Image.Format fmt = img.getFormat();
|
||||||
ByteBuffer data;
|
ByteBuffer data;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user