Kaynağa Gözat

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
iwg..om 12 yıl önce
ebeveyn
işleme
e26c86c794

Dosya farkı çok büyük olduğundan ihmal edildi
+ 457 - 362
engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java


+ 16 - 5
engine/src/android/com/jme3/renderer/android/TextureUtil.java

@@ -24,16 +24,19 @@ public class TextureUtil {
     private static boolean ETC1support = false;
     private static boolean DXT1 = false;
     private static boolean DEPTH24 = false;
+    private static boolean DEPTH_TEXTURE = false;
 
     public static void loadTextureFeatures(String extensionString) {
         ETC1support = extensionString.contains("GL_OES_compressed_ETC1_RGB8_texture");
         DEPTH24 = extensionString.contains("GL_OES_depth24");
         NPOT = extensionString.contains("GL_OES_texture_npot") || extensionString.contains("GL_NV_texture_npot_2D_mipmap");
         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 DEPTH24? {0}", DEPTH24);
         logger.log(Level.FINE, "Supports NPOT? {0}", NPOT);
         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) {
@@ -241,7 +244,7 @@ public class TextureUtil {
         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();
         switch (fmt) {
             case RGBA16:
@@ -269,14 +272,17 @@ public class TextureUtil {
             case RGB565:
                 imageFormat.format = GLES20.GL_RGB;
                 imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_6_5;
+                imageFormat.renderBufferStorageFormat = GLES20.GL_RGB565;
                 break;
             case ARGB4444:
                 imageFormat.format = GLES20.GL_RGBA4;
                 imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
+                imageFormat.renderBufferStorageFormat = GLES20.GL_RGBA4;
                 break;
             case RGB5A1:
                 imageFormat.format = GLES20.GL_RGBA;
                 imageFormat.dataType = GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
+                imageFormat.renderBufferStorageFormat = GLES20.GL_RGB5_A1;
                 break;
             case RGB8:
                 imageFormat.format = GLES20.GL_RGB;
@@ -293,8 +299,12 @@ public class TextureUtil {
             case Depth:
             case Depth16:
             case Depth24:
+                if (!DEPTH_TEXTURE) {
+                    unsupportedFormat(fmt);
+                }
                 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;
             case DXT1:
                 if (!DXT1) {
@@ -318,10 +328,11 @@ public class TextureUtil {
         return imageFormat;
     }
 
-    private static class AndroidGLImageFormat {
+    public static class AndroidGLImageFormat {
 
         boolean compress = false;
         int format = -1;
+        int renderBufferStorageFormat = -1;
         int dataType = -1;
     }
 
@@ -334,7 +345,7 @@ public class TextureUtil {
                     + "Use uploadTextureBitmap instead.");
         }
 
-        // Otherwise upload image directly. 
+        // Otherwise upload image directly.
         // Prefer to only use power of 2 textures here to avoid errors.
         Image.Format fmt = img.getFormat();
         ByteBuffer data;
@@ -436,7 +447,7 @@ public class TextureUtil {
             return;
         }
 
-        // Otherwise upload image directly. 
+        // Otherwise upload image directly.
         // Prefer to only use power of 2 textures here to avoid errors.
         Image.Format fmt = img.getFormat();
         ByteBuffer data;

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor