OSDN Git Service

[removed] Text blending from SpriteBatch.
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Thu, 4 Nov 2010 21:12:52 +0000 (21:12 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Thu, 4 Nov 2010 21:12:52 +0000 (21:12 +0000)
[changed] Exception msgs for missing files.

backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidFiles.java
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFiles.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglFiles.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglGraphics.java
gdx/src/com/badlogic/gdx/Game.java
gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java

index a02f35b..47f6d25 100644 (file)
@@ -58,7 +58,7 @@ final class AndroidFiles implements Files {
                try {\r
                        in = new FileInputStream(sdcard + fileName);\r
                } catch (FileNotFoundException ex) {\r
-                       throw new GdxRuntimeException("Couldn't open file '" + fileName + "'", ex);\r
+                       throw new GdxRuntimeException("File not found: " + fileName + " (" + FileType.External + ")", ex);\r
                }\r
 \r
                return in;\r
@@ -69,7 +69,7 @@ final class AndroidFiles implements Files {
                try {\r
                        in = assets.open(fileName);\r
                } catch (Exception ex) {\r
-                       throw new GdxRuntimeException("Couldn't load file '" + fileName + "'", ex);\r
+                       throw new GdxRuntimeException("Unable to read file: " + fileName + " (" + FileType.Internal + ")", ex);\r
                }\r
 \r
                return in;\r
@@ -81,19 +81,19 @@ final class AndroidFiles implements Files {
                try {\r
                        out = new FileOutputStream(sdcard + filename);\r
                } catch (FileNotFoundException ex) {\r
-                       throw new GdxRuntimeException("Couldn't open file '" + filename + "'", ex);\r
+                       throw new GdxRuntimeException("File not found: " + filename + " (" + FileType.External + ")", ex);\r
                }\r
 \r
                return out;\r
        }\r
 \r
-       private InputStream readAbsolutFile (String filename) {\r
+       private InputStream readAbsoluteFile (String filename) {\r
                FileInputStream in = null;\r
 \r
                try {\r
                        in = new FileInputStream(filename);\r
                } catch (FileNotFoundException ex) {\r
-                       throw new GdxRuntimeException("Couldn't open file '" + filename + "'", ex);\r
+                       throw new GdxRuntimeException("File not found: " + filename + " (" + FileType.Absolute + ")", ex);\r
                }\r
 \r
                return in;\r
@@ -114,19 +114,19 @@ final class AndroidFiles implements Files {
                        }\r
 \r
                        if (!exists)\r
-                               throw new GdxRuntimeException("Couldn't open file '" + filename + "'");\r
+                               throw new GdxRuntimeException("File not found: " + filename + " (" + type + ")");\r
                        else\r
                                return new AndroidFileHandle(assets, filename);\r
                }\r
 \r
                if (type == FileType.External) {\r
                        if (new File(sdcard + filename).exists() == false)\r
-                               throw new GdxRuntimeException("Couldn't open file '" + filename + "'");\r
+                               throw new GdxRuntimeException("File not found: " + filename + " (" + type + ")");\r
                        else\r
                                return new AndroidFileHandle(null, sdcard + filename);\r
                } else {\r
                        if (new File(filename).exists() == false)\r
-                               throw new GdxRuntimeException("Couldn't open file '" + filename + "'");\r
+                               throw new GdxRuntimeException("File not found: " + filename + " (" + type + ")");\r
                        else\r
                                return new AndroidFileHandle(null, filename);\r
                }\r
@@ -140,18 +140,18 @@ final class AndroidFiles implements Files {
                        try {\r
                                return assets.list(directory);\r
                        } catch (Exception ex) {\r
-                               throw new GdxRuntimeException("Couldn't open directory '" + directory + "'");\r
+                               throw new GdxRuntimeException("Unable to open directory: " + directory);\r
                        }\r
                }\r
 \r
                if (type == FileType.External) {\r
                        if (new File(sdcard + directory).exists() == false)\r
-                               throw new GdxRuntimeException("Couldn't open directory '" + directory + "'");\r
+                               throw new GdxRuntimeException("Unable to open directory: " + directory);\r
                        else\r
                                return new File(sdcard + directory).list();\r
                } else {\r
                        if (new File(directory).exists() == false)\r
-                               throw new GdxRuntimeException("Couldn't open directory '" + directory + "'");\r
+                               throw new GdxRuntimeException("Unable to open directory: " + directory);\r
                        else\r
                                return new File(directory).list();\r
                }\r
@@ -177,7 +177,7 @@ final class AndroidFiles implements Files {
                if (type == FileType.External)\r
                        return readExternalFile(fileName);\r
                else\r
-                       return readAbsolutFile(fileName);\r
+                       return readAbsoluteFile(fileName);\r
        }\r
 \r
        /**\r
@@ -193,7 +193,7 @@ final class AndroidFiles implements Files {
                        try {\r
                                out = new FileOutputStream(filename);\r
                        } catch (FileNotFoundException ex) {\r
-                               throw new GdxRuntimeException("Couldn't open file '" + filename + "'", ex);\r
+                               throw new GdxRuntimeException("File not found: " + filename + " (" + type + ")", ex);\r
                        }\r
 \r
                        return out;\r
index 281161c..9d5178d 100644 (file)
@@ -39,7 +39,7 @@ final class JoglFiles implements Files {
                File file = new File(fileName);\r
 \r
                if (JoglFileHandle.class.getResource("/" + fileName) == null && file.exists() == false)\r
-                       throw new GdxRuntimeException("File '" + fileName + "' doesn't exist");\r
+                       throw new GdxRuntimeException("File not found: " + fileName + " (" + type + ")");\r
                else\r
                        return new JoglFileHandle(file, type);\r
        }\r
@@ -48,7 +48,7 @@ final class JoglFiles implements Files {
                if (type == FileType.External) directory = this.externalPath + directory;\r
                File file = new File(directory);\r
 \r
-               if (file.exists() == false) throw new GdxRuntimeException("Directory '" + directory + "' does not exist");\r
+               if (file.exists() == false) throw new GdxRuntimeException("Directory not found: " + directory + " (" + type + ")");\r
 \r
                return file.list();\r
        }\r
@@ -79,19 +79,19 @@ final class JoglFiles implements Files {
                }\r
        }\r
 \r
-       public OutputStream writeFile (String filename, FileType type) {\r
+       public OutputStream writeFile (String fileName, FileType type) {\r
                if (type == FileType.Internal) return null;\r
 \r
                File file = null;\r
                if (type == FileType.Absolute)\r
-                       file = new File(filename);\r
+                       file = new File(fileName);\r
                else\r
-                       file = new File(this.externalPath + filename);\r
+                       file = new File(this.externalPath + fileName);\r
 \r
                try {\r
                        return new FileOutputStream(file);\r
                } catch (FileNotFoundException e) {\r
-                       throw new GdxRuntimeException("File '" + file + "' does not exist");\r
+                       throw new GdxRuntimeException("File not found: " + fileName + " (" + type + ")");\r
                }\r
        }\r
 }\r
index 49d52b0..3801412 100644 (file)
@@ -40,7 +40,7 @@ final class LwjglFiles implements Files {
                File file = new File(fileName);\r
 \r
                if (LwjglFileHandle.class.getResource("/" + fileName) == null && file.exists() == false)\r
-                       throw new GdxRuntimeException("File '" + fileName + "' doesn't exist");\r
+                       throw new GdxRuntimeException("File not found: " + fileName + " (" + type + ")");\r
                else\r
                        return new LwjglFileHandle(file, type);\r
        }\r
@@ -49,7 +49,7 @@ final class LwjglFiles implements Files {
                if (type == FileType.External) directory = this.externalPath + directory;\r
                File file = new File(directory);\r
 \r
-               if (file.exists() == false) throw new GdxRuntimeException("Directory '" + directory + "' does not exist");\r
+               if (file.exists() == false) throw new GdxRuntimeException("Directory not found: " + directory + " (" + type + ")");\r
 \r
                return file.list();\r
        }\r
@@ -80,19 +80,19 @@ final class LwjglFiles implements Files {
                }\r
        }\r
 \r
-       public OutputStream writeFile (String filename, FileType type) {\r
+       public OutputStream writeFile (String fileName, FileType type) {\r
                if (type == FileType.Internal) return null;\r
 \r
                File file = null;\r
                if (type == FileType.Absolute)\r
-                       file = new File(filename);\r
+                       file = new File(fileName);\r
                else\r
-                       file = new File(this.externalPath + filename);\r
+                       file = new File(this.externalPath + fileName);\r
 \r
                try {\r
                        return new FileOutputStream(file);\r
                } catch (FileNotFoundException e) {\r
-                       throw new GdxRuntimeException("File '" + file + "' does not exist");\r
+                       throw new GdxRuntimeException("File not found: " + fileName + " (" + type + ")");\r
                }\r
        }\r
 }\r
index b36098e..52c1338 100644 (file)
@@ -132,7 +132,7 @@ final class LwjglGraphics implements Graphics {
        public Texture newUnmanagedTexture (int width, int height, Pixmap.Format format, TextureFilter minFilter,\r
                TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {\r
                if (!MathUtils.isPowerOfTwo(width) || !MathUtils.isPowerOfTwo(height))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two");\r
+                       throw new GdxRuntimeException("Texture dimensions must be a power of two: " + width + "x" + height);\r
 \r
                if (format == Format.Alpha)\r
                        return new LwjglTexture(width, height, BufferedImage.TYPE_BYTE_GRAY, minFilter, magFilter, uWrap, vWrap, false);\r
@@ -143,7 +143,7 @@ final class LwjglGraphics implements Graphics {
        public Texture newUnmanagedTexture (Pixmap pixmap, TextureFilter minFilter, TextureFilter magFilter, TextureWrap uWrap,\r
                TextureWrap vWrap) {\r
                if (!MathUtils.isPowerOfTwo(pixmap.getHeight()) || !MathUtils.isPowerOfTwo(pixmap.getWidth()))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two");\r
+                       throw new GdxRuntimeException("Texture dimensions must be a power of two: " + width + "x" + height);\r
 \r
                return new LwjglTexture((BufferedImage)pixmap.getNativePixmap(), minFilter, magFilter, uWrap, vWrap, false);\r
        }\r
@@ -152,7 +152,8 @@ final class LwjglGraphics implements Graphics {
                TextureWrap vWrap) {\r
                Pixmap pixmap = newPixmap(file);\r
                if (!MathUtils.isPowerOfTwo(pixmap.getHeight()) || !MathUtils.isPowerOfTwo(pixmap.getWidth()))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two: " + file);\r
+                       throw new GdxRuntimeException("Texture dimensions must be a power of two: " + file + " (" + pixmap.getWidth() + "x"\r
+                               + pixmap.getHeight() + ")");\r
 \r
                return new LwjglTexture(file, minFilter, magFilter, uWrap, vWrap, false);\r
        }\r
index e3e25c1..683dfaf 100644 (file)
@@ -38,6 +38,7 @@ public abstract class Game implements ApplicationListener {
                if (this.screen != null) this.screen.hide();\r
                this.screen = screen;\r
                screen.show();\r
+               screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
        }\r
 \r
        public Screen getScreen () {\r
index 30d47ee..44efffc 100644 (file)
@@ -113,9 +113,6 @@ public class SpriteBatch {
        protected float invTexWidth = 0;\r
        protected float invTexHeight = 0;\r
 \r
-       /** whether to use the blend mode for text or for sprites **/\r
-       protected boolean useTextBlend = false;\r
-\r
        /** blend function src & target **/\r
        private int blendSrcFunc = GL11.GL_SRC_ALPHA;\r
        private int blendDstFunc = GL11.GL_ONE_MINUS_SRC_ALPHA;\r
@@ -301,8 +298,6 @@ public class SpriteBatch {
                        invTexHeight = 1.0f / texture.getHeight();\r
                }\r
 \r
-               useTextBlend = false;\r
-\r
                // bottom left and top right corner points relative to origin\r
                final float worldOriginX = x + originX;\r
                final float worldOriginY = y + originY;\r
@@ -453,8 +448,6 @@ public class SpriteBatch {
                        invTexHeight = 1.0f / texture.getHeight();\r
                }\r
 \r
-               useTextBlend = false;\r
-\r
                float u = srcX * invTexWidth;\r
                float v = (srcY + srcHeight) * invTexHeight;\r
                float u2 = (srcX + srcWidth) * invTexWidth;\r
@@ -527,8 +520,6 @@ public class SpriteBatch {
                        invTexHeight = 1.0f / texture.getHeight();\r
                }\r
 \r
-               useTextBlend = false;\r
-\r
                final float u = srcX * invTexWidth;\r
                final float v = (srcY + srcHeight) * invTexHeight;\r
                final float u2 = (srcX + srcWidth) * invTexWidth;\r
@@ -588,8 +579,6 @@ public class SpriteBatch {
                        invTexHeight = 1.0f / texture.getHeight();\r
                }\r
 \r
-               useTextBlend = false;\r
-\r
                final float fx2 = x + srcWidth;\r
                final float fy2 = y + srcHeight;\r
 \r
@@ -630,8 +619,6 @@ public class SpriteBatch {
                        invTexHeight = 1.0f / texture.getHeight();\r
                }\r
 \r
-               useTextBlend = false;\r
-\r
                if (idx + length >= vertices.length) renderMesh();\r
 \r
                System.arraycopy(spriteVertices, offset, vertices, idx, length);\r
@@ -654,11 +641,7 @@ public class SpriteBatch {
                mesh.setVertices(vertices, 0, idx);\r
 \r
                if (Gdx.graphics.isGL20Available()) {\r
-                       if (useTextBlend) {\r
-                               GL20 gl20 = Gdx.gl20;\r
-                               gl20.glBlendFunc(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);\r
-                               gl20.glEnable(GL20.GL_BLEND);\r
-                       } else if (blendingDisabled) {\r
+                       if (blendingDisabled) {\r
                                Gdx.gl20.glDisable(GL20.GL_BLEND);\r
                        } else {\r
                                GL20 gl20 = Gdx.gl20;\r
@@ -668,11 +651,7 @@ public class SpriteBatch {
 \r
                        mesh.render(shader, GL10.GL_TRIANGLES, 0, idx / 20 * 6);\r
                } else {\r
-                       if (useTextBlend) {\r
-                               GL10 gl10 = Gdx.gl10;\r
-                               gl10.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);\r
-                               gl10.glEnable(GL10.GL_BLEND);\r
-                       } else if (blendingDisabled) {\r
+                       if (blendingDisabled) {\r
                                Gdx.gl10.glDisable(GL10.GL_BLEND);\r
                        } else {\r
                                GL10 gl10 = Gdx.gl10;\r
@@ -701,8 +680,7 @@ public class SpriteBatch {
        }\r
 \r
        /**\r
-        * Sets the blending function to be used when rendering sprites. This will have no effect on the blend function used for text\r
-        * rendering!\r
+        * Sets the blending function to be used when rendering sprites.\r
         * \r
         * @param srcFunc the source function, e.g. GL11.GL_SRC_ALPHA\r
         * @param dstFunc the destination function, e.g. GL11.GL_ONE_MINUS_SRC_ALPHA\r