OSDN Git Service

[fixed] issue 70. Added support for Matrix3 uniforms in ShaderProgram.
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 11 Dec 2010 13:50:46 +0000 (13:50 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 11 Dec 2010 13:50:46 +0000 (13:50 +0000)
gdx/src/com/badlogic/gdx/graphics/glutils/ShaderProgram.java

index 1d5335b..eac32ea 100644 (file)
@@ -22,7 +22,7 @@ import java.util.HashMap;
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.graphics.GL20;\r
 import com.badlogic.gdx.graphics.Mesh;\r
-import com.badlogic.gdx.graphics.SpriteBatch;\r
+import com.badlogic.gdx.math.Matrix3;\r
 import com.badlogic.gdx.math.Matrix4;\r
 \r
 /**\r
@@ -422,13 +422,64 @@ public class ShaderProgram {
         *            the matrix\r
         */\r
        public void setUniformMatrix(String name, Matrix4 matrix) {\r
+               setUniformMatrix(name, matrix, false);          \r
+       }\r
+       \r
+       /**\r
+        * Sets the uniform matrix with the given name. Throws an\r
+        * IllegalArgumentException in case it is not called in between a\r
+        * {@link #begin()}/{@link #end()} block.\r
+        * \r
+        * @param name\r
+        *            the name of the uniform\r
+        * @param matrix\r
+        *            the matrix\r
+        * @param transpose\r
+        *                        whether the matrix shouls be transposed\r
+        */\r
+       public void setUniformMatrix(String name, Matrix4 matrix, boolean transpose) {\r
                GL20 gl = Gdx.graphics.getGL20();\r
                checkManaged();\r
                int location = fetchUniformLocation(name);\r
                this.matrix.put(matrix.val);\r
                this.matrix.position(0);\r
-               gl.glUniformMatrix4fv(location, 1, false, this.matrix);\r
+               gl.glUniformMatrix4fv(location, 1, transpose, this.matrix);             \r
+       }\r
+       \r
+       /**\r
+        * Sets the uniform matrix with the given name. Throws an\r
+        * IllegalArgumentException in case it is not called in between a\r
+        * {@link #begin()}/{@link #end()} block.\r
+        * \r
+        * @param name\r
+        *            the name of the uniform\r
+        * @param matrix\r
+        *            the matrix\r
+        */\r
+       public void setUniformMatrix(String name, Matrix3 matrix) {\r
+               setUniformMatrix(name, matrix, false);\r
        }\r
+       \r
+       /**\r
+        * Sets the uniform matrix with the given name. Throws an\r
+        * IllegalArgumentException in case it is not called in between a\r
+        * {@link #begin()}/{@link #end()} block.\r
+        * \r
+        * @param name\r
+        *            the name of the uniform\r
+        * @param matrix\r
+        *            the matrix\r
+        * @param transpose\r
+        *                        whether the uniform matrix should be transposed           \r
+        */\r
+       public void setUniformMatrix(String name, Matrix3 matrix, boolean transpose) {\r
+               GL20 gl = Gdx.graphics.getGL20();\r
+               checkManaged();\r
+               int location = fetchUniformLocation(name);\r
+               this.matrix.put(matrix.getValues());\r
+               this.matrix.position(0);\r
+               gl.glUniformMatrix3fv(location, 1, transpose, this.matrix);             \r
+       }       \r
 \r
        /**\r
         * Sets the vertex attribute with the given name. Throws an\r