OSDN Git Service

Add texture to gwt
authorXoppa <contact@xoppa.nl>
Fri, 13 Sep 2013 20:12:34 +0000 (22:12 +0200)
committerXoppa <contact@xoppa.nl>
Fri, 13 Sep 2013 20:12:34 +0000 (22:12 +0200)
backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/graphics/Texture.java
backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/graphics/glutils/FileTextureData.java
gdx/src/com/badlogic/gdx.gwt.xml

index a4b9eec..db7e3e5 100644 (file)
@@ -29,8 +29,8 @@ import com.badlogic.gdx.utils.BufferUtils;
 import com.badlogic.gdx.utils.Disposable;\r
 import com.badlogic.gdx.utils.GdxRuntimeException;\r
 \r
-public class Texture implements Disposable {\r
-       static IntBuffer buffer = BufferUtils.newIntBuffer(1);\r
+public class Texture extends GLTexture {\r
+       //static IntBuffer buffer = BufferUtils.newIntBuffer(1);\r
 \r
        public enum TextureFilter {\r
                Nearest(GL10.GL_NEAREST), Linear(GL10.GL_LINEAR), MipMap(GL10.GL_LINEAR_MIPMAP_LINEAR), MipMapNearestNearest(\r
@@ -53,7 +53,7 @@ public class Texture implements Disposable {
        }\r
 \r
        public enum TextureWrap {\r
-               ClampToEdge(GL10.GL_CLAMP_TO_EDGE), Repeat(GL10.GL_REPEAT);\r
+               MirroredRepeat(GL20.GL_MIRRORED_REPEAT),ClampToEdge(GL10.GL_CLAMP_TO_EDGE), Repeat(GL10.GL_REPEAT);\r
 \r
                final int glEnum;\r
 \r
@@ -66,11 +66,6 @@ public class Texture implements Disposable {
                }\r
        }\r
 \r
-       TextureFilter minFilter = TextureFilter.Nearest;\r
-       TextureFilter magFilter = TextureFilter.Nearest;\r
-       TextureWrap uWrap = TextureWrap.ClampToEdge;\r
-       TextureWrap vWrap = TextureWrap.ClampToEdge;\r
-       int glHandle;\r
        TextureData data;\r
 \r
        public Texture (String internalPath) {\r
@@ -86,7 +81,7 @@ public class Texture implements Disposable {
        }\r
 \r
        public Texture (FileHandle file, Format format, boolean useMipMaps) {\r
-               create(new FileTextureData(file, null, format, useMipMaps));\r
+               this(createTextureData(file, format, useMipMaps));\r
        }\r
 \r
        public Texture (Pixmap pixmap) {\r
@@ -106,21 +101,10 @@ public class Texture implements Disposable {
        }\r
 \r
        public Texture (TextureData data) {\r
-               create(data);\r
-       }\r
-\r
-       private void create (TextureData data) {\r
-               glHandle = createGLHandle();\r
+               super(GL10.GL_TEXTURE_2D, createGLHandle());\r
                load(data);\r
        }\r
 \r
-       public static int createGLHandle () {\r
-               buffer.position(0);\r
-               buffer.limit(buffer.capacity());\r
-               Gdx.gl.glGenTextures(1, buffer);\r
-               return buffer.get(0);\r
-       }\r
-\r
        public void load (TextureData data) {\r
                this.data = data;\r
                if (data.getType() == TextureDataType.Pixmap) {\r
@@ -183,6 +167,11 @@ public class Texture implements Disposable {
        public int getHeight () {\r
                return data.getHeight();\r
        }\r
+       \r
+       @Override\r
+       public int getDepth() {\r
+               return 0;\r
+       }\r
 \r
        public TextureFilter getMinFilter () {\r
                return minFilter;\r
@@ -267,10 +256,7 @@ public class Texture implements Disposable {
        /** Disposes all resources associated with the texture */\r
        public void dispose () {\r
                if (glHandle == 0) return;\r
-               buffer.clear();\r
-               buffer.put(glHandle);\r
-               buffer.flip();\r
-               Gdx.gl.glDeleteTextures(1, buffer);\r
+               delete();\r
                glHandle = 0;\r
        }\r
 \r
index 4b00bf5..b095893 100644 (file)
@@ -130,7 +130,7 @@ public class FileTextureData implements TextureData {
        }\r
 \r
        @Override\r
-       public void consumeCompressedData () {\r
+       public void consumeCompressedData (int target) {\r
                throw new GdxRuntimeException("This TextureData implementation does not upload data itself");\r
        }\r
 }\r
index 4769e73..aa1cb90 100644 (file)
        <!-- graphics -->               
                <include name="graphics/Camera.java"/>
                <include name="graphics/Color.java"/>
+               <include name="graphics/Cubemap.java"/>
                <include name="graphics/FPSLogger.java"/>
                <include name="graphics/GL10.java"/>
                <include name="graphics/GL11.java"/>
                <include name="graphics/GL20.java"/>
                <include name="graphics/GLCommon.java"/>
+               <include name="graphics/GLTexture.java"/>
                <include name="graphics/Mesh.java"/>
                <include name="graphics/OrthographicCamera.java"/>
                <include name="graphics/PerspectiveCamera.java"/>