OSDN Git Service

NOTE: extensions and lwjgl backend won't compile with this! Temporary commit for...
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Mon, 1 Nov 2010 20:36:12 +0000 (20:36 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Mon, 1 Nov 2010 20:36:12 +0000 (20:36 +0000)
[changed] ApplicationListener and RenderListener have been merged. All events (create, pause, resume, render, destroy) happen on the rendering thread now so you are always guaranteed to have an OpenGL context current.
[changed] InputListener is now called InputProcessor due to the fact that you can't register an InputListener anymore. Use Input.processEvents() instead. Note that if you do not process the events in ApplicationListener.render() they will get lost.
[changed] all freaking tests to work with the new model. gah
[rewrote] jogl backend...
[fixed] a couple of minor bugs. probably also introduced some with the rewritting :p Android ApplicationListener event generation is a bit shacky. Review Nate!
[fixed] build scripts to generate new gdx-backend-jogl.jar. not tested yet. will do in a bit...

133 files changed:
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidApplication.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidInput.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidMultiTouchHandler.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidSingleTouchHandler.java
backends/gdx-backend-desktop/.settings/org.eclipse.jdt.core.prefs [deleted file]
backends/gdx-backend-desktop/LICENSE-2.0.html [deleted file]
backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglApplication.java [deleted file]
backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGraphics.java [deleted file]
backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInput.java [deleted file]
backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInputMultiplexer.java [deleted file]
backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPanel.java [deleted file]
backends/gdx-backend-jogl/.classpath [moved from backends/gdx-backend-desktop/.classpath with 92% similarity]
backends/gdx-backend-jogl/.project [moved from tests/gdx-tests-desktop/.project with 87% similarity]
backends/gdx-backend-jogl/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglApplication.java [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudio.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudio.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioDevice.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioDevice.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioRecorder.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioRecorder.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFileHandle.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFileHandle.java with 94% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFiles.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFiles.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL10.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL10.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL11.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL11.java with 96% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL20.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL20.java with 96% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphics.java [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphicsBase.java [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglInput.java [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglMusic.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglMusic.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglNativesLoader.java [new file with mode: 0644]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglPixmap.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPixmap.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglSound.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglSound.java with 95% similarity]
backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglTexture.java [moved from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglTexture.java with 96% similarity]
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java
backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglInput.java
build.xml
extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java
extensions/hiero/src/com/badlogic/gdx/hiero/unicodefont/UnicodeFontTest.java
extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java
extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/ButtonTest.java
extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java
extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlInputListener.java
gdx/build.xml
gdx/src/com/badlogic/gdx/Application.java
gdx/src/com/badlogic/gdx/ApplicationListener.java
gdx/src/com/badlogic/gdx/Graphics.java
gdx/src/com/badlogic/gdx/Input.java
gdx/src/com/badlogic/gdx/InputAdapter.java
gdx/src/com/badlogic/gdx/InputProcessor.java [moved from gdx/src/com/badlogic/gdx/InputListener.java with 75% similarity]
gdx/src/com/badlogic/gdx/RenderListener.java [deleted file]
gdx/src/com/badlogic/gdx/graphics/Mesh.java
gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java
tests/gdx-tests-android/src/com/badlogic/gdx/tests/android/GdxTestActivity.java
tests/gdx-tests-android/src/com/badlogic/gdx/tests/android/WindowedTest.java
tests/gdx-tests-desktop/.settings/org.eclipse.jdt.core.prefs [deleted file]
tests/gdx-tests-desktop/LICENSE-2.0.html [deleted file]
tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglDebugStarter.java [deleted file]
tests/gdx-tests-jogl/.classpath [moved from tests/gdx-tests-desktop/.classpath with 50% similarity]
tests/gdx-tests-jogl/.project [moved from backends/gdx-backend-desktop/.project with 87% similarity]
tests/gdx-tests-jogl/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
tests/gdx-tests-jogl/data/arial.ttf [moved from tests/gdx-tests-desktop/data/arial.ttf with 100% similarity]
tests/gdx-tests-jogl/data/badlogic.jpg [moved from tests/gdx-tests-desktop/data/badlogic.jpg with 100% similarity]
tests/gdx-tests-jogl/data/badlogicsmall.jpg [moved from tests/gdx-tests-desktop/data/badlogicsmall.jpg with 100% similarity]
tests/gdx-tests-jogl/data/cloudconnected.ogg [moved from tests/gdx-tests-desktop/data/cloudconnected.ogg with 100% similarity]
tests/gdx-tests-jogl/data/cube.gdx3d [moved from tests/gdx-tests-desktop/data/cube.gdx3d with 100% similarity]
tests/gdx-tests-jogl/data/cube.obj [moved from tests/gdx-tests-desktop/data/cube.obj with 100% similarity]
tests/gdx-tests-jogl/data/debug.png [moved from tests/gdx-tests-desktop/data/debug.png with 100% similarity]
tests/gdx-tests-jogl/data/font.fnt [moved from tests/gdx-tests-desktop/data/font.fnt with 100% similarity]
tests/gdx-tests-jogl/data/font.png [moved from tests/gdx-tests-desktop/data/font.png with 100% similarity]
tests/gdx-tests-jogl/data/heavysphere.obj [moved from tests/gdx-tests-desktop/data/heavysphere.obj with 100% similarity]
tests/gdx-tests-jogl/data/particle-cloud.png [moved from tests/gdx-tests-desktop/data/particle-cloud.png with 100% similarity]
tests/gdx-tests-jogl/data/particle-fire.png [moved from tests/gdx-tests-desktop/data/particle-fire.png with 100% similarity]
tests/gdx-tests-jogl/data/particle-star.png [moved from tests/gdx-tests-desktop/data/particle-star.png with 100% similarity]
tests/gdx-tests-jogl/data/particle.png [moved from tests/gdx-tests-desktop/data/particle.png with 100% similarity]
tests/gdx-tests-jogl/data/scene.obj [moved from tests/gdx-tests-desktop/data/scene.obj with 100% similarity]
tests/gdx-tests-jogl/data/scene2.obj [moved from tests/gdx-tests-desktop/data/scene2.obj with 100% similarity]
tests/gdx-tests-jogl/data/shotgun.wav [moved from tests/gdx-tests-desktop/data/shotgun.wav with 100% similarity]
tests/gdx-tests-jogl/data/stones.jpg [moved from tests/gdx-tests-desktop/data/stones.jpg with 100% similarity]
tests/gdx-tests-jogl/data/test.p [moved from tests/gdx-tests-desktop/data/test.p with 100% similarity]
tests/gdx-tests-jogl/data/test.png [moved from tests/gdx-tests-desktop/data/test.png with 100% similarity]
tests/gdx-tests-jogl/data/threeofaperfectpair.mp3 [moved from tests/gdx-tests-desktop/data/threeofaperfectpair.mp3 with 100% similarity]
tests/gdx-tests-jogl/data/ui.png [moved from tests/gdx-tests-desktop/data/ui.png with 100% similarity]
tests/gdx-tests-jogl/data/verdana39.fnt [moved from tests/gdx-tests-desktop/data/verdana39.fnt with 100% similarity]
tests/gdx-tests-jogl/data/verdana39.png [moved from tests/gdx-tests-desktop/data/verdana39.png with 100% similarity]
tests/gdx-tests-jogl/data/villager.png [moved from tests/gdx-tests-desktop/data/villager.png with 100% similarity]
tests/gdx-tests-jogl/data/walk1.md5anim [moved from tests/gdx-tests-desktop/data/walk1.md5anim with 100% similarity]
tests/gdx-tests-jogl/data/zfat.md5mesh [moved from tests/gdx-tests-desktop/data/zfat.md5mesh with 100% similarity]
tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglDebugStarter.java [new file with mode: 0644]
tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglTestStarter.java [moved from tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglTestStarter.java with 81% similarity]
tests/gdx-tests/src/com/badlogic/gdx/tests/AlphaTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/AudioDeviceTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/AudioRecorderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontFlipTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTestCollection.java
tests/gdx-tests/src/com/badlogic/gdx/tests/FillrateTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/FloatTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/FrameBufferTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/ImmediateModeRendererTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectClassTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectShaderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/InputTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/LifeCycleTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/MD5Test.java
tests/gdx-tests/src/com/badlogic/gdx/tests/ManagedTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/ManualBindTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/MeshMultitextureTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/MeshShaderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/MeshTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/Mpg123Test.java
tests/gdx-tests/src/com/badlogic/gdx/tests/MultitouchTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/ObjTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/Pong.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SimpleTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchRotationTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchShaderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/StageTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/TerrainTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/TextureRenderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayClassTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectClassTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectShaderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/VorbisTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/WaterRipples.java
tests/gdx-tests/src/com/badlogic/gdx/tests/box2d/Box2DTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTest.java

index e4d96fe..4e3806b 100644 (file)
@@ -15,6 +15,8 @@ package com.badlogic.gdx.backends.android;
 \r
 import android.app.Activity;\r
 import android.os.Build;\r
+import android.os.Bundle;\r
+import android.os.Handler;\r
 import android.util.Log;\r
 import android.view.View;\r
 import android.view.Window;\r
@@ -34,7 +36,7 @@ import com.badlogic.gdx.graphics.GL11;
 \r
 /**\r
  * An implementation of the {@link Application} interface for Android. Create an {@link Activity} that derives from this class. In\r
- * the {@link Activity.onCreate()} method call the {@link initialize()} method specifying the configuration for the GLSurfaceView.\r
+ * the {@link Activity#onCreate(Bundle)} method call the {@link #initialize(ApplicationListener,boolean)} method specifying the configuration for the GLSurfaceView.\r
  * \r
  * @author mzechner\r
  */\r
@@ -43,96 +45,84 @@ public class AndroidApplication extends Activity implements Application {
        static {\r
                Version.loadLibrary();\r
        }\r
+       \r
+       AndroidGraphics graphics;\r
+       AndroidInput input;\r
+       AndroidAudio audio;     \r
+       AndroidFiles files;\r
+       ApplicationListener listener;\r
+       Handler handler;\r
+       boolean firstResume = true;\r
 \r
        /**\r
-        * the android graphics instance *\r
-        */\r
-       private AndroidGraphics graphics;\r
-\r
-       /**\r
-        * the input instance *\r
-        */\r
-       private AndroidInput input;\r
-\r
-       /**\r
-        * the audio instance *\r
-        */\r
-       private AndroidAudio audio;\r
-\r
-       /**\r
-        * the resources instance *\r
-        */\r
-       private AndroidFiles resources;\r
-\r
-       /**\r
-        * the DestroyListener *\r
-        */\r
-       private ApplicationListener listener;\r
-\r
-       /**\r
-        * This method has to be called in the {@link Activity.onCreate()} method. It sets up all the things necessary to get input,\r
+        * This method has to be called in the {@link Activity#onCreate(Bundle)} method. It sets up all the things necessary to get input,\r
         * render via OpenGL and so on. If useGL20IfAvailable is set the AndroidApplication will try to create an OpenGL ES 2.0 context\r
-        * which can then be used via {@link AndroidApplication.getGraphics().getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
+        * which can then be used via {@link Graphics#getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
         * should not be used when OpenGL ES 2.0 is enabled. To query whether enabling OpenGL ES 2.0 was successful use the {@link\r
-        * AndroidApplication.getGraphics().isGL20Available()} method. Sleep time in touch event handler is 0, so no sleeping is\r
+        * Graphics#isGL20Available()} method. Sleep time in touch event handler is 0, so no sleeping is\r
         * performed.\r
         * \r
+        * @param listener the {@link ApplicationListener} implementing the program logic\r
         * @param useGL2IfAvailable whether to use OpenGL ES 2.0 if its available.\r
         */\r
-       public void initialize (boolean useGL2IfAvailable) {\r
-               initialize(useGL2IfAvailable, 0);\r
+       public void initialize (ApplicationListener listener, boolean useGL2IfAvailable) {\r
+               initialize(listener, useGL2IfAvailable, 0);\r
        }\r
 \r
        /**\r
-        * This method has to be called in the {@link Activity.onCreate()} method. It sets up all the things necessary to get input,\r
+        * This method has to be called in the {@link Activity#onCreate(Bundle)} method. It sets up all the things necessary to get input,\r
         * render via OpenGL and so on. If useGL20IfAvailable is set the AndroidApplication will try to create an OpenGL ES 2.0 context\r
-        * which can then be used via {@link AndroidApplication.getGraphics().getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
+        * which can then be used via {@link Graphics#getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
         * should not be used when OpenGL ES 2.0 is enabled. To query whether enabling OpenGL ES 2.0 was successful use the {@link\r
-        * AndroidApplication.getGraphics().isGL20Available()} method. sleepTime specifies the number of milliseconds to sleep in the\r
+        * Graphics#isGL20Available()} method. sleepTime specifies the number of milliseconds to sleep in the\r
         * touch event handler. This may be used on <= 1.6 Android devices. Note that it will not solve the CPU usage problem of the\r
         * event handler of the Android system. Things will still slow down.\r
         * \r
+        * @param listener the {@link ApplicationListener} implementing the program logic\r
         * @param useGL2IfAvailable whether to use OpenGL ES 2.0 if its available.\r
         * @param sleepTime specifies the number of milliseconds to sleep in the touch event handler\r
         */\r
-       public void initialize (boolean useGL2IfAvailable, int sleepTime) {\r
-               requestWindowFeature(Window.FEATURE_NO_TITLE);\r
-               getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);\r
-               graphics = new AndroidGraphics(this, useGL2IfAvailable);\r
-               setContentView(graphics.getView());\r
-               input = new AndroidInput(this, graphics.view, sleepTime);\r
-               graphics.setInput(input);\r
+       public void initialize (ApplicationListener listener, boolean useGL2IfAvailable, int sleepTime) {                               \r
+               graphics = new AndroidGraphics(this, useGL2IfAvailable);                \r
+               input = new AndroidInput(this, graphics.view, sleepTime);               \r
                audio = new AndroidAudio(this);\r
-               resources = new AndroidFiles(this.getAssets());\r
+               files = new AndroidFiles(this.getAssets());\r
+               this.listener = listener;\r
+               this.handler = new Handler();\r
 \r
                Gdx.app = this;\r
                Gdx.input = this.getInput();\r
                Gdx.audio = this.getAudio();\r
                Gdx.files = this.getFiles();\r
                Gdx.graphics = this.getGraphics();\r
+               \r
+               \r
+               requestWindowFeature(Window.FEATURE_NO_TITLE);\r
+               getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);\r
+               setContentView(graphics.getView());\r
        }\r
 \r
        /**\r
-        * This method has to be called in the {@link Activity.onCreate()} method. It sets up all the things necessary to get input,\r
+        * This method has to be called in the {@link Activity#onCreate(Bundle)} method. It sets up all the things necessary to get input,\r
         * render via OpenGL and so on. If useGL20IfAvailable is set the AndroidApplication will try to create an OpenGL ES 2.0 context\r
-        * which can then be used via {@link AndroidApplication.getGraphics().getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
+        * which can then be used via {@link Graphics#getGL20()}. The {@link GL10} and {@link GL11} interfaces\r
         * should not be used when OpenGL ES 2.0 is enabled. To query whether enabling OpenGL ES 2.0 was successful use the {@link\r
-        * AndroidApplication.getGraphics().isGL20Available()} method. sleepTime specifies the number of milliseconds to sleep in the\r
+        * Graphics#isGL20Available()} method. sleepTime specifies the number of milliseconds to sleep in the\r
         * touch event handler. This may be used on <= 1.6 Android devices. Note that it will not solve the CPU usage problem of the\r
         * event handler of the Android system. Things will still slow down.\r
         * \r
         * Note: you have to add the returned view to your layout!\r
         * \r
+        * @param listener the {@link ApplicationListener} implementing the program logic\r
         * @param useGL2IfAvailable whether to use OpenGL ES 2.0 if its available.\r
         * @param sleepTime specifies the number of milliseconds to sleep in the touch event handler\r
         * @return the GLSurfaceView of the application\r
         */\r
-       public View initializeForView (boolean useGL2IfAvailable, int sleepTime) {\r
+       public View initializeForView (ApplicationListener listener, boolean useGL2IfAvailable, int sleepTime) {\r
                graphics = new AndroidGraphics(this, useGL2IfAvailable);\r
-               input = new AndroidInput(this, graphics.view, sleepTime);\r
-               graphics.setInput(input);\r
+               input = new AndroidInput(this, graphics.view, sleepTime);               \r
                audio = new AndroidAudio(this);\r
-               resources = new AndroidFiles(this.getAssets());\r
+               files = new AndroidFiles(this.getAssets());\r
 \r
                Gdx.app = this;\r
                Gdx.input = this.getInput();\r
@@ -143,12 +133,14 @@ public class AndroidApplication extends Activity implements Application {
                return graphics.getView();\r
        }\r
 \r
-       @Override protected void onPause () {\r
-               super.onPause();\r
-\r
-               if (isFinishing()) {\r
-                       graphics.disposeRenderListener();\r
+       @Override protected void onPause () {   \r
+               Log.d("Test", "activity pause");\r
+               graphics.pause();               \r
+               \r
+               if (isFinishing()) {                    \r
+                       Log.d("Test", "activity destroyed");\r
                        graphics.clearManagedCaches();\r
+                       graphics.destroy();\r
                }\r
 \r
                if (graphics != null && graphics.view != null) {\r
@@ -156,36 +148,35 @@ public class AndroidApplication extends Activity implements Application {
                        if (graphics.view instanceof android.opengl.GLSurfaceView) ((android.opengl.GLSurfaceView)graphics.view).onPause();\r
                }\r
 \r
-               if (audio != null) audio.pause();\r
-\r
-               if (listener != null) listener.pause();\r
+               if (audio != null) audio.pause();       \r
+               super.onPause();        \r
        }\r
 \r
-       @Override protected void onResume () {\r
-               super.onResume();\r
-\r
+       @Override protected void onResume () {          \r
                Gdx.app = this;\r
                Gdx.input = this.getInput();\r
                Gdx.audio = this.getAudio();\r
                Gdx.files = this.getFiles();\r
-               Gdx.graphics = this.getGraphics();\r
-\r
-               if (listener != null) listener.resume();\r
+               Gdx.graphics = this.getGraphics();              \r
 \r
                if (graphics != null && graphics.view != null) {\r
                        if (graphics.view instanceof GLSurfaceViewCupcake) ((GLSurfaceViewCupcake)graphics.view).onResume();\r
                        if (graphics.view instanceof android.opengl.GLSurfaceView) ((android.opengl.GLSurfaceView)graphics.view).onResume();\r
-               }\r
+               }                       \r
 \r
                if (audio != null) audio.resume();\r
+               Log.d("Test", "activity resume");\r
+               if(!firstResume)\r
+                       graphics.resume();\r
+               else\r
+                       firstResume=false;\r
+               super.onResume();\r
        }\r
 \r
        @Override protected void onDestroy () {\r
-               super.onDestroy();\r
-\r
-               if (listener != null) listener.destroy();\r
-\r
+//             graphics.destroy();\r
                audio.dispose();\r
+               super.onDestroy();\r
        }\r
 \r
        /**\r
@@ -199,7 +190,7 @@ public class AndroidApplication extends Activity implements Application {
         * {@inheritDoc}\r
         */\r
        @Override public Files getFiles () {\r
-               return resources;\r
+               return files;\r
        }\r
 \r
        /**\r
@@ -219,13 +210,6 @@ public class AndroidApplication extends Activity implements Application {
        /**\r
         * {@inheritDoc}\r
         */\r
-       @Override public void setApplicationListener (ApplicationListener listener) {\r
-               this.listener = listener;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
        @Override public void log (String tag, String message) {\r
                Log.d(tag, message);\r
        }\r
index 63e5f9f..b230a7e 100644 (file)
@@ -25,12 +25,12 @@ import android.app.Activity;
 import android.graphics.Bitmap;\r
 import android.graphics.BitmapFactory;\r
 import android.opengl.GLSurfaceView.Renderer;\r
+import android.util.Log;\r
 import android.view.Display;\r
 import android.view.View;\r
 \r
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.Graphics;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.backends.android.surfaceview.GLSurfaceView20;\r
 import com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake;\r
 import com.badlogic.gdx.files.FileHandle;\r
@@ -55,87 +55,28 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
  * @author mzechner\r
  */\r
 final class AndroidGraphics implements Graphics, Renderer {\r
-       /**\r
-        * the gl surfaceview *\r
-        */\r
-       protected final View view;\r
-\r
-       /**\r
-        * the android input we have to call *\r
-        */\r
-       private AndroidInput input;\r
-\r
-       /**\r
-        * the render listener *\r
-        */\r
-       protected RenderListener listener;\r
-\r
-       /**\r
-        * width & height of the surface *\r
-        */\r
-       protected int width;\r
-       protected int height;\r
-\r
-       /**\r
-        * the app *\r
-        */\r
-       protected AndroidApplication app;\r
-\r
-       /**\r
-        * Common instance\r
-        */\r
-       protected GLCommon gl;\r
-\r
-       /**\r
-        * the GL10 instance *\r
-        */\r
-       protected GL10 gl10;\r
-\r
-       /**\r
-        * the GL11 instance *\r
-        */\r
-       protected GL11 gl11;\r
-\r
-       /**\r
-        * the GL20 instance *\r
-        */\r
-       protected GL20 gl20;\r
-\r
-       /**\r
-        * the last frame time *\r
-        */\r
-       private long lastFrameTime = System.nanoTime();\r
-\r
-       /**\r
-        * the deltaTime *\r
-        */\r
-       private float deltaTime = 0;\r
-\r
-       /**\r
-        * frame start time *\r
-        */\r
+       final View view;\r
+       int width;\r
+       int height;\r
+       AndroidApplication app;\r
+       GLCommon gl;\r
+       GL10 gl10;\r
+       GL11 gl11;\r
+       GL20 gl20;\r
+       \r
+       private long lastFrameTime = System.nanoTime(); \r
+       private float deltaTime = 0;    \r
        private long frameStart = System.nanoTime();\r
-\r
-       /**\r
-        * frame counter *\r
-        */\r
-       private int frames = 0;\r
-\r
-       /**\r
-        * last fps *\r
-        */\r
-       private int fps;\r
-\r
-       /**\r
-        * the deltaTime mean *\r
-        */\r
-       private WindowedMean mean = new WindowedMean(5);\r
-\r
-       /**\r
-        * whether to dispose the render listeners *\r
-        */\r
-       private boolean dispose = false;\r
-\r
+       private int frames = 0; \r
+       private int fps;        \r
+       private WindowedMean mean = new WindowedMean(5);                \r
+\r
+       boolean created = false;\r
+       boolean running = false;\r
+       boolean pause = false;\r
+       boolean resume = false;\r
+       boolean destroy = false;        \r
+       \r
        public AndroidGraphics (AndroidApplication activity, boolean useGL2IfAvailable) {\r
                view = createGLSurfaceView(activity, useGL2IfAvailable);\r
                this.app = activity;\r
@@ -160,15 +101,6 @@ final class AndroidGraphics implements Graphics, Renderer {
 \r
        }\r
 \r
-       /**\r
-        * This is a hack...\r
-        * \r
-        * @param input\r
-        */\r
-       protected void setInput (AndroidInput input) {\r
-               this.input = input;\r
-       }\r
-\r
        private boolean checkGL20 () {\r
                EGL10 egl = (EGL10)EGLContext.getEGL();\r
                EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);\r
@@ -271,43 +203,6 @@ final class AndroidGraphics implements Graphics, Renderer {
        }\r
 \r
        /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public void setRenderListener (RenderListener listener) {\r
-               synchronized (this) {\r
-                       if (this.listener != null) this.listener.dispose();\r
-                       this.listener = listener;\r
-               }\r
-       }\r
-\r
-       @Override public void onDrawFrame (javax.microedition.khronos.opengles.GL10 gl) {\r
-               // calculate delta time\r
-               deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;\r
-               lastFrameTime = System.nanoTime();\r
-               mean.addValue(deltaTime);\r
-\r
-               // this is a hack so the events get processed synchronously.\r
-               if (input != null) input.update();\r
-\r
-               synchronized (this) {\r
-                       if (listener != null) listener.render();\r
-               }\r
-\r
-               if (dispose) {\r
-                       if (listener != null) listener.dispose();\r
-                       listener = null;\r
-                       dispose = false;\r
-               }\r
-\r
-               if (System.nanoTime() - frameStart > 1000000000) {\r
-                       fps = frames;\r
-                       frames = 0;\r
-                       frameStart = System.nanoTime();\r
-               }\r
-               frames++;\r
-       }\r
-\r
-       /**\r
         * This instantiates the GL10, GL11 and GL20 instances. Includes the check for certain devices that pretend to support GL11 but\r
         * fuck up vertex buffer objects. This includes the pixelflinger which segfaults when buffers are deleted as well as the\r
         * Motorola CLIQ and the Samsung Behold II.\r
@@ -342,9 +237,7 @@ final class AndroidGraphics implements Graphics, Renderer {
 \r
        @Override public void onSurfaceChanged (javax.microedition.khronos.opengles.GL10 gl, int width, int height) {\r
                this.width = width;\r
-               this.height = height;\r
-\r
-               if (listener != null) listener.surfaceChanged(width, height);\r
+               this.height = height;           \r
        }\r
 \r
        @Override public void onSurfaceCreated (javax.microedition.khronos.opengles.GL10 gl, EGLConfig config) {\r
@@ -357,14 +250,93 @@ final class AndroidGraphics implements Graphics, Renderer {
 \r
                Display display = app.getWindowManager().getDefaultDisplay();\r
                this.width = display.getWidth();\r
-               this.height = display.getHeight();\r
-\r
-               if (listener != null) listener.surfaceCreated();\r
+               this.height = display.getHeight();              \r
                mean = new WindowedMean(5);\r
                this.lastFrameTime = System.nanoTime();\r
 \r
                gl.glViewport(0, 0, this.width, this.height);\r
+               \r
+               if( created == false ) {\r
+                       app.listener.create();\r
+                       created = true;\r
+                       synchronized(this) {\r
+                               running = true;\r
+                       }\r
+               }\r
+       }\r
+       \r
+       Object synch = new Object();    \r
+       void resume () {\r
+               synchronized(synch) {\r
+                       running = false;\r
+                       resume = true;\r
+               }\r
+       }\r
+       \r
+       void pause () {\r
+               synchronized(synch) {\r
+                       running = false;        \r
+                       pause = true;\r
+               }\r
+               boolean cond = false;\r
+               while(!cond) {\r
+                       synchronized(synch) {\r
+                               cond = !pause;\r
+                       }\r
+               }\r
+       }\r
+       \r
+       void destroy () {\r
+               synchronized(synch) {\r
+                       running = false;\r
+                       destroy = true;\r
+               }\r
+               boolean cond = false;\r
+               while(!cond) {\r
+                       synchronized(synch) {\r
+                               cond = !destroy;\r
+                       }\r
+               }\r
        }\r
+       \r
+       @Override public void onDrawFrame (javax.microedition.khronos.opengles.GL10 gl) {\r
+               deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;\r
+               lastFrameTime = System.nanoTime();\r
+               mean.addValue(deltaTime);                       \r
+\r
+               synchronized(synch) {\r
+                       if(running) {\r
+                               app.listener.render();\r
+                       }\r
+                               \r
+                       if(pause) {\r
+                               app.listener.pause();\r
+                               pause = false;          \r
+                       }\r
+                       \r
+                       if(resume) {\r
+                               app.listener.resume();\r
+                               resume = false;\r
+                               running = true;\r
+                       }\r
+                       \r
+                       if(destroy) {                   \r
+                               app.listener.destroy();\r
+                               destroy = false;\r
+                       }\r
+               }\r
+               \r
+               Gdx.input.processEvents(null);\r
+               \r
+               if (System.nanoTime() - frameStart > 1000000000) {\r
+                       fps = frames;\r
+                       frames = 0;\r
+                       frameStart = System.nanoTime();\r
+               }\r
+               frames++;\r
+       }\r
+       \r
+       \r
 \r
        /**\r
         * {@inheritDoc}\r
@@ -373,16 +345,6 @@ final class AndroidGraphics implements Graphics, Renderer {
                return mean.getMean() == 0 ? deltaTime : mean.getMean();\r
        }\r
 \r
-       public void disposeRenderListener () {\r
-               dispose = true;\r
-               while (dispose) {\r
-                       try {\r
-                               Thread.sleep(20);\r
-                       } catch (InterruptedException e) {\r
-                       }\r
-               }\r
-       }\r
-\r
        /**\r
         * {@inheritDoc}\r
         */\r
@@ -429,11 +391,8 @@ final class AndroidGraphics implements Graphics, Renderer {
                ShaderProgram.clearAllShaderPrograms();\r
                FrameBuffer.clearAllFrameBuffers();             \r
        }\r
-\r
-       /**\r
-        * @return the GLSurfaceView\r
-        */\r
-       public View getView () {\r
+       \r
+       View getView () {\r
                return view;\r
        }\r
 \r
@@ -443,5 +402,4 @@ final class AndroidGraphics implements Graphics, Renderer {
        @Override public GLCommon getGLCommon () {\r
                return gl;\r
        }\r
-\r
 }\r
index 9232f01..6b8d4c3 100644 (file)
@@ -15,6 +15,7 @@ package com.badlogic.gdx.backends.android;
 \r
 import java.util.ArrayList;\r
 import java.util.HashSet;\r
+import java.util.List;\r
 \r
 import android.app.AlertDialog;\r
 import android.content.Context;\r
@@ -24,7 +25,6 @@ import android.hardware.SensorEvent;
 import android.hardware.SensorEventListener;\r
 import android.hardware.SensorManager;\r
 import android.os.Handler;\r
-import android.view.KeyEvent;\r
 import android.view.MotionEvent;\r
 import android.view.View;\r
 import android.view.View.OnKeyListener;\r
@@ -33,7 +33,9 @@ import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;\r
 \r
 import com.badlogic.gdx.Input;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
+import com.badlogic.gdx.utils.Pool;\r
+import com.badlogic.gdx.utils.Pool.PoolObjectFactory;\r
 \r
 /**\r
  * An implementation of the {@link Input} interface for Android.\r
@@ -41,96 +43,66 @@ import com.badlogic.gdx.InputListener;
  * @author mzechner\r
  * \r
  */\r
-final class AndroidInput implements Input, OnKeyListener, OnTouchListener, SensorEventListener {\r
-       /** touch coordinates in x, package private for touch handlers **/\r
-       int[] touchX = new int[10];\r
+final class AndroidInput implements Input, OnKeyListener, OnTouchListener,\r
+               SensorEventListener {\r
+       class KeyEvent {\r
+               static final int KEY_DOWN = 0;\r
+               static final int KEY_UP = 1;\r
+               static final int KEY_TYPED = 2;\r
+\r
+               int type;\r
+               int keyCode;\r
+               char keyChar;\r
+       }\r
 \r
-       /** touch coordinates in y, package private for touch handlers **/\r
-       int[] touchY = new int[10];\r
+       class TouchEvent {\r
+               static final int TOUCH_DOWN = 0;\r
+               static final int TOUCH_UP = 1;\r
+               static final int TOUCH_DRAGGED = 2;\r
 \r
-       /** touch state, package private for touch handlers **/\r
-       boolean[] touched = new boolean[10];\r
+               int type;\r
+               int x;\r
+               int y;\r
+               int pointer;\r
+       }\r
 \r
-       /** key state **/\r
-       private HashSet<Integer> keys = new HashSet<Integer>();\r
+       Pool<KeyEvent> freeKeyEvents = new Pool<KeyEvent>(\r
+                       new PoolObjectFactory<KeyEvent>() {\r
 \r
-       /** whether the accelerometer is available **/\r
-       public boolean accelerometerAvailable = false;\r
+                               @Override\r
+                               public KeyEvent createObject() {\r
+                                       return new KeyEvent();\r
+                               }\r
+                       }, 1000);\r
 \r
-       /** the sensor manager **/\r
-       private SensorManager manager;\r
+       Pool<TouchEvent> freeTouchEvents = new Pool<TouchEvent>(\r
+                       new PoolObjectFactory<TouchEvent>() {\r
 \r
-       /** the accelerometer values **/\r
-       private final float[] accelerometerValues = new float[3];\r
+                               @Override\r
+                               public TouchEvent createObject() {\r
+                                       return new TouchEvent();\r
+                               }\r
+                       }, 1000);\r
 \r
-       /** user input text **/\r
+       List<KeyEvent> keyEvents = new ArrayList<KeyEvent>();\r
+       List<TouchEvent> touchEvents = new ArrayList<TouchEvent>();\r
+       int[] touchX = new int[10];\r
+       int[] touchY = new int[10];\r
+       boolean[] touched = new boolean[10];\r
+       final boolean hasMultitouch;\r
+       private HashSet<Integer> keys = new HashSet<Integer>();\r
+       private SensorManager manager;\r
+       public boolean accelerometerAvailable = false;\r
+       private final float[] accelerometerValues = new float[3];\r
        private String text = null;\r
-\r
-       /** the last user input text listener **/\r
        private TextInputListener textListener = null;\r
-\r
-       /** a nice handler **/\r
        private Handler handle;\r
-\r
-       /** array of input listeners **/\r
-       private final ArrayList<InputListener> inputListeners = new ArrayList<InputListener>();\r
-\r
-       /** the app **/\r
        private final AndroidApplication app;\r
-\r
-       /** the touch handler **/\r
        private final AndroidTouchHandler touchHandler;\r
-\r
-       /** touch handler sleep time in milliseconds **/\r
        private int sleepTime = 0;\r
-       \r
-       /** what system keys to catch **/       \r
-       private boolean catchBack = false;      \r
-\r
-       /**\r
-        * helper enum\r
-        * @author mzechner\r
-        * \r
-        */\r
-       static enum EventType {\r
-               MouseDown, MouseUp, MouseMoved, MouseDragged, KeyDown, KeyUp, KeyTyped\r
-       }\r
-\r
-       /**\r
-        * Helper class\r
-        * @author mzechner\r
-        * \r
-        */\r
-       static class Event {\r
-               public int x, y;\r
-               public int pointer;\r
-               public int keycode;\r
-               public char keychar;\r
-               public EventType type;\r
-\r
-               public void set (EventType type, int x, int y, int pointer, int keycode, char keychar) {\r
-                       this.type = type;\r
-                       this.x = x;\r
-                       this.y = y;\r
-                       this.pointer = pointer;\r
-                       this.keycode = keycode;\r
-                       this.keychar = keychar;\r
-               }\r
-       }\r
-\r
-       /** queue of events to be processed, package private for touch handlers **/\r
-       final ArrayList<Event> eventQueue = new ArrayList<Event>();\r
-\r
-       /** pool of free Event instances, package private for touch handlers **/\r
-       final ArrayList<Event> freeEvents = new ArrayList<Event>();\r
+       private boolean catchBack = false;\r
 \r
-       /** index to the next free event, package private for touch handlers **/\r
-       int freeEventIndex = 0;\r
-\r
-       /** whether multitouch is supported or not **/\r
-       final boolean hasMultitouch;\r
-\r
-       AndroidInput (AndroidApplication activity, View view, int sleepTime) {\r
+       AndroidInput(AndroidApplication activity, View view, int sleepTime) {\r
                view.setOnKeyListener(this);\r
                view.setOnTouchListener(this);\r
                view.setFocusable(true);\r
@@ -138,136 +110,105 @@ final class AndroidInput implements Input, OnKeyListener, OnTouchListener, Senso
                view.requestFocus();\r
                view.requestFocusFromTouch();\r
 \r
-               manager = (SensorManager)activity.getSystemService(Context.SENSOR_SERVICE);\r
-               if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() == 0)\r
+               manager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);\r
+               if (manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size() == 0) {\r
                        accelerometerAvailable = false;\r
+               }\r
                else {\r
-                       Sensor accelerometer = manager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);\r
-                       if (!manager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME))\r
+                       Sensor accelerometer = manager.getSensorList(\r
+                                       Sensor.TYPE_ACCELEROMETER).get(0);\r
+                       if (!manager.registerListener(this, accelerometer,\r
+                                       SensorManager.SENSOR_DELAY_GAME))\r
                                accelerometerAvailable = false;\r
                        else\r
                                accelerometerAvailable = true;\r
                }\r
 \r
-               for (int i = 0; i < 1000; i++)\r
-                       freeEvents.add(new Event());\r
-\r
                handle = new Handler();\r
                this.app = activity;\r
-\r
                this.sleepTime = sleepTime;\r
-\r
                int sdkVersion = Integer.parseInt(android.os.Build.VERSION.SDK);\r
-\r
                if (sdkVersion >= 5)\r
                        touchHandler = new AndroidMultiTouchHandler();\r
                else\r
                        touchHandler = new AndroidSingleTouchHandler();\r
-\r
                hasMultitouch = touchHandler instanceof AndroidMultiTouchHandler\r
-                       && ((AndroidMultiTouchHandler)touchHandler).supportsMultitouch(activity);\r
-       }\r
-\r
-       /**\r
-        * Called from within the render method of the AndroidGraphics instance. This is ugly but the only way to syncrhonously process\r
-        * events.\r
-        */\r
-       protected void update () {\r
-               synchronized (eventQueue) {\r
-                       for (int i = 0; i < eventQueue.size(); i++) {\r
-                               Event event = eventQueue.get(i);\r
-                               if (event.type == EventType.MouseDown) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).touchDown(event.x, event.y, event.pointer)) break;\r
-                               if (event.type == EventType.MouseUp) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).touchUp(event.x, event.y, event.pointer)) break;\r
-                               if (event.type == EventType.MouseDragged) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).touchDragged(event.x, event.y, event.pointer)) break;\r
-                               if (event.type == EventType.KeyDown) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).keyDown(event.keycode)) break;\r
-                               if (event.type == EventType.KeyUp) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).keyUp(event.keycode)) break;\r
-                               if (event.type == EventType.KeyTyped) for (int j = 0; j < inputListeners.size(); j++)\r
-                                       if (inputListeners.get(j).keyTyped(event.keychar)) break;\r
-                       }\r
-                       eventQueue.clear();\r
-                       freeEventIndex = 0;\r
-               }\r
-\r
-               if (textListener != null) {\r
-                       textListener.input(text);\r
-                       textListener = null;\r
-               }\r
+                               && ((AndroidMultiTouchHandler)touchHandler)\r
+                                               .supportsMultitouch(activity);\r
        }\r
 \r
-       @Override public void addInputListener (InputListener listener) {\r
-               synchronized (eventQueue) {\r
-                       if (!inputListeners.contains(listener)) inputListeners.add(listener);\r
-               }\r
-       }\r
-\r
-       @Override public float getAccelerometerX () {\r
+       @Override\r
+       public float getAccelerometerX() {\r
                return accelerometerValues[0];\r
        }\r
 \r
-       @Override public float getAccelerometerY () {\r
+       @Override\r
+       public float getAccelerometerY() {\r
                return accelerometerValues[1];\r
        }\r
 \r
-       @Override public float getAccelerometerZ () {\r
+       @Override\r
+       public float getAccelerometerZ() {\r
                return accelerometerValues[2];\r
        }\r
 \r
-       @Override public void getTextInput (final TextInputListener listener, final String title, final String text) {\r
+       @Override\r
+       public void getTextInput(final TextInputListener listener,\r
+                       final String title, final String text) {\r
                handle.post(new Runnable() {\r
-                       public void run () {\r
-\r
-                               AlertDialog.Builder alert = new AlertDialog.Builder(AndroidInput.this.app);\r
-\r
+                       @SuppressWarnings("synthetic-access")\r
+                       public void run() {\r
+                               AlertDialog.Builder alert = new AlertDialog.Builder(\r
+                                               AndroidInput.this.app);\r
                                alert.setTitle(title);\r
-\r
-                               // Set an EditText view to get user input\r
                                final EditText input = new EditText(AndroidInput.this.app);\r
                                input.setText(text);\r
                                input.setSingleLine();\r
                                alert.setView(input);\r
-\r
-                               alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {\r
-                                       public void onClick (DialogInterface dialog, int whichButton) {\r
-                                               AndroidInput.this.text = input.getText().toString();\r
-                                               textListener = listener;\r
-                                       }\r
-                               });\r
+                               alert.setPositiveButton("Ok",\r
+                                               new DialogInterface.OnClickListener() {\r
+                                                       public void onClick(DialogInterface dialog,\r
+                                                                       int whichButton) {\r
+                                                               listener.input(input.getText().toString());\r
+                                                       }\r
+                                               });\r
                                alert.show();\r
                        }\r
                });\r
        }\r
 \r
-       @Override public int getX () {\r
+       @Override\r
+       public int getX() {\r
                return touchX[0];\r
        }\r
 \r
-       @Override public int getY () {\r
+       @Override\r
+       public int getY() {\r
                return touchY[0];\r
        }\r
 \r
-       @Override public int getX (int pointer) {\r
+       @Override\r
+       public int getX(int pointer) {\r
                return touchX[pointer];\r
        }\r
 \r
-       @Override public int getY (int pointer) {\r
+       @Override\r
+       public int getY(int pointer) {\r
                return touchY[pointer];\r
        }\r
 \r
-       public boolean isTouched (int pointer) {\r
+       public boolean isTouched(int pointer) {\r
                return touched[pointer];\r
        }\r
 \r
-       @Override public boolean isAccelerometerAvailable () {\r
+       @Override\r
+       public boolean isAccelerometerAvailable() {\r
                return accelerometerAvailable;\r
        }\r
 \r
-       @Override public boolean isKeyPressed (int key) {\r
-               synchronized (eventQueue) {\r
+       @Override\r
+       public boolean isKeyPressed(int key) {\r
+               synchronized (this) {\r
                        if (key == Input.Keys.ANY_KEY)\r
                                return keys.size() > 0;\r
                        else\r
@@ -275,97 +216,146 @@ final class AndroidInput implements Input, OnKeyListener, OnTouchListener, Senso
                }\r
        }\r
 \r
-       @Override public boolean isTouched () {\r
+       @Override\r
+       public boolean isTouched() {\r
                return touched[0];\r
        }\r
-\r
-       @Override public void removeInputListener (InputListener listener) {\r
-               synchronized (eventQueue) {\r
-                       inputListeners.remove(listener);\r
+       \r
+       @Override\r
+       public void processEvents(InputProcessor listener) {\r
+               synchronized(this) {\r
+                       if(listener!=null) {                                            \r
+                               for(KeyEvent e: keyEvents) {\r
+                                       switch(e.type) {\r
+                                       case KeyEvent.KEY_DOWN:\r
+                                               listener.keyDown(e.keyCode);\r
+                                               break;\r
+                                       case KeyEvent.KEY_UP:\r
+                                               listener.keyUp(e.keyCode);\r
+                                               break;\r
+                                       case KeyEvent.KEY_TYPED:\r
+                                               listener.keyTyped(e.keyChar);\r
+                                       }\r
+                                       freeKeyEvents.free(e);\r
+                               }                                       \r
+                               \r
+                               for(TouchEvent e: touchEvents) {\r
+                                       switch(e.type) {\r
+                                       case TouchEvent.TOUCH_DOWN:\r
+                                               listener.touchDown(e.x, e.y, e.pointer);\r
+                                               break;\r
+                                       case TouchEvent.TOUCH_UP:\r
+                                               listener.touchUp(e.x, e.y, e.pointer);\r
+                                               break;\r
+                                       case TouchEvent.TOUCH_DRAGGED:\r
+                                               listener.touchDragged(e.x, e.y, e.pointer);\r
+                                       }\r
+                                       freeTouchEvents.free(e);\r
+                               }\r
+                       }\r
+                       \r
+                       keyEvents.clear();\r
+                       touchEvents.clear();\r
                }\r
        }\r
 \r
        boolean requestFocus = true;\r
-\r
-       @Override public boolean onTouch (View view, MotionEvent event) {\r
+       @Override\r
+       public boolean onTouch(View view, MotionEvent event) {\r
                if (requestFocus) {\r
                        view.requestFocus();\r
                        view.requestFocusFromTouch();\r
                        requestFocus = false;\r
                }\r
-\r
-               touchHandler.onTouch(event, this);\r
-\r
-               if (sleepTime != 0) {\r
+               synchronized (this) {\r
+                       touchHandler.onTouch(event, this);\r
+               }\r
+               if (sleepTime != 0)\r
                        try {\r
                                Thread.sleep(sleepTime);\r
                        } catch (InterruptedException e) {\r
-                               // yeah, right...\r
                        }\r
-               }\r
-\r
                return true;\r
        }\r
 \r
-       @Override public boolean onKey (View v, int keyCode, KeyEvent event) {\r
-               synchronized (eventQueue) {\r
-                       char character = (char)event.getUnicodeChar();\r
-                       \r
+       @Override\r
+       public boolean onKey(View v, int keyCode, android.view.KeyEvent e) {\r
+               synchronized (this) {\r
+                       char character = (char) e.getUnicodeChar();\r
                        // Android doesn't report a unicode char for back space. hrm...\r
-                       if( keyCode == 67 )\r
+                       if (keyCode == 67)\r
                                character = '\b';\r
-                       \r
-                       if (event.getAction() == KeyEvent.ACTION_DOWN) {\r
-                               Event ev = freeEvents.get(freeEventIndex++);\r
-                               ev.set(EventType.KeyDown, 0, 0, 0, event.getKeyCode(), character);\r
-                               eventQueue.add(ev);\r
-                               keys.add(event.getKeyCode());\r
-                       }\r
-                       if (event.getAction() == KeyEvent.ACTION_UP) {\r
-                               keys.remove(event.getKeyCode());\r
-\r
-                               Event ev = freeEvents.get(freeEventIndex++);\r
-                               ev.set(EventType.KeyUp, 0, 0, 0, event.getKeyCode(), character);\r
-                               eventQueue.add(ev);\r
 \r
-                               ev = freeEvents.get(freeEventIndex++);\r
-                               ev.set(EventType.KeyTyped, 0, 0, 0, event.getKeyCode(), character);\r
-                               eventQueue.add(ev);\r
+                       KeyEvent event = null;\r
+                       switch (e.getAction()) {\r
+                       case android.view.KeyEvent.ACTION_DOWN:\r
+                               event = freeKeyEvents.newObject();\r
+                               event.keyChar = 0;\r
+                               event.keyCode = e.getKeyCode();\r
+                               event.type = KeyEvent.KEY_DOWN;\r
+                               keyEvents.add(event);\r
+                               keys.add(event.keyCode);\r
+                               break;\r
+                       case android.view.KeyEvent.ACTION_UP:\r
+                               event = freeKeyEvents.newObject();\r
+                               event.keyChar = 0;\r
+                               event.keyCode = e.getKeyCode();\r
+                               event.type = KeyEvent.KEY_UP;\r
+                               keyEvents.add(event);                           \r
+\r
+                               event = freeKeyEvents.newObject();\r
+                               event.keyChar = character;\r
+                               event.keyCode = 0;\r
+                               event.type = KeyEvent.KEY_TYPED;\r
+                               keyEvents.add(event);\r
+                               \r
+                               keys.remove(event.keyCode);\r
                        }\r
                }\r
-               \r
-               if( catchBack && keyCode == KeyEvent.KEYCODE_BACK ) return true;\r
+\r
+               if (catchBack && keyCode == android.view.KeyEvent.KEYCODE_BACK)\r
+                       return true;\r
                return false;\r
        }\r
 \r
-       @Override public void onAccuracyChanged (Sensor arg0, int arg1) {\r
+       @Override\r
+       public void onAccuracyChanged(Sensor arg0, int arg1) {\r
 \r
        }\r
 \r
-       @Override public void onSensorChanged (SensorEvent event) {\r
+       @Override\r
+       public void onSensorChanged(SensorEvent event) {\r
                if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {\r
-                       System.arraycopy(event.values, 0, accelerometerValues, 0, accelerometerValues.length);\r
+                       System.arraycopy(event.values, 0, accelerometerValues, 0,\r
+                                       accelerometerValues.length);\r
                }\r
        }\r
 \r
-       @Override public boolean supportsMultitouch () {\r
+       @Override\r
+       public boolean supportsMultitouch() {\r
                return hasMultitouch;\r
        }\r
 \r
-       @Override public void setOnscreenKeyboardVisible (boolean visible) {\r
-               InputMethodManager manager = (InputMethodManager)app.getSystemService( Context.INPUT_METHOD_SERVICE );\r
-               if( visible ) {                 \r
-                       manager.showSoftInput( ((AndroidGraphics)app.getGraphics()).getView(), 0 );\r
+       @Override\r
+       public void setOnscreenKeyboardVisible(boolean visible) {\r
+               InputMethodManager manager = (InputMethodManager) app\r
+                               .getSystemService(Context.INPUT_METHOD_SERVICE);\r
+               if (visible) {\r
+                       manager.showSoftInput(((AndroidGraphics) app.getGraphics())\r
+                                       .getView(), 0);\r
                } else {\r
-                       manager.hideSoftInputFromWindow( ((AndroidGraphics)app.getGraphics()).getView().getWindowToken(), 0 );          \r
-               }                       \r
+                       manager.hideSoftInputFromWindow(((AndroidGraphics) app\r
+                                       .getGraphics()).getView().getWindowToken(), 0);\r
+               }\r
        }\r
 \r
-       @Override public boolean supportsOnscreenKeyboard () {\r
+       @Override\r
+       public boolean supportsOnscreenKeyboard() {\r
                return true;\r
        }\r
 \r
-       @Override public void setCatchBackKey (boolean catchBack) {\r
-               this.catchBack = catchBack;             \r
+       @Override\r
+       public void setCatchBackKey(boolean catchBack) {\r
+               this.catchBack = catchBack;\r
        }\r
 }\r
index 0c188b9..982f3e6 100644 (file)
@@ -15,8 +15,7 @@ package com.badlogic.gdx.backends.android;
 \r
 import android.view.MotionEvent;\r
 \r
-import com.badlogic.gdx.backends.android.AndroidInput.Event;\r
-import com.badlogic.gdx.backends.android.AndroidInput.EventType;\r
+import com.badlogic.gdx.backends.android.AndroidInput.TouchEvent;\r
 \r
 /**\r
  * Multitouch handler for devices running Android >= 2.0. If device is capable of (fake) multitouch this will report additional\r
@@ -38,7 +37,7 @@ public class AndroidMultiTouchHandler implements AndroidTouchHandler {
                case MotionEvent.ACTION_POINTER_DOWN:\r
                        x = (int)event.getX(pointerIndex);\r
                        y = (int)event.getY(pointerIndex);\r
-                       postTouchEvent(input, EventType.MouseDown, x, y, pointerId);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_DOWN, x, y, pointerId);\r
                        input.touchX[pointerId] = x;\r
                        input.touchY[pointerId] = y;\r
                        input.touched[pointerId] = true;\r
@@ -50,7 +49,7 @@ public class AndroidMultiTouchHandler implements AndroidTouchHandler {
                case MotionEvent.ACTION_CANCEL:\r
                        x = (int)event.getX(pointerIndex);\r
                        y = (int)event.getY(pointerIndex);\r
-                       postTouchEvent(input, EventType.MouseUp, x, y, pointerId);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_UP, x, y, pointerId);\r
                        input.touchX[pointerId] = x;\r
                        input.touchY[pointerId] = y;\r
                        input.touched[pointerId] = false;\r
@@ -63,7 +62,7 @@ public class AndroidMultiTouchHandler implements AndroidTouchHandler {
                                pointerId = event.getPointerId(pointerIndex);\r
                                x = (int)event.getX(pointerIndex);\r
                                y = (int)event.getY(pointerIndex);\r
-                               postTouchEvent(input, EventType.MouseDragged, x, y, pointerId);\r
+                               postTouchEvent(input, TouchEvent.TOUCH_DRAGGED, x, y, pointerId);\r
                                input.touchX[pointerId] = x;\r
                                input.touchY[pointerId] = y;\r
                        }\r
@@ -71,11 +70,14 @@ public class AndroidMultiTouchHandler implements AndroidTouchHandler {
                }\r
        }\r
 \r
-       private void postTouchEvent (AndroidInput input, EventType type, int x, int y, int pointer) {\r
-               synchronized (input.eventQueue) {\r
-                       Event ev = input.freeEvents.get(input.freeEventIndex++);\r
-                       ev.set(type, x, y, pointer, 0, '\0');\r
-                       input.eventQueue.add(ev);\r
+       private void postTouchEvent (AndroidInput input, int type, int x, int y, int pointer) {\r
+               synchronized (input) {\r
+                       TouchEvent event = input.freeTouchEvents.newObject();\r
+                       event.pointer = 0;\r
+                       event.x = x;\r
+                       event.y = y;\r
+                       event.type = type;                      \r
+                       input.touchEvents.add(event);                                   \r
                }\r
        }\r
 \r
index a44e334..a6b658c 100644 (file)
@@ -15,8 +15,7 @@ package com.badlogic.gdx.backends.android;
 \r
 import android.view.MotionEvent;\r
 \r
-import com.badlogic.gdx.backends.android.AndroidInput.Event;\r
-import com.badlogic.gdx.backends.android.AndroidInput.EventType;\r
+import com.badlogic.gdx.backends.android.AndroidInput.TouchEvent;\r
 \r
 /**\r
  * Single touch handler for devices running <= 1.6\r
@@ -31,30 +30,33 @@ public class AndroidSingleTouchHandler implements AndroidTouchHandler {
                input.touchX[0] = x;\r
                input.touchY[0] = y;\r
                if (event.getAction() == MotionEvent.ACTION_DOWN) {\r
-                       postTouchEvent(input, EventType.MouseDown, x, y, 0);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_DOWN, x, y, 0);\r
                        input.touched[0] = true;\r
                }\r
 \r
                if (event.getAction() == MotionEvent.ACTION_MOVE) {\r
-                       postTouchEvent(input, EventType.MouseDragged, x, y, 0);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_DRAGGED, x, y, 0);\r
                        input.touched[0] = true;\r
                }\r
                if (event.getAction() == MotionEvent.ACTION_UP) {\r
-                       postTouchEvent(input, EventType.MouseUp, x, y, 0);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_UP, x, y, 0);\r
                        input.touched[0] = false;\r
                }\r
 \r
                if (event.getAction() == MotionEvent.ACTION_CANCEL) {\r
-                       postTouchEvent(input, EventType.MouseUp, x, y, 0);\r
+                       postTouchEvent(input, TouchEvent.TOUCH_UP, x, y, 0);\r
                        input.touched[0] = false;\r
                }\r
        }\r
 \r
-       private void postTouchEvent (AndroidInput input, EventType type, int x, int y, int pointer) {\r
-               synchronized (input.eventQueue) {\r
-                       Event ev = input.freeEvents.get(input.freeEventIndex++);\r
-                       ev.set(type, x, y, pointer, 0, '\0');\r
-                       input.eventQueue.add(ev);\r
-               }\r
+       private void postTouchEvent (AndroidInput input, int type, int x, int y, int pointer) {         \r
+               synchronized (input) {\r
+                       TouchEvent event = input.freeTouchEvents.newObject();\r
+                       event.pointer = 0;\r
+                       event.x = x;\r
+                       event.y = y;\r
+                       event.type = type;                      \r
+                       input.touchEvents.add(event);                                   \r
+               }               \r
        }\r
 }\r
diff --git a/backends/gdx-backend-desktop/.settings/org.eclipse.jdt.core.prefs b/backends/gdx-backend-desktop/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index c6553de..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#Sat Oct 23 16:38:23 PDT 2010\r
-eclipse.preferences.version=1\r
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
-org.eclipse.jdt.core.compiler.compliance=1.6\r
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
-org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled\r
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning\r
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore\r
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning\r
-org.eclipse.jdt.core.compiler.problem.deadCode=ignore\r
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore\r
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled\r
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled\r
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning\r
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore\r
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore\r
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled\r
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore\r
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning\r
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning\r
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning\r
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning\r
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore\r
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private\r
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore\r
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning\r
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private\r
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore\r
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning\r
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning\r
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore\r
-org.eclipse.jdt.core.compiler.problem.nullReference=warning\r
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning\r
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore\r
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning\r
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore\r
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore\r
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore\r
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore\r
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled\r
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning\r
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled\r
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled\r
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning\r
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning\r
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore\r
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore\r
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning\r
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore\r
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore\r
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedImport=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning\r
-org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning\r
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning\r
-org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/backends/gdx-backend-desktop/LICENSE-2.0.html b/backends/gdx-backend-desktop/LICENSE-2.0.html
deleted file mode 100644 (file)
index 034256c..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html><head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-  <link rel="stylesheet" href="LICENSE-2.0_fichiers/style.css" type="text/css">
-  <meta name="author" content="The Apache Software Foundation">
-  <meta name="email" content="apache.AT.apache.DOT.org">
-  <title>Apache License, Version 2.0 - The Apache Software Foundation</title>
-</head>
-<body>        
-<p align="center">
-Apache License<br>
-Version 2.0, January 2004<br>
-<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a>
-</p>
-<p>
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-</p>
-<p><b><a name="definitions">1. Definitions</a></b>.</p>
-<p>
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-</p>
-<p>
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-</p>
-<p>
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-</p>
-<p>
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-</p>
-<p>
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-</p>
-<p>
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-</p>
-<p>
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-</p>
-<p>
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-</p>
-<p>
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-</p>
-<p>
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-</p>
-<p><b><a name="copyright">2. Grant of Copyright License</a></b>.
-Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-</p>
-<p><b><a name="patent">3. Grant of Patent License</a></b>.
-Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-</p>
-<p><b><a name="redistribution">4. Redistribution</a></b>.
-You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-</p><ol type="a">
-<li>You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-<br> <br></li>
-
-<li>You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-<br> <br></li>
-
-<li>You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-<br> <br></li>
-
-<li>If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.</li>
-</ol>
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-<p><b><a name="contributions">5. Submission of Contributions</a></b>.
-Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-</p>
-<p><b><a name="trademarks">6. Trademarks</a></b>.
-This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-</p>
-<p><b><a name="no-warranty">7. Disclaimer of Warranty</a></b>.
-Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-</p>
-<p><b><a name="no-liability">8. Limitation of Liability</a></b>.
-In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-</p>
-<p><b><a name="additional">9. Accepting Warranty or Additional Liability</a></b>.
-While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-</p>
-<p>
-END OF TERMS AND CONDITIONS
-</p>
-</body></html>
\ No newline at end of file
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglApplication.java b/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglApplication.java
deleted file mode 100644 (file)
index c8fedaf..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx.backends.desktop;\r
-\r
-import com.badlogic.gdx.Application;\r
-import com.badlogic.gdx.ApplicationListener;\r
-import com.badlogic.gdx.Audio;\r
-import com.badlogic.gdx.Files;\r
-import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.Graphics;\r
-import com.badlogic.gdx.Input;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
-import com.badlogic.gdx.Version;\r
-import com.badlogic.gdx.graphics.GL10;\r
-import com.badlogic.gdx.graphics.GL11;\r
-\r
-/**\r
- * An implemenation of the {@link Application} interface based on Jogl for Windows, Linux and Mac. Instantiate this class with\r
- * apropriate parameters and then register {@link ApplicationListener}, {@link RenderListener} or {@link InputListener} instances.\r
- * \r
- * @author mzechner\r
- * \r
- */\r
-public final class JoglApplication implements Application {\r
-       static {\r
-               Version.loadLibrary();\r
-       }\r
-\r
-       /** the graphics instance **/\r
-       private final JoglGraphics graphics;\r
-\r
-       /** the input instance **/\r
-       private final JoglInput input;\r
-\r
-       /** the audio instance **/\r
-       private final JoglAudio audio;\r
-\r
-       /** the DestroyListener **/\r
-       ApplicationListener listener;\r
-\r
-       /**\r
-        * Creates a new {@link JoglApplication} with the given title and dimensions. If useGL20IfAvailable is set the JoglApplication\r
-        * will try to create an OpenGL 2.0 context which can then be used via {@link JoglApplication.getGraphics().getGL20()}. The\r
-        * {@link GL10} and {@link GL11} interfaces should not be used when OpenGL 2.0 is enabled. To query whether enabling OpenGL 2.0\r
-        * was successful use the {@link JoglApplication.getGraphics().isGL20Available()} method.\r
-        * \r
-        * @param title the title of the application\r
-        * @param width the width of the surface in pixels\r
-        * @param height the height of the surface in pixels\r
-        * @param useGL20IfAvailable wheter to use OpenGL 2.0 if it is available or not\r
-        */\r
-       public JoglApplication (String title, int width, int height, boolean useGL20IfAvailable) {\r
-               graphics = new JoglGraphics(this, title, width, height, useGL20IfAvailable);\r
-               input = new JoglInput(graphics.graphicPanel);\r
-               audio = new JoglAudio();\r
-\r
-               Gdx.app = this;\r
-               Gdx.graphics = this.getGraphics();\r
-               Gdx.input = this.getInput();\r
-               Gdx.audio = this.getAudio();\r
-               Gdx.files = this.getFiles();\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public Audio getAudio () {\r
-               return audio;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public Files getFiles () {\r
-               return new JoglFiles();\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public Graphics getGraphics () {\r
-               return graphics;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public Input getInput () {\r
-               return input;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public void setApplicationListener (ApplicationListener listener) {\r
-               this.listener = listener;\r
-       }\r
-\r
-       @Override public void log (String tag, String message) {\r
-               System.out.println(tag + ": " + message);\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public ApplicationType getType () {\r
-               return ApplicationType.Desktop;\r
-       }\r
-\r
-       @Override public int getVersion () {\r
-               return 0;\r
-       }\r
-\r
-}\r
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGraphics.java b/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGraphics.java
deleted file mode 100644 (file)
index 430cb4e..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx.backends.desktop;\r
-\r
-import java.awt.BorderLayout;\r
-import java.awt.Dimension;\r
-import java.awt.event.WindowAdapter;\r
-import java.awt.event.WindowEvent;\r
-import java.awt.image.BufferedImage;\r
-import java.io.InputStream;\r
-\r
-import javax.imageio.ImageIO;\r
-import javax.media.opengl.GL;\r
-import javax.swing.JFrame;\r
-\r
-import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.Graphics;\r
-import com.badlogic.gdx.RenderListener;\r
-import com.badlogic.gdx.files.FileHandle;\r
-import com.badlogic.gdx.graphics.GL10;\r
-import com.badlogic.gdx.graphics.GL11;\r
-import com.badlogic.gdx.graphics.GL20;\r
-import com.badlogic.gdx.graphics.GLCommon;\r
-import com.badlogic.gdx.graphics.Pixmap;\r
-import com.badlogic.gdx.graphics.Texture;\r
-import com.badlogic.gdx.graphics.Pixmap.Format;\r
-import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
-import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
-import com.badlogic.gdx.math.WindowedMean;\r
-import com.badlogic.gdx.utils.GdxRuntimeException;\r
-\r
-/**\r
- * An implementation of the {@link Graphics} interface based on Jogl.\r
- * @author mzechner\r
- * \r
- */\r
-public final class JoglGraphics implements Graphics, RenderListener {\r
-       /** the jframe **/\r
-       private final JFrame frame;\r
-\r
-       /** the graphic panel **/\r
-       protected final JoglPanel graphicPanel;\r
-\r
-       /** the render listener **/\r
-       private RenderListener listener;\r
-\r
-       /** Common instance **/\r
-       private GLCommon gl;\r
-\r
-       /** GL10 instance **/\r
-       private GL10 gl10;\r
-\r
-       /** GL11 instance **/\r
-       private GL11 gl11;\r
-\r
-       /** GL20 instance **/\r
-       private GL20 gl20;\r
-\r
-       /** wheter to use opengl 2 **/\r
-       private final boolean useGL2;\r
-\r
-       /** the last frame time **/\r
-       private long lastFrameTime = System.nanoTime();\r
-\r
-       /** the deltaTime **/\r
-       private float deltaTime = 0;\r
-\r
-       /** frame start time **/\r
-       private long frameStart = System.nanoTime();\r
-\r
-       /** frame counter **/\r
-       private int frames = 0;\r
-\r
-       /** last fps **/\r
-       private int fps;\r
-\r
-       /** the deltaTime mean **/\r
-       private WindowedMean mean = new WindowedMean(5);\r
-\r
-       JoglGraphics (final JoglApplication application, String title, int width, int height, boolean useGL2IfAvailable) {\r
-               frame = new JFrame(title);\r
-               graphicPanel = new JoglPanel(application);\r
-               graphicPanel.setPreferredSize(new Dimension(width, height));\r
-               frame.setSize(width + frame.getInsets().left + frame.getInsets().right, frame.getInsets().top + frame.getInsets().bottom\r
-                       + height);\r
-               frame.add(graphicPanel, BorderLayout.CENTER);\r
-               frame.pack();\r
-               frame.setVisible(true);\r
-               frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);\r
-               frame.setLocationRelativeTo(null);\r
-               frame.addWindowListener(new WindowAdapter() {\r
-                       public void windowClosing (WindowEvent e) {\r
-                               if (application.listener != null) application.listener.pause();\r
-                               graphicPanel.dispose();\r
-                               if (application.listener != null) application.listener.destroy();\r
-                       }\r
-               });\r
-               useGL2 = useGL2IfAvailable;\r
-               graphicPanel.addGraphicListener(this);\r
-               graphicPanel.requestFocusInWindow();\r
-       }\r
-\r
-       @Override public GL10 getGL10 () {\r
-               return gl10;\r
-       }\r
-\r
-       @Override public GL11 getGL11 () {\r
-               return gl11;\r
-       }\r
-\r
-       @Override public GL20 getGL20 () {\r
-               return gl20;\r
-       }\r
-\r
-       @Override public int getHeight () {\r
-               return graphicPanel.getHeight();\r
-       }\r
-\r
-       @Override public int getWidth () {\r
-               return graphicPanel.getWidth();\r
-       }\r
-\r
-       @Override public boolean isGL11Available () {\r
-               return gl11 != null;\r
-       }\r
-\r
-       @Override public boolean isGL20Available () {\r
-               return gl20 != null;\r
-       }\r
-       \r
-       @Override public Pixmap newPixmap (int width, int height, Format format) {\r
-               return new JoglPixmap(width, height, format);\r
-       }\r
-\r
-       @Override public Pixmap newPixmap (InputStream in) {\r
-               try {\r
-                       BufferedImage img = (BufferedImage)ImageIO.read(in);\r
-                       return new JoglPixmap(img);\r
-               } catch (Exception ex) {\r
-                       throw new GdxRuntimeException("Couldn't load Pixmap from InputStream", ex);\r
-               }\r
-       }\r
-\r
-       @Override public Pixmap newPixmap (FileHandle file) {\r
-               return newPixmap(file.getInputStream());\r
-       }\r
-\r
-       @Override public Pixmap newPixmap (Object nativePixmap) {\r
-               return new JoglPixmap((BufferedImage)nativePixmap);\r
-       }\r
-\r
-       private static boolean isPowerOfTwo (int value) {\r
-               return ((value != 0) && (value & (value - 1)) == 0);\r
-       }\r
-\r
-       @Override public Texture newUnmanagedTexture (int width, int height, Pixmap.Format format, TextureFilter minFilter,\r
-               TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {\r
-               if (!isPowerOfTwo(width) || !isPowerOfTwo(height))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two");\r
-\r
-               if (format == Format.Alpha)\r
-                       return new JoglTexture(width, height, BufferedImage.TYPE_BYTE_GRAY, minFilter, magFilter, uWrap, vWrap, false);\r
-               else\r
-                       return new JoglTexture(width, height, BufferedImage.TYPE_4BYTE_ABGR, minFilter, magFilter, uWrap, vWrap, false);\r
-       }\r
-\r
-       @Override public Texture newUnmanagedTexture (Pixmap pixmap, TextureFilter minFilter, TextureFilter magFilter,\r
-               TextureWrap uWrap, TextureWrap vWrap) {\r
-               if (!isPowerOfTwo(pixmap.getHeight()) || !isPowerOfTwo(pixmap.getWidth()))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two");\r
-\r
-               return new JoglTexture((BufferedImage)pixmap.getNativePixmap(), minFilter, magFilter, uWrap, vWrap, false);\r
-       }\r
-\r
-       @Override public Texture newTexture (FileHandle file, TextureFilter minFilter, TextureFilter magFilter, TextureWrap uWrap,\r
-               TextureWrap vWrap) {\r
-               Pixmap pixmap = newPixmap(file);\r
-               if (!isPowerOfTwo(pixmap.getHeight()) || !isPowerOfTwo(pixmap.getWidth()))\r
-                       throw new GdxRuntimeException("Texture dimensions must be a power of two");\r
-\r
-               return new JoglTexture((BufferedImage)pixmap.getNativePixmap(), minFilter, magFilter, uWrap, vWrap, false);\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public void setRenderListener (RenderListener listener) {\r
-               if (this.listener != null) graphicPanel.removeGraphicListener(this.listener);\r
-               graphicPanel.addGraphicListener(listener);\r
-               this.listener = listener;\r
-       }\r
-\r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
-               // calculate delta time\r
-               deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;\r
-               lastFrameTime = System.nanoTime();\r
-               mean.addValue(deltaTime);\r
-\r
-               if (System.nanoTime() - frameStart > 1000000000) {\r
-                       fps = frames;\r
-                       frames = 0;\r
-                       frameStart = System.nanoTime();\r
-               }\r
-               frames++;\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               String version = graphicPanel.getGL().glGetString(GL.GL_VERSION);\r
-               int major = Integer.parseInt("" + version.charAt(0));\r
-               int minor = Integer.parseInt("" + version.charAt(2));\r
-\r
-               if (useGL2 && major >= 2) {\r
-                       // FIXME add check wheter gl 2.0 is supported\r
-                       gl20 = new JoglGL20(graphicPanel.getGL());\r
-                       gl = gl20;\r
-               } else {\r
-                       if (major == 1 && minor < 5) {\r
-                               gl10 = new JoglGL10(graphicPanel.getGL());\r
-                       } else {\r
-                               gl11 = new JoglGL11(graphicPanel.getGL());\r
-                               gl10 = gl11;\r
-                       }\r
-                       gl = gl10;\r
-               }\r
-\r
-               Gdx.gl = gl;\r
-               Gdx.gl10 = gl10;\r
-               Gdx.gl11 = gl11;\r
-               Gdx.gl20 = gl20;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public float getDeltaTime () {\r
-               return mean.getMean() == 0 ? deltaTime : mean.getMean();\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public GraphicsType getType () {\r
-               return GraphicsType.JoglGL;\r
-       }\r
-\r
-       /**\r
-        * {@inheritDoc}\r
-        */\r
-       @Override public int getFramesPerSecond () {\r
-               return fps;\r
-       }\r
-\r
-       @Override public GLCommon getGLCommon () {\r
-               return gl;\r
-       }\r
-}\r
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInput.java b/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInput.java
deleted file mode 100644 (file)
index 5068f73..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx.backends.desktop;\r
-\r
-import java.awt.event.MouseEvent;\r
-\r
-import javax.swing.JOptionPane;\r
-import javax.swing.SwingUtilities;\r
-\r
-import com.badlogic.gdx.Input;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
-\r
-/**\r
- * An implementation of the {@link Input} interface hooking a Jogl panel for input.\r
- * \r
- * @author mzechner\r
- * \r
- */\r
-final class JoglInput implements Input, RenderListener {\r
-       /** the multiplexer **/\r
-       private final JoglInputMultiplexer multiplexer;\r
-\r
-       /** the graphics panel **/\r
-       private final JoglPanel panel;\r
-\r
-       /** user input **/\r
-       private String text;\r
-\r
-       /** user input listener **/\r
-       private TextInputListener textListener;\r
-\r
-       JoglInput (JoglPanel panel) {\r
-               multiplexer = new JoglInputMultiplexer(panel.getCanvas());\r
-               this.panel = panel;\r
-               this.panel.addGraphicListener(this);\r
-       }\r
-\r
-       @Override public void addInputListener (InputListener listener) {\r
-               multiplexer.addListener(listener);\r
-       }\r
-\r
-       @Override public float getAccelerometerX () {\r
-               return 0;\r
-       }\r
-\r
-       @Override public float getAccelerometerY () {\r
-               return 0;\r
-       }\r
-\r
-       @Override public float getAccelerometerZ () {\r
-               return 0;\r
-       }\r
-\r
-       @Override public void getTextInput (final TextInputListener listener, final String title, final String text) {\r
-               SwingUtilities.invokeLater(new Runnable() {\r
-                       @Override public void run () {\r
-                               JoglInput.this.text = JOptionPane.showInputDialog(null, title, text);\r
-                               if (JoglInput.this.text != null) textListener = listener;\r
-                       }\r
-               });\r
-       }\r
-\r
-       @Override public int getX () {\r
-               return panel.getMouseX();\r
-       }\r
-\r
-       @Override public int getY () {\r
-               return panel.getMouseY();\r
-       }\r
-\r
-       @Override public boolean isAccelerometerAvailable () {\r
-               return false;\r
-       }\r
-\r
-       @Override public boolean isKeyPressed (int key) {\r
-               return panel.isKeyDown(key);\r
-       }\r
-\r
-       @Override public boolean isTouched () {\r
-               return panel.isButtonDown(MouseEvent.BUTTON1) || panel.isButtonDown(MouseEvent.BUTTON2)\r
-                       || panel.isButtonDown(MouseEvent.BUTTON3);\r
-       }\r
-\r
-       @Override public void removeInputListener (InputListener listener) {\r
-               multiplexer.removeListener(listener);\r
-       }\r
-\r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
-               multiplexer.processEvents();\r
-\r
-               if (textListener != null) {\r
-                       textListener.input(text);\r
-                       textListener = null;\r
-               }\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public int getX (int pointer) {\r
-               if (pointer > 0)\r
-                       return 0;\r
-               else\r
-                       return getX();\r
-       }\r
-\r
-       @Override public int getY (int pointer) {\r
-               if (pointer > 0)\r
-                       return 0;\r
-               else\r
-                       return getY();\r
-       }\r
-\r
-       @Override public boolean isTouched (int pointer) {\r
-               if (pointer > 0)\r
-                       return false;\r
-               else\r
-                       return isTouched();\r
-       }\r
-\r
-       @Override public boolean supportsMultitouch () {\r
-               return false;\r
-       }\r
-\r
-       @Override public void setOnscreenKeyboardVisible (boolean visible) {\r
-               \r
-       }\r
-\r
-       @Override public boolean supportsOnscreenKeyboard () {\r
-               return false;\r
-       }\r
-       \r
-       @Override public void setCatchBackKey (boolean catchBack) {\r
-               \r
-       }\r
-}\r
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInputMultiplexer.java b/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInputMultiplexer.java
deleted file mode 100644 (file)
index f45f174..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx.backends.desktop;\r
-\r
-import java.awt.Component;\r
-import java.awt.event.KeyEvent;\r
-import java.awt.event.KeyListener;\r
-import java.awt.event.MouseEvent;\r
-import java.awt.event.MouseListener;\r
-import java.awt.event.MouseMotionListener;\r
-import java.awt.event.MouseWheelEvent;\r
-import java.awt.event.MouseWheelListener;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-\r
-import com.badlogic.gdx.Input;\r
-import com.badlogic.gdx.InputListener;\r
-\r
-/**\r
- * Hooks a swing component and multiplexes any input events to all registered listeners in order. a listener can signal wheter he\r
- * has consumed the event therefor ending the multiplexing.\r
- * \r
- * @author badlogicgames@gmail.com\r
- * \r
- */\r
-final class JoglInputMultiplexer implements MouseListener, MouseMotionListener, MouseWheelListener, KeyListener {\r
-       private enum EventType {\r
-               MouseDown, MouseUp, MouseMoved, MouseDragged, KeyDown, KeyUp, KeyTyped\r
-       }\r
-\r
-       private class Event {\r
-               public int x, y;\r
-               public int keycode;\r
-               public char keychar;\r
-               public EventType type;\r
-\r
-               public void set (EventType type, int x, int y, int keycode, char keychar) {\r
-                       this.type = type;\r
-                       this.x = x;\r
-                       this.y = y;\r
-                       this.keycode = keycode;\r
-                       this.keychar = keychar;\r
-               }\r
-       }\r
-\r
-       private final ArrayList<Event> eventQueue = new ArrayList<Event>();\r
-       private final ArrayList<Event> freeEvents = new ArrayList<Event>();\r
-       private int freeEventIndex = 0;\r
-\r
-       private final ArrayList<InputListener> listeners = new ArrayList<InputListener>();\r
-       private final HashMap<InputListener, Boolean> disabled = new HashMap<InputListener, Boolean>();\r
-       private Component component;\r
-\r
-       /**\r
-        * constructor, hooks the given component\r
-        * @param component the component to hook\r
-        */\r
-       JoglInputMultiplexer (Component component) {\r
-               hook(component);\r
-               for (int i = 0; i < 1000; i++)\r
-                       freeEvents.add(new Event());\r
-       }\r
-\r
-       /**\r
-        * adds callback hooks to the component. unhooks from the old component if any was set.\r
-        * \r
-        * @param component the component to hook\r
-        */\r
-       public void hook (Component component) {\r
-               unhook();\r
-               component.addMouseListener(this);\r
-               component.addMouseMotionListener(this);\r
-               component.addMouseWheelListener(this);\r
-               component.addKeyListener(this);\r
-               this.component = component;\r
-       }\r
-\r
-       /**\r
-        * removes the callback hooks from the swing component\r
-        */\r
-       public void unhook () {\r
-               if (component != null) {\r
-                       component.removeMouseListener(this);\r
-                       component.removeMouseMotionListener(this);\r
-                       component.removeMouseWheelListener(this);\r
-                       component.removeKeyListener(this);\r
-               }\r
-       }\r
-\r
-       public void disableListener (InputListener listener) {\r
-               disabled.put(listener, true);\r
-       }\r
-\r
-       public void enableListener (InputListener listener) {\r
-               disabled.put(listener, false);\r
-       }\r
-\r
-       public void processEvents () {\r
-               synchronized (eventQueue) {\r
-                       for (int i = 0; i < eventQueue.size(); i++) {\r
-                               Event event = eventQueue.get(i);\r
-                               if (event.type == EventType.MouseDown) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).touchDown(event.x, event.y, 0)) break;\r
-                               if (event.type == EventType.MouseUp) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).touchUp(event.x, event.y, 0)) break;\r
-                               if (event.type == EventType.MouseDragged) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).touchDragged(event.x, event.y, 0)) break;\r
-                               if (event.type == EventType.KeyDown) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).keyDown(event.keycode)) break;\r
-                               if (event.type == EventType.KeyUp) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).keyUp(event.keycode)) break;\r
-                               if (event.type == EventType.KeyTyped) for (int j = 0; j < listeners.size(); j++)\r
-                                       if (listeners.get(j).keyTyped(event.keychar)) break;\r
-                       }\r
-                       eventQueue.clear();\r
-                       freeEventIndex = 0;\r
-               }\r
-       }\r
-\r
-       /**\r
-        * adds an {@link InputListener} to this multiplexer. The order in which listeners are added is the order in which they are\r
-        * asked to consume events.\r
-        * \r
-        * @param listener the listener to add\r
-        */\r
-       public void addListener (InputListener listener) {\r
-               synchronized (eventQueue) {\r
-                       if (!listeners.contains(listener)) {\r
-                               listeners.add(listener);\r
-                               disabled.put(listener, false);\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void removeListener (InputListener listener) {\r
-               synchronized (eventQueue) {\r
-                       listeners.remove(listener);\r
-                       disabled.remove(listener);\r
-               }\r
-       }\r
-\r
-       public void mouseClicked (MouseEvent e) {\r
-\r
-       }\r
-\r
-       public void mousePressed (MouseEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.MouseDown, e.getX(), e.getY(), 0, '\0');\r
-                       eventQueue.add(event);\r
-               }\r
-       }\r
-\r
-       public void mouseReleased (MouseEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.MouseUp, e.getX(), e.getY(), 0, '\0');\r
-                       eventQueue.add(event);\r
-               }\r
-\r
-       }\r
-\r
-       public void mouseDragged (MouseEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.MouseDragged, e.getX(), e.getY(), 0, '\0');\r
-                       eventQueue.add(event);\r
-               }\r
-       }\r
-\r
-       public void mouseMoved (MouseEvent e) {\r
-       }\r
-\r
-       public void keyPressed (KeyEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.KeyDown, 0, 0, translateKeyCode(e.getKeyCode()), '\0');\r
-                       eventQueue.add(event);\r
-               }\r
-       }\r
-\r
-       public void keyReleased (KeyEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.KeyUp, 0, 0, translateKeyCode(e.getKeyCode()), '\0');\r
-                       eventQueue.add(event);\r
-               }\r
-       }\r
-\r
-       public void keyTyped (KeyEvent e) {\r
-               synchronized (eventQueue) {\r
-                       Event event = freeEvents.get(freeEventIndex++);\r
-                       event.set(EventType.KeyTyped, 0, 0, translateKeyCode(e.getKeyCode()), e.getKeyChar());\r
-                       eventQueue.add(event);\r
-               }\r
-       }\r
-\r
-       @Override public void mouseEntered (MouseEvent e) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void mouseExited (MouseEvent e) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void mouseWheelMoved (MouseWheelEvent arg0) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       protected static int translateKeyCode (int keyCode) {\r
-               if (keyCode == KeyEvent.VK_0) return Input.Keys.KEYCODE_0;\r
-               if (keyCode == KeyEvent.VK_1) return Input.Keys.KEYCODE_1;\r
-               if (keyCode == KeyEvent.VK_2) return Input.Keys.KEYCODE_2;\r
-               if (keyCode == KeyEvent.VK_3) return Input.Keys.KEYCODE_3;\r
-               if (keyCode == KeyEvent.VK_4) return Input.Keys.KEYCODE_4;\r
-               if (keyCode == KeyEvent.VK_5) return Input.Keys.KEYCODE_5;\r
-               if (keyCode == KeyEvent.VK_6) return Input.Keys.KEYCODE_6;\r
-               if (keyCode == KeyEvent.VK_7) return Input.Keys.KEYCODE_7;\r
-               if (keyCode == KeyEvent.VK_8) return Input.Keys.KEYCODE_8;\r
-               if (keyCode == KeyEvent.VK_9) return Input.Keys.KEYCODE_9;\r
-               if (keyCode == KeyEvent.VK_A) return Input.Keys.KEYCODE_A;\r
-               if (keyCode == KeyEvent.VK_B) return Input.Keys.KEYCODE_B;\r
-               if (keyCode == KeyEvent.VK_C) return Input.Keys.KEYCODE_C;\r
-               if (keyCode == KeyEvent.VK_D) return Input.Keys.KEYCODE_D;\r
-               if (keyCode == KeyEvent.VK_E) return Input.Keys.KEYCODE_E;\r
-               if (keyCode == KeyEvent.VK_F) return Input.Keys.KEYCODE_F;\r
-               if (keyCode == KeyEvent.VK_G) return Input.Keys.KEYCODE_G;\r
-               if (keyCode == KeyEvent.VK_H) return Input.Keys.KEYCODE_H;\r
-               if (keyCode == KeyEvent.VK_I) return Input.Keys.KEYCODE_I;\r
-               if (keyCode == KeyEvent.VK_J) return Input.Keys.KEYCODE_J;\r
-               if (keyCode == KeyEvent.VK_K) return Input.Keys.KEYCODE_K;\r
-               if (keyCode == KeyEvent.VK_L) return Input.Keys.KEYCODE_L;\r
-               if (keyCode == KeyEvent.VK_M) return Input.Keys.KEYCODE_M;\r
-               if (keyCode == KeyEvent.VK_N) return Input.Keys.KEYCODE_N;\r
-               if (keyCode == KeyEvent.VK_O) return Input.Keys.KEYCODE_O;\r
-               if (keyCode == KeyEvent.VK_P) return Input.Keys.KEYCODE_P;\r
-               if (keyCode == KeyEvent.VK_Q) return Input.Keys.KEYCODE_Q;\r
-               if (keyCode == KeyEvent.VK_R) return Input.Keys.KEYCODE_R;\r
-               if (keyCode == KeyEvent.VK_S) return Input.Keys.KEYCODE_S;\r
-               if (keyCode == KeyEvent.VK_T) return Input.Keys.KEYCODE_T;\r
-               if (keyCode == KeyEvent.VK_U) return Input.Keys.KEYCODE_U;\r
-               if (keyCode == KeyEvent.VK_V) return Input.Keys.KEYCODE_V;\r
-               if (keyCode == KeyEvent.VK_W) return Input.Keys.KEYCODE_W;\r
-               if (keyCode == KeyEvent.VK_X) return Input.Keys.KEYCODE_X;\r
-               if (keyCode == KeyEvent.VK_Y) return Input.Keys.KEYCODE_Y;\r
-               if (keyCode == KeyEvent.VK_Z) return Input.Keys.KEYCODE_Z;\r
-               if (keyCode == KeyEvent.VK_ALT) return Input.Keys.KEYCODE_ALT_LEFT;\r
-               if (keyCode == KeyEvent.VK_ALT_GRAPH) return Input.Keys.KEYCODE_ALT_RIGHT;\r
-               if (keyCode == KeyEvent.VK_BACK_SLASH) return Input.Keys.KEYCODE_BACKSLASH;\r
-               if (keyCode == KeyEvent.VK_COMMA) return Input.Keys.KEYCODE_COMMA;\r
-               if (keyCode == KeyEvent.VK_DELETE) return Input.Keys.KEYCODE_DEL;\r
-               if (keyCode == KeyEvent.VK_LEFT) return Input.Keys.KEYCODE_DPAD_LEFT;\r
-               if (keyCode == KeyEvent.VK_RIGHT) return Input.Keys.KEYCODE_DPAD_RIGHT;\r
-               if (keyCode == KeyEvent.VK_UP) return Input.Keys.KEYCODE_DPAD_UP;\r
-               if (keyCode == KeyEvent.VK_DOWN) return Input.Keys.KEYCODE_DPAD_DOWN;\r
-               if (keyCode == KeyEvent.VK_ENTER) return Input.Keys.KEYCODE_ENTER;\r
-               if (keyCode == KeyEvent.VK_HOME) return Input.Keys.KEYCODE_HOME;\r
-               if (keyCode == KeyEvent.VK_MINUS) return Input.Keys.KEYCODE_MINUS;\r
-               if (keyCode == KeyEvent.VK_PERIOD) return Input.Keys.KEYCODE_PERIOD;\r
-               if (keyCode == KeyEvent.VK_PLUS) return Input.Keys.KEYCODE_PLUS;\r
-               if (keyCode == KeyEvent.VK_SEMICOLON) return Input.Keys.KEYCODE_SEMICOLON;\r
-               if (keyCode == KeyEvent.VK_SHIFT) return Input.Keys.KEYCODE_SHIFT_LEFT;\r
-               if (keyCode == KeyEvent.VK_SLASH) return Input.Keys.KEYCODE_SLASH;\r
-               if (keyCode == KeyEvent.VK_SPACE) return Input.Keys.KEYCODE_SPACE;\r
-               if (keyCode == KeyEvent.VK_TAB) return Input.Keys.KEYCODE_TAB;\r
-\r
-               return Input.Keys.KEYCODE_UNKNOWN;\r
-       }\r
-}\r
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPanel.java b/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPanel.java
deleted file mode 100644 (file)
index b3a6d5c..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx.backends.desktop;\r
-\r
-import java.awt.BorderLayout;\r
-import java.awt.Point;\r
-import java.awt.event.KeyEvent;\r
-import java.awt.event.KeyListener;\r
-import java.awt.event.MouseEvent;\r
-import java.awt.event.MouseListener;\r
-import java.awt.event.MouseMotionListener;\r
-import java.io.BufferedOutputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.ArrayList;\r
-import java.util.HashSet;\r
-\r
-import javax.media.opengl.GL;\r
-import javax.media.opengl.GLAutoDrawable;\r
-import javax.media.opengl.GLCanvas;\r
-import javax.media.opengl.GLCapabilities;\r
-import javax.media.opengl.GLContext;\r
-import javax.media.opengl.GLEventListener;\r
-import javax.swing.JPanel;\r
-\r
-import com.badlogic.gdx.Application;\r
-import com.badlogic.gdx.RenderListener;\r
-import com.badlogic.gdx.math.WindowedMean;\r
-import com.sun.opengl.impl.NativeLibLoader;\r
-import com.sun.opengl.util.Animator;\r
-\r
-/**\r
- * An OpenGL based graphics panel. Shares its context with all other GraphicPanels in the application. Has a continous render\r
- * thread constantly invoking the paint method. Note that you have to dispose the panel before it is being removed from another\r
- * gui component such as a JFrame.\r
- * \r
- * @author badlogicgames@gmail.com\r
- * \r
- */\r
-final class JoglPanel extends JPanel implements GLEventListener, MouseMotionListener, MouseListener, KeyListener {\r
-       private static final long serialVersionUID = -3638194405409146221L;\r
-\r
-       /** global flag used to check wheter the libraries are loaded already **/\r
-       private static boolean loaded = false;\r
-\r
-       /** the context to be used by all GraphicPanels **/\r
-       private static GLContext context = null;\r
-\r
-       /** the canvas object **/\r
-       private final GLCanvas canvas;\r
-\r
-       /** animator for continous updates **/\r
-       private final Animator animator;\r
-\r
-       /** vsynch flag **/\r
-       private boolean vSynch = true;\r
-\r
-       /** last mouse position **/\r
-       private final Point mousePosition = new Point();\r
-\r
-       /** last mouse button states **/\r
-       private final HashSet<Integer> buttons = new HashSet<Integer>();\r
-\r
-       /** last key states **/\r
-       private final HashSet<Integer> keys = new HashSet<Integer>();\r
-\r
-       /** listeners **/\r
-       private final ArrayList<RenderListener> listeners = new ArrayList<RenderListener>();\r
-\r
-       /** listeners **/\r
-       private final ArrayList<RenderListener> setupListeners = new ArrayList<RenderListener>();\r
-\r
-       /** start time of last frame **/\r
-       private long frameStart = System.nanoTime();\r
-\r
-       /** delta time between current and last frame **/\r
-       private float deltaTime = 0;\r
-       private WindowedMean mean = new WindowedMean(10);\r
-\r
-       private JoglInputMultiplexer multiplexer;\r
-\r
-       /**\r
-        * loads the necessary libraries depending on the operating system\r
-        */\r
-       private static void loadLibraries () {\r
-               if (loaded) return;\r
-\r
-               NativeLibLoader.disableLoading();\r
-               com.sun.gluegen.runtime.NativeLibLoader.disableLoading();\r
-               // By wkien: On some systems (read: mine) jogl_awt would not find its dependency jawt if not loaded before\r
-               System.loadLibrary("jawt");\r
-               loadLibrary("gluegen-rt");\r
-               loadLibrary("jogl_awt");\r
-               loadLibrary("jogl");\r
-\r
-               loaded = true;\r
-       }\r
-\r
-       /**\r
-        * helper method to load a specific library in an operation system dependant manner\r
-        * @param resource the name of the resource\r
-        */\r
-       private static void loadLibrary (String resource) {\r
-               String package_path = "/javax/media/";\r
-               String library = "";\r
-\r
-               String os = System.getProperty("os.name");\r
-               String arch = System.getProperty("os.arch");\r
-\r
-               if (os.contains("Windows")) {\r
-                       if (!arch.equals("amd64"))\r
-                               library = resource + "-win32.dll";\r
-                       else {\r
-                               library = resource + "-win64.dll";\r
-                       }\r
-               }\r
-\r
-               if (os.contains("Linux")) {\r
-                       if (!arch.equals("amd64"))\r
-                               library = "lib" + resource + "-linux32.so";\r
-                       else\r
-                               library = "lib" + resource + "-linux64.so";\r
-               }\r
-\r
-               if (os.contains("Mac")) {\r
-                       library = "lib" + resource + ".jnilib";\r
-               }\r
-\r
-               String so = System.getProperty("java.io.tmpdir") + "/" + System.nanoTime() + library;\r
-               InputStream in = JoglPanel.class.getResourceAsStream(package_path + library);\r
-               if (in == null) throw new RuntimeException("couldn't find " + library + " in jar file.");\r
-\r
-               try {\r
-                       BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(so));\r
-                       byte[] bytes = new byte[1024 * 4];\r
-                       while (true) {\r
-                               int read_bytes = in.read(bytes);\r
-                               if (read_bytes == -1) break;\r
-\r
-                               out.write(bytes, 0, read_bytes);\r
-                       }\r
-                       out.close();\r
-                       in.close();\r
-                       System.load(so);\r
-               } catch (FileNotFoundException e) {\r
-                       throw new RuntimeException("couldn't write " + library + " to temporary file " + so);\r
-               } catch (IOException e) {\r
-                       throw new RuntimeException("couldn't write " + library + " to temporary file " + so);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Constructor loading the libraries if needed and creating/reusing a {@link GLContext}. A standard back/depth/stencil buffer\r
-        * combination is created (32-bit, 16-bit, 8-bit). Additionally an animator thread is created that is responsible for redrawing\r
-        * the panel as fast as possible in case the continous flag is set to true. Keyboard and Mouse events are processed by the\r
-        * panel so that a client can poll for specific states.\r
-        */\r
-       JoglPanel (Application application) {\r
-               super();\r
-               loadLibraries();\r
-\r
-               GLCapabilities caps = new GLCapabilities();\r
-               caps.setRedBits(8);\r
-               caps.setGreenBits(8);\r
-               caps.setBlueBits(8);\r
-               caps.setAlphaBits(8);\r
-               caps.setDepthBits(16);\r
-               caps.setStencilBits(8);\r
-               caps.setNumSamples(0);\r
-               caps.setSampleBuffers(false);\r
-               caps.setDoubleBuffered(true);\r
-\r
-               if (context == null) {\r
-                       canvas = new GLCanvas(caps);\r
-                       context = canvas.getContext();\r
-               } else\r
-                       canvas = new GLCanvas(caps, null, context, null);\r
-\r
-               canvas.addGLEventListener(this);\r
-               this.setLayout(new BorderLayout());\r
-               add(canvas, BorderLayout.CENTER);\r
-\r
-               animator = new Animator(canvas);\r
-               animator.setRunAsFastAsPossible(true);\r
-               animator.start();\r
-\r
-               canvas.addMouseListener(this);\r
-               canvas.addMouseMotionListener(this);\r
-               canvas.addKeyListener(this);\r
-       }\r
-\r
-       /**\r
-        * stops the animator thread and releases any resources\r
-        */\r
-       public void dispose () {\r
-               if (animator != null) animator.stop();\r
-               canvas.getContext().makeCurrent();\r
-               for (RenderListener listener : listeners)\r
-                       listener.dispose();\r
-               remove(canvas);\r
-       }\r
-\r
-       /**\r
-        * @return the delta time between the current and last frame\r
-        */\r
-       public float getDeltaTime () {\r
-               return mean.hasEnoughData() ? mean.getMean() : deltaTime;\r
-       }\r
-\r
-       /**\r
-        * @return the underlying GLCanvas\r
-        */\r
-       public GLCanvas getCanvas () {\r
-               return canvas;\r
-       }\r
-\r
-       /**\r
-        * sets wheter vsynch is enabled or disabled. true by default.\r
-        * \r
-        * @param v_synch\r
-        */\r
-       public void setVerticalSynch (boolean v_synch) {\r
-               this.vSynch = v_synch;\r
-               if (v_synch)\r
-                       GLContext.getCurrent().getGL().setSwapInterval(1);\r
-               else\r
-                       GLContext.getCurrent().getGL().setSwapInterval(0);\r
-       }\r
-\r
-       /**\r
-        * @return wheter vsynch is on or not\r
-        */\r
-       public boolean getVerticalSynch () {\r
-               return vSynch;\r
-       }\r
-\r
-       public void mouseDragged (MouseEvent arg0) {\r
-               mousePosition.x = arg0.getX();\r
-               mousePosition.y = arg0.getY();\r
-\r
-       }\r
-\r
-       public void mouseMoved (MouseEvent arg0) {\r
-               mousePosition.x = arg0.getX();\r
-               mousePosition.y = arg0.getY();\r
-       }\r
-\r
-       public int getMouseX () {\r
-               return mousePosition.x;\r
-       }\r
-\r
-       public int getMouseY () {\r
-               return mousePosition.y;\r
-       }\r
-\r
-       public void mouseClicked (MouseEvent arg0) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       public void mouseEntered (MouseEvent arg0) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       public void mouseExited (MouseEvent arg0) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       public void mousePressed (MouseEvent arg0) {\r
-               buttons.add(arg0.getButton());\r
-       }\r
-\r
-       public void mouseReleased (MouseEvent arg0) {\r
-               buttons.remove(arg0.getButton());\r
-       }\r
-\r
-       public void keyPressed (KeyEvent arg0) {\r
-               keys.add(JoglInputMultiplexer.translateKeyCode(arg0.getKeyCode()));\r
-       }\r
-\r
-       public void keyReleased (KeyEvent arg0) {\r
-// getCanvas().getContext().makeCurrent();\r
-               keys.remove(JoglInputMultiplexer.translateKeyCode(arg0.getKeyCode()));\r
-       }\r
-\r
-       public void keyTyped (KeyEvent arg0) {\r
-\r
-       }\r
-\r
-       /**\r
-        * returns wheter the given mousebutton is down. use the constants in {@link MouseEvent}.\r
-        * \r
-        * @param button the button in question\r
-        * @return wheter the button is down or not\r
-        */\r
-       public boolean isButtonDown (int button) {\r
-               return buttons.size() > 0;\r
-       }\r
-\r
-       /**\r
-        * returns wheter the given key is down. use the constants in {@link KeyEvent}.\r
-        * \r
-        * @param key the key in question\r
-        * @return wheter the key is down or not\r
-        */\r
-       public boolean isKeyDown (int key) {\r
-               return keys.contains(key);\r
-       }\r
-\r
-       /**\r
-        * adds a new graphic listener\r
-        * @param listener the listener\r
-        */\r
-       public void addGraphicListener (RenderListener listener) {\r
-               synchronized (this) {\r
-                       setupListeners.add(listener);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * removes a graphic listener\r
-        * @param listener the listener\r
-        */\r
-       public void removeGraphicListener (RenderListener listener) {\r
-               synchronized (this) {\r
-                       setupListeners.remove(listener);\r
-                       listeners.remove(listener);\r
-                       listener.dispose();\r
-               }\r
-       }\r
-\r
-       @Override public void display (GLAutoDrawable arg0) {\r
-               if (multiplexer != null) multiplexer.processEvents();\r
-               deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;\r
-               frameStart = System.nanoTime();\r
-               mean.addValue(deltaTime);\r
-\r
-               synchronized (this) {\r
-                       for (RenderListener listener : setupListeners) {\r
-                               listener.surfaceCreated();\r
-                               listener.surfaceChanged(this.getWidth(), this.getHeight());\r
-                       }\r
-                       listeners.addAll(setupListeners);\r
-                       setupListeners.clear();\r
-\r
-                       for (RenderListener listener : listeners)\r
-                               listener.render();\r
-               }\r
-\r
-       }\r
-\r
-       @Override public void displayChanged (GLAutoDrawable arg0, boolean arg1, boolean arg2) {\r
-               deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;\r
-               frameStart = System.nanoTime();\r
-\r
-               for (RenderListener listener : listeners)\r
-                       listener.render();\r
-       }\r
-\r
-       @Override public void init (GLAutoDrawable arg0) {\r
-               for (RenderListener listener : listeners)\r
-                       listener.surfaceCreated();\r
-               setVerticalSynch(true);\r
-       }\r
-\r
-       @Override public void reshape (GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {\r
-               deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;\r
-               frameStart = System.nanoTime();\r
-\r
-               for (RenderListener listener : listeners) {\r
-                       listener.surfaceChanged(this.getWidth(), this.getHeight());\r
-                       listener.render();\r
-               }\r
-       }\r
-\r
-       /**\r
-        * @return the gl context this panel works on\r
-        */\r
-       public GL getGL () {\r
-               return canvas.getGL();\r
-       }\r
-\r
-       public Point getLastMousePosition () {\r
-               return mousePosition;\r
-       }\r
-\r
-       public void setInputMultiplexer (JoglInputMultiplexer inputMultiplexer) {\r
-               multiplexer = inputMultiplexer;\r
-       }\r
-\r
-       public boolean isAnyKeyDown () {\r
-               return keys.size() > 0;\r
-       }\r
-}\r
similarity index 92%
rename from backends/gdx-backend-desktop/.classpath
rename to backends/gdx-backend-jogl/.classpath
index bf21c6a..c242aa3 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <classpath>\r
-       <classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
+       <classpathentry kind="src" path="src"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
        <classpathentry combineaccessrules="false" kind="src" path="/gdx"/>\r
-       <classpathentry exported="true" kind="lib" path="/dependencies/javazoom-spi.jar"/>\r
        <classpathentry exported="true" kind="lib" path="/dependencies/gluegen-rt.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="/dependencies/javazoom-spi.jar"/>\r
        <classpathentry exported="true" kind="lib" path="/dependencies/jl1.0.1.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="/dependencies/jogl-natives.jar"/>\r
        <classpathentry exported="true" kind="lib" path="/dependencies/jogl.jar"/>\r
        <classpathentry exported="true" kind="lib" path="/dependencies/jorbis.jar"/>\r
-       <classpathentry exported="true" kind="lib" path="/dependencies/jogl-natives.jar"/>\r
        <classpathentry exported="true" kind="lib" path="/dependencies/tritonus-utils.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
similarity index 87%
rename from tests/gdx-tests-desktop/.project
rename to backends/gdx-backend-jogl/.project
index 4a765a0..26d4f95 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <projectDescription>\r
-       <name>gdx-tests-desktop</name>\r
+       <name>gdx-backend-jogl</name>\r
        <comment></comment>\r
        <projects>\r
        </projects>\r
diff --git a/backends/gdx-backend-jogl/.settings/org.eclipse.jdt.core.prefs b/backends/gdx-backend-jogl/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..67539e7
--- /dev/null
@@ -0,0 +1,12 @@
+#Mon Nov 01 14:12:24 CET 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglApplication.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglApplication.java
new file mode 100644 (file)
index 0000000..cd98081
--- /dev/null
@@ -0,0 +1,192 @@
+/*******************************************************************************\r
+ * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
+ * License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ ******************************************************************************/\r
+\r
+package com.badlogic.gdx.backends.jogl;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.event.WindowAdapter;\r
+import java.awt.event.WindowEvent;\r
+\r
+import javax.swing.JFrame;\r
+\r
+import com.badlogic.gdx.Application;\r
+import com.badlogic.gdx.ApplicationListener;\r
+import com.badlogic.gdx.Audio;\r
+import com.badlogic.gdx.Files;\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.Graphics;\r
+import com.badlogic.gdx.Input;\r
+import com.badlogic.gdx.InputProcessor;\r
+import com.badlogic.gdx.Version;\r
+\r
+/**\r
+ * An implemenation of the {@link Application} interface based on Jogl for Windows, Linux and Mac. Instantiate this class with\r
+ * apropriate parameters and then register {@link ApplicationListener}, {@link RenderListener} or {@link InputProcessor} instances.\r
+ * \r
+ * @author mzechner\r
+ * \r
+ */\r
+public final class JoglApplication implements Application {\r
+       static {\r
+               Version.loadLibrary();\r
+       }\r
+\r
+       final JoglGraphics graphics;    \r
+       final JoglInput input;  \r
+       final JoglFiles files;  \r
+       final JoglAudio audio;  \r
+       JFrame frame;\r
+       \r
+\r
+       /**\r
+        * Creates a new {@link JoglApplication} with the given title and dimensions. If useGL20IfAvailable is set the JoglApplication\r
+        * will try to create an OpenGL 2.0 context which can then be used via {@link JoglApplication.getGraphics().getGL20()}. To query whether enabling OpenGL 2.0\r
+        * was successful use the {@link JoglApplication.getGraphics().isGL20Available()} method.\r
+        * \r
+        * @param listener the ApplicationListener implementing the program logic\r
+        * @param title the title of the application\r
+        * @param width the width of the surface in pixels\r
+        * @param height the height of the surface in pixels\r
+        * @param useGL20IfAvailable wheter to use OpenGL 2.0 if it is available or not\r
+        */\r
+       public JoglApplication (ApplicationListener listener, String title, int width, int height, boolean useGL20IfAvailable) {\r
+               graphics = new JoglGraphics(listener, title, width, height, useGL20IfAvailable);\r
+               input = new JoglInput(graphics.getCanvas());\r
+               audio = new JoglAudio();\r
+               files = new JoglFiles();\r
+\r
+               Gdx.app = this;\r
+               Gdx.graphics = this.getGraphics();\r
+               Gdx.input = this.getInput();\r
+               Gdx.audio = this.getAudio();\r
+               Gdx.files = this.getFiles();\r
+               \r
+               initialize(title, width, height);\r
+       }\r
+       \r
+       private void initialize(String title, int width, int height) {\r
+               graphics.getCanvas().setPreferredSize(new Dimension(width, height));\r
+               \r
+               frame = new JFrame(title);              \r
+               frame.setSize(width + frame.getInsets().left + frame.getInsets().right, frame.getInsets().top + frame.getInsets().bottom\r
+                       + height);\r
+               frame.add(graphics.getCanvas(), BorderLayout.CENTER);           \r
+               frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);\r
+               frame.setLocationRelativeTo(null);\r
+               \r
+               frame.addWindowListener( new WindowAdapter() {          \r
+                       @Override\r
+                       public void windowOpened(WindowEvent arg0) {\r
+                               graphics.getCanvas().requestFocus();\r
+                               graphics.getCanvas().requestFocusInWindow();                            \r
+                       }\r
+                       \r
+                       @Override\r
+                       public void windowIconified(WindowEvent arg0) {                 \r
+                               graphics.pause();                               \r
+                       }\r
+                       \r
+                       @Override\r
+                       public void windowDeiconified(WindowEvent arg0) {\r
+                               graphics.resume();\r
+                       }               \r
+                       \r
+                       @Override\r
+                       public void windowClosing(WindowEvent arg0) {\r
+                               graphics.pause();                               \r
+                               graphics.destroy();\r
+                               frame.remove(graphics.getCanvas());\r
+                       }                               \r
+               });\r
+               \r
+               frame.pack();\r
+               frame.setVisible(true);\r
+               graphics.create();\r
+       }\r
+\r
+       /**\r
+        * {@inheritDoc}\r
+        */\r
+       @Override public Audio getAudio () {\r
+               return audio;\r
+       }\r
+\r
+       /**\r
+        * {@inheritDoc}\r
+        */\r
+       @Override public Files getFiles () {\r
+               return files;\r
+       }\r
+\r
+       /**\r
+        * {@inheritDoc}\r
+        */\r
+       @Override public Graphics getGraphics () {\r
+               return graphics;\r
+       }\r
+\r
+       /**\r
+        * {@inheritDoc}\r
+        */\r
+       @Override public Input getInput () {\r
+               return input;\r
+       }\r
+\r
+       @Override public void log (String tag, String message) {\r
+               System.out.println(tag + ": " + message);\r
+       }\r
+\r
+       /**\r
+        * {@inheritDoc}\r
+        */\r
+       @Override public ApplicationType getType () {\r
+               return ApplicationType.Desktop;\r
+       }\r
+\r
+       @Override public int getVersion () {\r
+               return 0;\r
+       }\r
+\r
+       public static void main(String[] argv) {\r
+               ApplicationListener listener = new ApplicationListener() {\r
+                       \r
+                       @Override\r
+                       public void resume() {\r
+                               System.out.println("resumed");\r
+                       }\r
+                       \r
+                       @Override\r
+                       public void render() {\r
+                               System.out.println("render");                           \r
+                       }\r
+                       \r
+                       @Override\r
+                       public void pause() {\r
+                               System.out.println("paused");                           \r
+                       }\r
+                       \r
+                       @Override\r
+                       public void destroy() {\r
+                               System.out.println("destroy");                          \r
+                       }\r
+                       \r
+                       @Override\r
+                       public void create() {\r
+                               System.out.println("created");                          \r
+                       }\r
+               };\r
+               \r
+               new JoglApplication(listener, "Jogl Application Test", 480, 320, false);\r
+       }\r
+}\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import javax.sound.sampled.AudioFormat;\r
 import javax.sound.sampled.AudioSystem;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import javax.sound.sampled.AudioFormat;\r
 import javax.sound.sampled.AudioFormat.Encoding;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.io.File;\r
 import java.io.FileInputStream;\r
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.nio.Buffer;\r
-import java.nio.ByteBuffer;\r
-import java.nio.ByteOrder;\r
 import java.nio.FloatBuffer;\r
 import java.nio.IntBuffer;\r
 \r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.nio.Buffer;\r
 import java.nio.FloatBuffer;\r
@@ -19,7 +19,6 @@ import java.nio.IntBuffer;
 \r
 import javax.media.opengl.GL;\r
 \r
-import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.GL11;\r
 \r
 /**\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.nio.Buffer;\r
 import java.nio.ByteBuffer;\r
diff --git a/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphics.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphics.java
new file mode 100644 (file)
index 0000000..50418f7
--- /dev/null
@@ -0,0 +1,84 @@
+package com.badlogic.gdx.backends.jogl;\r
+\r
+import javax.media.opengl.GLAutoDrawable;\r
+import javax.media.opengl.GLContext;\r
+import javax.media.opengl.GLEventListener;\r
+\r
+import com.badlogic.gdx.ApplicationListener;\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.Graphics;\r
+import com.badlogic.gdx.utils.GdxRuntimeException;\r
+\r
+/**\r
+ * Implements the {@link Graphics} interface with Jogl.\r
+ * \r
+ * @author mzechner\r
+ * \r
+ */\r
+public class JoglGraphics extends JoglGraphicsBase implements GLEventListener {                \r
+       ApplicationListener listener = null;    \r
+       boolean useGL2; \r
+       boolean created = false;\r
+\r
+       public JoglGraphics(ApplicationListener listener, String title, int width, int height, boolean useGL2) {\r
+               initialize(title, width, height, useGL2);\r
+               if(listener==null) throw new GdxRuntimeException("RenderListener must not be null");\r
+               this.listener = listener;\r
+       }       \r
+       \r
+       public void create () {\r
+               super.create();\r
+       }\r
+       \r
+       public void pause () {\r
+               super.pause();\r
+               canvas.getContext().makeCurrent();              \r
+               listener.pause();\r
+       }\r
+       \r
+       public void resume () {         \r
+               canvas.getContext().makeCurrent();\r
+               listener.resume();\r
+               super.resume();\r
+       }\r
+\r
+       @Override\r
+       public void init(GLAutoDrawable drawable) {\r
+               initializeGLInstances(drawable);                \r
+               \r
+               if( !created ) {                                \r
+                       listener.create();\r
+                       synchronized (this) {\r
+                               paused = false;\r
+                       }       \r
+                       created = true;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void reshape(GLAutoDrawable drawable, int x, int y, int width,\r
+                       int height) {   \r
+       }\r
+       \r
+       @Override\r
+       public void display(GLAutoDrawable arg0) {                              \r
+               synchronized (this) {\r
+                       if (!paused) {\r
+                               updateTimes();\r
+                               listener.render();\r
+                       }\r
+               }               \r
+               \r
+               Gdx.input.processEvents(null);\r
+       }\r
+       \r
+       @Override\r
+       public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {\r
+\r
+       }\r
+\r
+       public void destroy() {         \r
+               canvas.getContext().makeCurrent();\r
+               listener.destroy();\r
+       }\r
+}\r
diff --git a/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphicsBase.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphicsBase.java
new file mode 100644 (file)
index 0000000..303dcb1
--- /dev/null
@@ -0,0 +1,261 @@
+package com.badlogic.gdx.backends.jogl;\r
+\r
+import java.awt.image.BufferedImage;\r
+import java.io.InputStream;\r
+\r
+import javax.imageio.ImageIO;\r
+import javax.media.opengl.GL;\r
+import javax.media.opengl.GLAutoDrawable;\r
+import javax.media.opengl.GLCanvas;\r
+import javax.media.opengl.GLCapabilities;\r
+import javax.media.opengl.GLEventListener;\r
+\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.Graphics;\r
+import com.badlogic.gdx.files.FileHandle;\r
+import com.badlogic.gdx.graphics.GL10;\r
+import com.badlogic.gdx.graphics.GL11;\r
+import com.badlogic.gdx.graphics.GL20;\r
+import com.badlogic.gdx.graphics.GLCommon;\r
+import com.badlogic.gdx.graphics.Pixmap;\r
+import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.Pixmap.Format;\r
+import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
+import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
+import com.badlogic.gdx.math.WindowedMean;\r
+import com.badlogic.gdx.utils.GdxRuntimeException;\r
+import com.sun.opengl.util.Animator;\r
+\r
+public abstract class JoglGraphicsBase implements Graphics, GLEventListener {\r
+       GLCanvas canvas;\r
+       Animator animator;      \r
+       boolean useGL2;\r
+       long frameStart = System.nanoTime();\r
+       long lastFrameTime = System.nanoTime();\r
+       float deltaTime = 0;\r
+       WindowedMean mean = new WindowedMean(10);\r
+       int fps;\r
+       int frames;\r
+       boolean paused = true;\r
+       \r
+       GLCommon gl;\r
+       GL10 gl10;\r
+       GL11 gl11;\r
+       GL20 gl20;\r
+       \r
+       void initialize(String title, int width, int height, boolean useGL2) {\r
+               JoglNativesLoader.loadLibraries();\r
+\r
+               GLCapabilities caps = new GLCapabilities();\r
+               caps.setRedBits(8);\r
+               caps.setGreenBits(8);\r
+               caps.setBlueBits(8);\r
+               caps.setAlphaBits(8);\r
+               caps.setDepthBits(16);\r
+               caps.setStencilBits(8);\r
+               caps.setNumSamples(0);\r
+               caps.setSampleBuffers(false);\r
+               caps.setDoubleBuffered(true);\r
+               \r
+               canvas = new GLCanvas(caps);\r
+\r
+               canvas.addGLEventListener(this);\r
+               this.useGL2 = useGL2;\r
+       }\r
+       \r
+       GLCanvas getCanvas() {\r
+               return canvas;\r
+       }\r
+\r
+       void create() {         \r
+               frameStart = System.nanoTime();\r
+               lastFrameTime = frameStart;\r
+               deltaTime = 0;\r
+               mean.clear();   \r
+               animator = new Animator(canvas);\r
+               animator.setRunAsFastAsPossible(true);\r
+               animator.start();\r
+       }\r
+\r
+       void pause() {\r
+               synchronized (this) {\r
+                       paused = true;\r
+               }\r
+               animator.stop();\r
+       }\r
+       \r
+       void resume() {         \r
+               paused = false;         \r
+               frameStart = System.nanoTime();\r
+               lastFrameTime = frameStart;\r
+               deltaTime = 0;\r
+               mean.clear();                   \r
+               animator = new Animator(canvas);\r
+               animator.setRunAsFastAsPossible(true);\r
+               animator.start();\r
+       }       \r
+       \r
+       void initializeGLInstances (GLAutoDrawable drawable) {\r
+               String version = drawable.getGL().glGetString(GL.GL_VERSION);\r
+               int major = Integer.parseInt("" + version.charAt(0));\r
+               int minor = Integer.parseInt("" + version.charAt(2));\r
+\r
+               if (useGL2 && major >= 2) {\r
+                       gl20 = new JoglGL20(drawable.getGL());\r
+                       gl = gl20;\r
+               } else {\r
+                       if (major == 1 && minor < 5) {\r
+                               gl10 = new JoglGL10(drawable.getGL());\r
+                       } else {\r
+                               gl11 = new JoglGL11(drawable.getGL());\r
+                               gl10 = gl11;\r
+                       }\r
+                       gl = gl10;\r
+               }\r
+               \r
+               Gdx.gl = gl;\r
+               Gdx.gl10 = gl10;\r
+               Gdx.gl11 = gl11;\r
+               Gdx.gl20 = gl20;\r
+       }\r
+       \r
+       void updateTimes () {\r
+               deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;\r
+               lastFrameTime = System.nanoTime();\r
+               mean.addValue(deltaTime);\r
+               \r
+               if (System.nanoTime() - frameStart > 1000000000) {\r
+                       fps = frames;\r
+                       frames = 0;\r
+                       frameStart = System.nanoTime();\r
+               }\r
+               frames++;\r
+       }\r
+       \r
+       @Override\r
+       public float getDeltaTime() {\r
+               return mean.getMean() == 0 ? deltaTime : mean.getMean();\r
+       }\r
+\r
+       @Override\r
+       public int getFramesPerSecond() {\r
+               return fps;\r
+       }\r
+       \r
+       @Override\r
+       public int getHeight() {\r
+               return canvas.getHeight();\r
+       }\r
+\r
+       @Override\r
+       public int getWidth() {\r
+               return canvas.getWidth();\r
+       }\r
+       \r
+       @Override\r
+       public GL10 getGL10() { \r
+               return gl10;\r
+       }\r
+\r
+       @Override\r
+       public GL11 getGL11() {         \r
+               return gl11;\r
+       }\r
+\r
+       @Override\r
+       public GL20 getGL20() {         \r
+               return gl20;\r
+       }\r
+\r
+       @Override\r
+       public GLCommon getGLCommon() {\r
+               return gl;\r
+       }\r
+       \r
+       @Override\r
+       public boolean isGL11Available() {\r
+               return gl11 != null;\r
+       }\r
+\r
+       @Override\r
+       public boolean isGL20Available() {\r
+               return gl20 != null;\r
+       }\r
+       \r
+       @Override\r
+       public GraphicsType getType() {\r
+               return GraphicsType.JoglGL;\r
+       }\r
+\r
+       @Override\r
+       public Pixmap newPixmap(int width, int height, Format format) {\r
+               return new JoglPixmap(width, height, format);\r
+       }\r
+\r
+       @Override\r
+       public Pixmap newPixmap(InputStream in) {\r
+               try {\r
+                       BufferedImage img = (BufferedImage) ImageIO.read(in);\r
+                       return new JoglPixmap(img);\r
+               } catch (Exception ex) {\r
+                       throw new GdxRuntimeException(\r
+                                       "Couldn't load Pixmap from InputStream", ex);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public Pixmap newPixmap(FileHandle file) {\r
+               return newPixmap(file.getInputStream());\r
+       }\r
+\r
+       @Override\r
+       public Pixmap newPixmap(Object nativePixmap) {\r
+               return new JoglPixmap((BufferedImage) nativePixmap);\r
+       }\r
+\r
+       private static boolean isPowerOfTwo(int value) {\r
+               return ((value != 0) && (value & (value - 1)) == 0);\r
+       }\r
+\r
+       @Override\r
+       public Texture newUnmanagedTexture(int width, int height,\r
+                       Pixmap.Format format, TextureFilter minFilter,\r
+                       TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {\r
+               if (!isPowerOfTwo(width) || !isPowerOfTwo(height))\r
+                       throw new GdxRuntimeException(\r
+                                       "Texture dimensions must be a power of two");\r
+\r
+               if (format == Format.Alpha)\r
+                       return new JoglTexture(width, height, BufferedImage.TYPE_BYTE_GRAY,\r
+                                       minFilter, magFilter, uWrap, vWrap, false);\r
+               else\r
+                       return new JoglTexture(width, height,\r
+                                       BufferedImage.TYPE_4BYTE_ABGR, minFilter, magFilter, uWrap,\r
+                                       vWrap, false);\r
+       }\r
+\r
+       @Override\r
+       public Texture newUnmanagedTexture(Pixmap pixmap, TextureFilter minFilter,\r
+                       TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {\r
+               if (!isPowerOfTwo(pixmap.getHeight())\r
+                               || !isPowerOfTwo(pixmap.getWidth()))\r
+                       throw new GdxRuntimeException(\r
+                                       "Texture dimensions must be a power of two");\r
+\r
+               return new JoglTexture((BufferedImage) pixmap.getNativePixmap(),\r
+                               minFilter, magFilter, uWrap, vWrap, false);\r
+       }\r
+\r
+       @Override\r
+       public Texture newTexture(FileHandle file, TextureFilter minFilter,\r
+                       TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {\r
+               Pixmap pixmap = newPixmap(file);\r
+               if (!isPowerOfTwo(pixmap.getHeight())\r
+                               || !isPowerOfTwo(pixmap.getWidth()))\r
+                       throw new GdxRuntimeException(\r
+                                       "Texture dimensions must be a power of two");\r
+\r
+               return new JoglTexture((BufferedImage) pixmap.getNativePixmap(),\r
+                               minFilter, magFilter, uWrap, vWrap, false);\r
+       }\r
+}\r
diff --git a/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglInput.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglInput.java
new file mode 100644 (file)
index 0000000..bcf8e18
--- /dev/null
@@ -0,0 +1,377 @@
+package com.badlogic.gdx.backends.jogl;\r
+\r
+import java.awt.event.KeyListener;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.awt.event.MouseMotionListener;\r
+import java.util.ArrayList;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import javax.media.opengl.GLCanvas;\r
+import javax.swing.JOptionPane;\r
+import javax.swing.SwingUtilities;\r
+\r
+import com.badlogic.gdx.Input;\r
+import com.badlogic.gdx.InputProcessor;\r
+import com.badlogic.gdx.utils.Pool;\r
+import com.badlogic.gdx.utils.Pool.PoolObjectFactory;\r
+\r
+public class JoglInput implements Input, MouseMotionListener, MouseListener,\r
+               KeyListener {\r
+       class KeyEvent {\r
+               static final int KEY_DOWN = 0;\r
+               static final int KEY_UP = 1;\r
+               static final int KEY_TYPED = 2;\r
+\r
+               int type;\r
+               int keyCode;\r
+               char keyChar;\r
+       }\r
+\r
+       class TouchEvent {\r
+               static final int TOUCH_DOWN = 0;\r
+               static final int TOUCH_UP = 1;\r
+               static final int TOUCH_DRAGGED = 2;\r
+\r
+               int type;\r
+               int x;\r
+               int y;\r
+               int pointer;\r
+       }\r
+\r
+       Pool<KeyEvent> freeKeyEvents = new Pool<KeyEvent>(\r
+                       new PoolObjectFactory<KeyEvent>() {\r
+\r
+                               @Override\r
+                               public KeyEvent createObject() {\r
+                                       return new KeyEvent();\r
+                               }\r
+                       }, 1000);\r
+\r
+       Pool<TouchEvent> freeTouchEvents = new Pool<TouchEvent>(\r
+                       new PoolObjectFactory<TouchEvent>() {\r
+\r
+                               @Override\r
+                               public TouchEvent createObject() {\r
+                                       return new TouchEvent();\r
+                               }\r
+                       }, 1000);\r
+\r
+       List<KeyEvent> keyEvents = new ArrayList<KeyEvent>();\r
+       List<TouchEvent> touchEvents = new ArrayList<TouchEvent>();\r
+       int touchX = 0;\r
+       int touchY = 0;\r
+       boolean touchDown = false;\r
+       Set<Integer> keys = new HashSet<Integer>();     \r
+\r
+       public JoglInput(GLCanvas canvas) {\r
+               canvas.addMouseListener(this);\r
+               canvas.addMouseMotionListener(this);\r
+               canvas.addKeyListener(this);            \r
+       }\r
+\r
+       @Override\r
+       public float getAccelerometerX() {\r
+               return 0;\r
+       }\r
+\r
+       @Override\r
+       public float getAccelerometerY() {\r
+               return 0;\r
+       }\r
+\r
+       @Override\r
+       public float getAccelerometerZ() {\r
+               return 0;\r
+       }\r
+\r
+       @Override\r
+       public void getTextInput(final TextInputListener listener, final String title,\r
+                       final String text) {\r
+               SwingUtilities.invokeLater(new Runnable() {\r
+                       @Override public void run () {\r
+                               String output = JOptionPane.showInputDialog(null, title, text);\r
+                               if (output != null) listener.input(output);\r
+                       }\r
+               });\r
+       }\r
+\r
+       @Override\r
+       public int getX() {\r
+               return touchX;\r
+       }\r
+\r
+       @Override\r
+       public int getX(int pointer) {\r
+               if (pointer == 0)\r
+                       return touchX;\r
+               else\r
+                       return 0;\r
+       }\r
+\r
+       @Override\r
+       public int getY() {\r
+               return touchY;\r
+       }\r
+\r
+       @Override\r
+       public int getY(int pointer) {\r
+               if (pointer == 0)\r
+                       return touchY;\r
+               else\r
+                       return 0;                               \r
+       }\r
+\r
+       @Override\r
+       public boolean isAccelerometerAvailable() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public boolean isKeyPressed(int key) {\r
+               synchronized(this) {\r
+                       if( key == Input.Keys.ANY_KEY )\r
+                               return keys.size() > 0;\r
+                       else\r
+                               return keys.contains(key);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public boolean isTouched() {\r
+               return touchDown;\r
+       }\r
+\r
+       @Override\r
+       public boolean isTouched(int pointer) {\r
+               if (pointer == 0)\r
+                       return touchDown;\r
+               else\r
+                       return false;\r
+       }\r
+\r
+       @Override\r
+       public void processEvents(InputProcessor listener) {\r
+               synchronized(this) {\r
+                       if(listener!=null) {                                            \r
+                               for(KeyEvent e: keyEvents) {\r
+                                       switch(e.type) {\r
+                                       case KeyEvent.KEY_DOWN:\r
+                                               listener.keyDown(e.keyCode);\r
+                                               break;\r
+                                       case KeyEvent.KEY_UP:\r
+                                               listener.keyUp(e.keyCode);\r
+                                               break;\r
+                                       case KeyEvent.KEY_TYPED:\r
+                                               listener.keyTyped(e.keyChar);\r
+                                       }\r
+                                       freeKeyEvents.free(e);\r
+                               }                                       \r
+                               \r
+                               for(TouchEvent e: touchEvents) {\r
+                                       switch(e.type) {\r
+                                       case TouchEvent.TOUCH_DOWN:\r
+                                               listener.touchDown(e.x, e.y, e.pointer);\r
+                                               break;\r
+                                       case TouchEvent.TOUCH_UP:\r
+                                               listener.touchUp(e.x, e.y, e.pointer);\r
+                                               break;\r
+                                       case TouchEvent.TOUCH_DRAGGED:\r
+                                               listener.touchDragged(e.x, e.y, e.pointer);\r
+                                       }\r
+                                       freeTouchEvents.free(e);\r
+                               }\r
+                       }\r
+                       \r
+                       keyEvents.clear();\r
+                       touchEvents.clear();\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void setCatchBackKey(boolean catchBack) {\r
+\r
+       }\r
+\r
+       @Override\r
+       public void setOnscreenKeyboardVisible(boolean visible) {\r
+\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsMultitouch() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsOnscreenKeyboard() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public void mouseDragged(MouseEvent e) {\r
+               synchronized(this) {\r
+                       TouchEvent event = freeTouchEvents.newObject();\r
+                       event.pointer = 0;\r
+                       event.x = e.getX();\r
+                       event.y = e.getY();\r
+                       event.type = TouchEvent.TOUCH_DRAGGED;                  \r
+                       touchEvents.add(event);\r
+                       \r
+                       touchX = event.x;\r
+                       touchY = event.y;\r
+                       touchDown = true;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseMoved(MouseEvent arg0) {\r
+\r
+       }\r
+\r
+       @Override\r
+       public void mouseClicked(MouseEvent arg0) {\r
+\r
+       }\r
+\r
+       @Override\r
+       public void mouseEntered(MouseEvent arg0) {\r
+               // TODO Auto-generated method stub\r
+\r
+       }\r
+\r
+       @Override\r
+       public void mouseExited(MouseEvent arg0) {\r
+               // TODO Auto-generated method stub\r
+\r
+       }\r
+\r
+       @Override\r
+       public void mousePressed(MouseEvent e) {\r
+               synchronized(this) {\r
+                       TouchEvent event = freeTouchEvents.newObject();\r
+                       event.pointer = 0;\r
+                       event.x = e.getX();\r
+                       event.y = e.getY();\r
+                       event.type = TouchEvent.TOUCH_DOWN;                     \r
+                       touchEvents.add(event);\r
+                       \r
+                       touchX = event.x;\r
+                       touchY = event.y;\r
+                       touchDown = true;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseReleased(MouseEvent e) {\r
+               synchronized(this) {\r
+                       TouchEvent event = freeTouchEvents.newObject();\r
+                       event.pointer = 0;\r
+                       event.x = e.getX();\r
+                       event.y = e.getY();\r
+                       event.type = TouchEvent.TOUCH_UP;                       \r
+                       touchEvents.add(event);\r
+                       \r
+                       touchX = event.x;\r
+                       touchY = event.y;\r
+                       touchDown = false;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void keyPressed(java.awt.event.KeyEvent e) {\r
+               synchronized(this) {\r
+                       KeyEvent event = freeKeyEvents.newObject();\r
+                       event.keyChar = 0;\r
+                       event.keyCode = translateKeyCode(e.getKeyCode());\r
+                       event.type = KeyEvent.KEY_DOWN;\r
+                       keyEvents.add(event);                   \r
+                       keys.add(event.keyCode);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void keyReleased(java.awt.event.KeyEvent e) {\r
+               synchronized(this) {\r
+                       KeyEvent event = freeKeyEvents.newObject();\r
+                       event.keyChar = 0;\r
+                       event.keyCode = translateKeyCode(e.getKeyCode());\r
+                       event.type = KeyEvent.KEY_UP;\r
+                       keyEvents.add(event);                   \r
+                       keys.remove(event.keyCode);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void keyTyped(java.awt.event.KeyEvent e) {\r
+               synchronized(this) {\r
+                       KeyEvent event = freeKeyEvents.newObject();\r
+                       event.keyChar = e.getKeyChar();\r
+                       event.keyCode = 0;\r
+                       event.type = KeyEvent.KEY_TYPED;        \r
+                       keyEvents.add(event);\r
+               }\r
+       }\r
+\r
+       protected static int translateKeyCode (int keyCode) {\r
+               if (keyCode == java.awt.event.KeyEvent.VK_0) return Input.Keys.KEYCODE_0;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_1) return Input.Keys.KEYCODE_1;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_2) return Input.Keys.KEYCODE_2;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_3) return Input.Keys.KEYCODE_3;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_4) return Input.Keys.KEYCODE_4;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_5) return Input.Keys.KEYCODE_5;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_6) return Input.Keys.KEYCODE_6;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_7) return Input.Keys.KEYCODE_7;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_8) return Input.Keys.KEYCODE_8;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_9) return Input.Keys.KEYCODE_9;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_A) return Input.Keys.KEYCODE_A;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_B) return Input.Keys.KEYCODE_B;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_C) return Input.Keys.KEYCODE_C;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_D) return Input.Keys.KEYCODE_D;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_E) return Input.Keys.KEYCODE_E;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_F) return Input.Keys.KEYCODE_F;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_G) return Input.Keys.KEYCODE_G;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_H) return Input.Keys.KEYCODE_H;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_I) return Input.Keys.KEYCODE_I;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_J) return Input.Keys.KEYCODE_J;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_K) return Input.Keys.KEYCODE_K;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_L) return Input.Keys.KEYCODE_L;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_M) return Input.Keys.KEYCODE_M;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_N) return Input.Keys.KEYCODE_N;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_O) return Input.Keys.KEYCODE_O;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_P) return Input.Keys.KEYCODE_P;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_Q) return Input.Keys.KEYCODE_Q;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_R) return Input.Keys.KEYCODE_R;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_S) return Input.Keys.KEYCODE_S;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_T) return Input.Keys.KEYCODE_T;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_U) return Input.Keys.KEYCODE_U;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_V) return Input.Keys.KEYCODE_V;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_W) return Input.Keys.KEYCODE_W;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_X) return Input.Keys.KEYCODE_X;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_Y) return Input.Keys.KEYCODE_Y;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_Z) return Input.Keys.KEYCODE_Z;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_ALT) return Input.Keys.KEYCODE_ALT_LEFT;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_ALT_GRAPH) return Input.Keys.KEYCODE_ALT_RIGHT;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_BACK_SLASH) return Input.Keys.KEYCODE_BACKSLASH;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_COMMA) return Input.Keys.KEYCODE_COMMA;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_DELETE) return Input.Keys.KEYCODE_DEL;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_LEFT) return Input.Keys.KEYCODE_DPAD_LEFT;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_RIGHT) return Input.Keys.KEYCODE_DPAD_RIGHT;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_UP) return Input.Keys.KEYCODE_DPAD_UP;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_DOWN) return Input.Keys.KEYCODE_DPAD_DOWN;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_ENTER) return Input.Keys.KEYCODE_ENTER;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_HOME) return Input.Keys.KEYCODE_HOME;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_MINUS) return Input.Keys.KEYCODE_MINUS;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_PERIOD) return Input.Keys.KEYCODE_PERIOD;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_PLUS) return Input.Keys.KEYCODE_PLUS;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_SEMICOLON) return Input.Keys.KEYCODE_SEMICOLON;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_SHIFT) return Input.Keys.KEYCODE_SHIFT_LEFT;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_SLASH) return Input.Keys.KEYCODE_SLASH;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_SPACE) return Input.Keys.KEYCODE_SPACE;\r
+               if (keyCode == java.awt.event.KeyEvent.VK_TAB) return Input.Keys.KEYCODE_TAB;\r
+\r
+               return Input.Keys.KEYCODE_UNKNOWN;\r
+       }\r
+}\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.io.File;\r
 import java.io.IOException;\r
diff --git a/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglNativesLoader.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglNativesLoader.java
new file mode 100644 (file)
index 0000000..25d6403
--- /dev/null
@@ -0,0 +1,96 @@
+package com.badlogic.gdx.backends.jogl;\r
+\r
+import java.io.BufferedOutputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+import com.sun.opengl.impl.NativeLibLoader;\r
+\r
+public class JoglNativesLoader {\r
+       static boolean nativesLoaded = false;\r
+       \r
+       /**\r
+        * loads the necessary libraries depending on the operating system\r
+        */\r
+       static void loadLibraries() {\r
+               if (nativesLoaded)\r
+                       return;\r
+\r
+               NativeLibLoader.disableLoading();\r
+               com.sun.gluegen.runtime.NativeLibLoader.disableLoading();\r
+               // By wkien: On some systems (read: mine) jogl_awt would not find its\r
+               // dependency jawt if not loaded before\r
+               System.loadLibrary("jawt");\r
+               loadLibrary("gluegen-rt");\r
+               loadLibrary("jogl_awt");\r
+               loadLibrary("jogl");\r
+\r
+               nativesLoaded = true;\r
+       }\r
+\r
+       /**\r
+        * helper method to load a specific library in an operation system dependant\r
+        * manner\r
+        * \r
+        * @param resource\r
+        *            the name of the resource\r
+        */\r
+       private static void loadLibrary(String resource) {\r
+               String package_path = "/javax/media/";\r
+               String library = "";\r
+\r
+               String os = System.getProperty("os.name");\r
+               String arch = System.getProperty("os.arch");\r
+\r
+               if (os.contains("Windows")) {\r
+                       if (!arch.equals("amd64"))\r
+                               library = resource + "-win32.dll";\r
+                       else {\r
+                               library = resource + "-win64.dll";\r
+                       }\r
+               }\r
+\r
+               if (os.contains("Linux")) {\r
+                       if (!arch.equals("amd64"))\r
+                               library = "lib" + resource + "-linux32.so";\r
+                       else\r
+                               library = "lib" + resource + "-linux64.so";\r
+               }\r
+\r
+               if (os.contains("Mac")) {\r
+                       library = "lib" + resource + ".jnilib";\r
+               }\r
+\r
+               String so = System.getProperty("java.io.tmpdir") + "/"\r
+                               + System.nanoTime() + library;\r
+               InputStream in = JoglGraphics.class.getResourceAsStream(package_path\r
+                               + library);\r
+               if (in == null)\r
+                       throw new RuntimeException("couldn't find " + library\r
+                                       + " in jar file.");\r
+\r
+               try {\r
+                       BufferedOutputStream out = new BufferedOutputStream(\r
+                                       new FileOutputStream(so));\r
+                       byte[] bytes = new byte[1024 * 4];\r
+                       while (true) {\r
+                               int read_bytes = in.read(bytes);\r
+                               if (read_bytes == -1)\r
+                                       break;\r
+\r
+                               out.write(bytes, 0, read_bytes);\r
+                       }\r
+                       out.close();\r
+                       in.close();\r
+                       System.load(so);\r
+               } catch (FileNotFoundException e) {\r
+                       throw new RuntimeException("couldn't write " + library\r
+                                       + " to temporary file " + so);\r
+               } catch (IOException e) {\r
+                       throw new RuntimeException("couldn't write " + library\r
+                                       + " to temporary file " + so);\r
+               }\r
+       }\r
+}\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.awt.AlphaComposite;\r
 import java.awt.BasicStroke;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.io.BufferedInputStream;\r
 import java.io.ByteArrayOutputStream;\r
@@ -11,7 +11,7 @@
  * governing permissions and limitations under the License.\r
  ******************************************************************************/\r
 \r
-package com.badlogic.gdx.backends.desktop;\r
+package com.badlogic.gdx.backends.jogl;\r
 \r
 import java.awt.image.BufferedImage;\r
 import java.io.InputStream;\r
index 657c0ed..abb5a3c 100644 (file)
@@ -166,7 +166,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
                this.width = width;\r
                this.height = height;\r
                for (RenderListener listener : listeners)\r
-                       listener.surfaceChanged(getWidth(), getHeight());\r
+                       listener.resized(getWidth(), getHeight());\r
        }\r
 \r
        void start () throws LWJGLException {\r
@@ -175,7 +175,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
                setupDisplay();\r
 \r
                for (RenderListener listener : listeners)\r
-                       listener.surfaceCreated();\r
+                       listener.created();\r
                setSize(width, height);\r
                graphics.lastTime = System.nanoTime();\r
                for (RenderListener listener : listeners)\r
index d73ba1a..b324670 100644 (file)
@@ -158,7 +158,7 @@ public final class LwjglGraphics implements Graphics, RenderListener {
                frames++;\r
        }\r
 \r
-       public void surfaceCreated () {\r
+       public void created () {\r
                String version = org.lwjgl.opengl.GL11.glGetString(GL11.GL_VERSION);\r
                int major = Integer.parseInt("" + version.charAt(0));\r
                int minor = Integer.parseInt("" + version.charAt(2));\r
@@ -187,7 +187,7 @@ public final class LwjglGraphics implements Graphics, RenderListener {
                return deltaTime;\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
+       public void resized (int width, int height) {\r
        }\r
 \r
        public GraphicsType getType () {\r
index 5873368..43a8aee 100644 (file)
@@ -23,7 +23,7 @@ import org.lwjgl.input.Mouse;
 \r
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.Input;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.RenderListener;\r
 \r
 /**\r
@@ -35,9 +35,9 @@ import com.badlogic.gdx.RenderListener;
 final class LwjglInput implements Input, RenderListener {\r
        String text;\r
        TextInputListener textListener;\r
-       @SuppressWarnings("unchecked") private final ArrayList<InputListener> listeners = new ArrayList();\r
+       @SuppressWarnings("unchecked") private final ArrayList<InputProcessor> listeners = new ArrayList();\r
 \r
-       public void addInputListener (InputListener listener) {\r
+       public void addInputListener (InputProcessor listener) {\r
                listeners.add(listener);\r
        }\r
 \r
@@ -84,7 +84,7 @@ final class LwjglInput implements Input, RenderListener {
                return button;\r
        }\r
 \r
-       public void removeInputListener (InputListener listener) {\r
+       public void removeInputListener (InputProcessor listener) {\r
                listeners.remove(listener);\r
        }\r
 \r
@@ -99,12 +99,12 @@ final class LwjglInput implements Input, RenderListener {
                }\r
        }\r
 \r
-       public void surfaceCreated () {\r
+       public void created () {\r
                // TODO Auto-generated method stub\r
 \r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
+       public void resized (int width, int height) {\r
                // TODO Auto-generated method stub\r
 \r
        }\r
index 5f3831e..d6fad07 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <!-- \r
 \r
  libgdx distribution ant build file. Performs the compilation of the modules\r
- gdx, gdx-backend-android, gdx-backend-desktop\r
+ gdx, gdx-backend-android, gdx-backend-jogl\r
  and creates a distribution out of this mess. \r
 \r
 -->\r
@@ -23,7 +23,7 @@
        <target name="clean">\r
                <delete dir="${stable}"/>\r
                <delete dir="gdx/bin"/>\r
-               <delete dir="backends/gdx-backend-desktop/bin"/>                \r
+               <delete dir="backends/gdx-backend-jogl/bin"/>           \r
                <delete dir="backends/gdx-backend-android/bin"/>\r
        </target>\r
        \r
@@ -32,7 +32,7 @@
                <mkdir dir="${stable}"/>\r
                <mkdir dir="gdx/bin"/>          \r
                <mkdir dir="backends/gdx-backend-android/bin"/>\r
-               <mkdir dir="backends/gdx-backend-desktop/bin"/>\r
+               <mkdir dir="backends/gdx-backend-jogl/bin"/>\r
        </target>\r
        \r
        <!-- compiles the java code of all modules -->\r
@@ -40,8 +40,8 @@
                <!-- build gdx api -->\r
                <javac srcdir="gdx/src" destdir="gdx/bin"/>\r
                \r
-               <!-- build desktop backend -->\r
-               <javac srcdir="backends/gdx-backend-desktop/src" destdir="backends/gdx-backend-desktop/bin">\r
+               <!-- build jogl backend -->\r
+               <javac srcdir="backends/gdx-backend-jogl/src" destdir="backends/gdx-backend-jogl/bin">\r
                        <classpath>\r
                                <pathelement location="gdx/bin"/>\r
                                <pathelement location="backends/dependencies/gluegen-rt.jar"/>\r
@@ -82,8 +82,8 @@
                <delete dir="gdx/bin/ndk"/>\r
                <jar destfile="${stable}/gdx.jar" basedir="gdx/bin"/>\r
                <jar destfile="${stable}/gdx-sources.jar" basedir="gdx/src"/>\r
-               <jar destfile="${stable}/gdx-backend-desktop.jar">\r
-                       <fileset dir="backends/gdx-backend-desktop/bin"/>\r
+               <jar destfile="${stable}/gdx-backend-jogl.jar">\r
+                       <fileset dir="backends/gdx-backend-jogl/bin"/>\r
                        <zipfileset src="backends/dependencies/gluegen-rt.jar"/>\r
                        <zipfileset src="backends/dependencies/javazoom-spi.jar"/>\r
                        <zipfileset src="backends/dependencies/jl1.0.1.jar"/>\r
        <target name="update-demos" depends="dist">\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx.jar" file="${stable}/gdx.jar"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-sources.jar" file="${stable}/gdx-sources.jar"/>\r
-               <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-backend-desktop.jar" file="${stable}/gdx-backend-desktop.jar"/>\r
+               <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-backend-jogl.jar" file="${stable}/gdx-backend-jogl.jar"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx.dll" file="${stable}/gdx.dll" failonerror="false"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/libgdx.so" file="${stable}/libgdx.so" failonerror="false"/>\r
                \r
                \r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx.jar" file="${stable}/gdx.jar"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx-sources.jar" file="${stable}/gdx-sources.jar"/>\r
-               <copy tofile="demos/invaders/gdx-invaders/libs/gdx-backend-desktop.jar" file="${stable}/gdx-backend-desktop.jar"/>\r
+               <copy tofile="demos/invaders/gdx-invaders/libs/gdx-backend-jogl.jar" file="${stable}/gdx-backend-jogl.jar"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx.dll" file="${stable}/gdx.dll" failonerror="false"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/libgdx.so" file="${stable}/libgdx.so" failonerror="false"/>\r
                \r
index 46738af..162c413 100644 (file)
@@ -1135,7 +1135,7 @@ public class Hiero extends JFrame {
        class Renderer implements RenderListener {\r
                private String sampleText;\r
 \r
-               public void surfaceCreated () {\r
+               public void created () {\r
                        glEnable(GL_SCISSOR_TEST);\r
 \r
                        glEnable(GL_TEXTURE_2D);\r
@@ -1151,7 +1151,7 @@ public class Hiero extends JFrame {
                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r
                }\r
 \r
-               public void surfaceChanged (int width, int height) {\r
+               public void resized (int width, int height) {\r
                        glViewport(0, 0, width, height);\r
                        glScissor(0, 0, width, height);\r
 \r
@@ -1263,16 +1263,16 @@ public class Hiero extends JFrame {
        }\r
 \r
        public static void main (String[] args) throws Exception {\r
-               LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();\r
-               for (int i = 0, n = lookAndFeels.length; i < n; i++) {\r
-                       if ("Nimbus".equals(lookAndFeels[i].getName())) {\r
-                               try {\r
-                                       UIManager.setLookAndFeel(lookAndFeels[i].getClassName());\r
-                               } catch (Throwable ignored) {\r
-                               }\r
-                               break;\r
-                       }\r
-               }\r
+//             LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();\r
+//             for (int i = 0, n = lookAndFeels.length; i < n; i++) {\r
+//                     if ("Nimbus".equals(lookAndFeels[i].getName())) {\r
+//                             try {\r
+//                                     UIManager.setLookAndFeel(lookAndFeels[i].getClassName());\r
+//                             } catch (Throwable ignored) {\r
+//                             }\r
+//                             break;\r
+//                     }\r
+//             }\r
                new Hiero();\r
        }\r
 }\r
index 3ad0f4d..46152fc 100644 (file)
@@ -13,14 +13,14 @@ import com.badlogic.gdx.hiero.unicodefont.effects.ColorEffect;
 public class UnicodeFontTest implements RenderListener {\r
        private UnicodeFont unicodeFont;\r
 \r
-       public void surfaceCreated () {\r
+       public void created () {\r
                unicodeFont = new UnicodeFont("c:/windows/fonts/arial.ttf", 48, false, false);\r
                unicodeFont.getEffects().add(new ColorEffect(java.awt.Color.white));\r
                // unicodeFont.addAsciiGlyphs();\r
                // unicodeFont.loadGlyphs();\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
+       public void resized (int width, int height) {\r
                glViewport(0, 0, width, height);\r
                glScissor(0, 0, width, height);\r
                glEnable(GL_SCISSOR_TEST);\r
index ead59b1..4db9576 100644 (file)
@@ -35,7 +35,7 @@ import org.lwjgl.opengl.Display;
 \r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.backends.desktop.LwjglApplication;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
@@ -248,7 +248,7 @@ public class ParticleEditor extends JFrame {
                splitPane.setDividerLocation(325);\r
        }\r
 \r
-       class Renderer implements RenderListener, InputListener {\r
+       class Renderer implements RenderListener, InputProcessor {\r
                private float maxActiveTimer;\r
                private int maxActive, lastMaxActive;\r
                private boolean mouseDown;\r
@@ -258,7 +258,7 @@ public class ParticleEditor extends JFrame {
                private SpriteBatch spriteBatch;\r
                private Sprite bgImage; // BOZO - Add setting background image to UI.\r
 \r
-               public void surfaceCreated () {\r
+               public void created () {\r
                        if (spriteBatch != null) return;\r
                        spriteBatch = new SpriteBatch();\r
 \r
@@ -270,7 +270,7 @@ public class ParticleEditor extends JFrame {
                        Gdx.input.addInputListener(this);\r
                }\r
 \r
-               public void surfaceChanged (int width, int height) {\r
+               public void resized (int width, int height) {\r
                        int viewWidth = Gdx.graphics.getWidth();\r
                        int viewHeight = Gdx.graphics.getHeight();\r
 \r
index 734debf..d3a77de 100644 (file)
@@ -23,7 +23,7 @@ import de.matthiasmann.twl.textarea.Value;
 public class ButtonTest implements RenderListener {\r
        GUI gui;\r
 \r
-       public void surfaceCreated () {\r
+       public void created () {\r
                if (gui != null) return;\r
 \r
                Button button = new Button("Click Me");\r
@@ -42,7 +42,7 @@ public class ButtonTest implements RenderListener {
                gui.update();\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
+       public void resized (int width, int height) {\r
                gui.setSize();\r
        }\r
 \r
index c74b509..7f4b7af 100644 (file)
@@ -22,7 +22,7 @@ import de.matthiasmann.twl.textarea.Value;
 public class TextAreaTest implements RenderListener {\r
        GUI gui;\r
 \r
-       public void surfaceCreated () {\r
+       public void created () {\r
                if (gui != null) return;\r
 \r
                final HTMLTextAreaModel htmlText = new HTMLTextAreaModel();\r
@@ -75,7 +75,7 @@ public class TextAreaTest implements RenderListener {
                gui.update();\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
+       public void resized (int width, int height) {\r
                TwlRenderer.updateSize(gui);\r
        }\r
 \r
index 72c8028..748f3bd 100644 (file)
@@ -1,7 +1,7 @@
 \r
 package com.badlogic.gdx.twl.renderer;\r
 \r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.RenderListener;\r
 \r
 import de.matthiasmann.twl.GUI;\r
@@ -9,7 +9,7 @@ import de.matthiasmann.twl.GUI;
 /**\r
  * @author Nathan Sweet <misc@n4te.com>\r
  */\r
-public class TwlInputListener implements InputListener {\r
+public class TwlInputListener implements InputProcessor {\r
        private final GUI gui;\r
 \r
        public TwlInputListener (GUI gui) {\r
index c99ade7..fd527e5 100644 (file)
@@ -1,8 +1,7 @@
 <!-- \r
 \r
  libgdx distribution ant build file. Performs the compilation of the modules\r
- gdx, gdx-backend-android, gdx-backend-desktop, gdx-backend-applet\r
- and creates a distribution out of this mess. \r
+ gdx, gdx-backend-android, gdx-backend-jogl and creates a distribution out of this mess. \r
 \r
 -->\r
 <project name="gdx" default="all" basedir="../" >\r
@@ -24,7 +23,7 @@
        <target name="clean">\r
                <delete dir="${stable}"/>\r
                <delete dir="gdx/bin"/>\r
-               <delete dir="backends/gdx-backend-desktop/bin"/>                \r
+               <delete dir="backends/gdx-backend-jogl/bin"/>           \r
                <delete dir="backends/gdx-backend-android/bin"/>\r
        </target>\r
        \r
@@ -33,7 +32,7 @@
                <mkdir dir="${stable}"/>\r
                <mkdir dir="gdx/bin"/>          \r
                <mkdir dir="backends/gdx-backend-android/bin"/>\r
-               <mkdir dir="backends/gdx-backend-desktop/bin"/>\r
+               <mkdir dir="backends/gdx-backend-jogl/bin"/>\r
        </target>\r
        \r
        <!-- compiles the java code of all modules -->\r
@@ -41,8 +40,8 @@
                <!-- build gdx api -->\r
                <javac srcdir="gdx/src" destdir="gdx/bin"/>\r
                \r
-               <!-- build desktop backend -->\r
-               <javac srcdir="backends/gdx-backend-desktop/src" destdir="backends/gdx-backend-desktop/bin">\r
+               <!-- build jogl backend -->\r
+               <javac srcdir="backends/gdx-backend-jogl/src" destdir="backends/gdx-backend-jogl/bin">\r
                        <classpath>\r
                                <pathelement location="gdx/bin"/>\r
                                <pathelement location="backends/dependencies/gluegen-rt.jar"/>\r
@@ -84,8 +83,8 @@
                <delete dir="gdx/bin/ndk"/>\r
                <jar destfile="${stable}/gdx.jar" basedir="gdx/bin"/>\r
                <jar destfile="${stable}/gdx-sources.jar" basedir="gdx/src"/>\r
-               <jar destfile="${stable}/gdx-backend-desktop.jar">\r
-                       <fileset dir="backends/gdx-backend-desktop/bin"/>\r
+               <jar destfile="${stable}/gdx-backend-jogl.jar">\r
+                       <fileset dir="backends/gdx-backend-jogl/bin"/>\r
                        <zipfileset src="backends/dependencies/gluegen-rt.jar"/>\r
                        <zipfileset src="backends/dependencies/javazoom-spi.jar"/>\r
                        <zipfileset src="backends/dependencies/jl1.0.1.jar"/>\r
        <target name="update-demos" depends="dist">\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx.jar" file="${stable}/gdx.jar"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-sources.jar" file="${stable}/gdx-sources.jar"/>\r
-               <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-backend-desktop.jar" file="${stable}/gdx-backend-desktop.jar"/>\r
+               <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx-backend-jogl.jar" file="${stable}/gdx-backend-jogl.jar"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/gdx.dll" file="${stable}/gdx.dll" failonerror="false"/>\r
                <copy tofile="demos/helloworld/gdx-helloworld/libs/libgdx.so" file="${stable}/libgdx.so" failonerror="false"/>\r
                \r
                \r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx.jar" file="${stable}/gdx.jar"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx-sources.jar" file="${stable}/gdx-sources.jar"/>\r
-               <copy tofile="demos/invaders/gdx-invaders/libs/gdx-backend-desktop.jar" file="${stable}/gdx-backend-desktop.jar"/>\r
+               <copy tofile="demos/invaders/gdx-invaders/libs/gdx-backend-jogl.jar" file="${stable}/gdx-backend-jogl.jar"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/gdx.dll" file="${stable}/gdx.dll" failonerror="false"/>\r
                <copy tofile="demos/invaders/gdx-invaders/libs/libgdx.so" file="${stable}/libgdx.so" failonerror="false"/>\r
                \r
index 7471161..f1ea34f 100644 (file)
@@ -23,7 +23,8 @@ package com.badlogic.gdx;
  * <p>\r
  * An application can either be a desktop application ({@link JoglApplication}, {@link LwjglApplication}), or an\r
  * Android application ({@link AndroidApplication}). Each application class has it's own startup and initialization methods.\r
- * Please refer to their documentation for more information.\r
+ * Please refer to their documentation for more information. In any case you will have to specify an {@link ApplicationListener} that\r
+ * implements your program logic.\r
  * </p>\r
  * \r
  * <p>\r
@@ -41,7 +42,7 @@ package com.badlogic.gdx;
  * \r
  * <p>\r
  * {@link Input} offers you various methods to poll user input from the keyboard, touch screen, mouse and accelerometer.\r
- * Additionally you can register an {@link InputListener} which allows for event based input processing. The\r
+ * Additionally you can register an {@link InputProcessor} which allows for event based input processing. The\r
  * <code>InputListener</code> will be called in the rendering thread which will also call your <code>RenderListener</code>. This\r
  * way you don't have to care about thread synchronization when you process input events.\r
  * </p>\r
@@ -56,11 +57,6 @@ package com.badlogic.gdx;
  * </p>\r
  * \r
  * <p>\r
- * Additionally an <code>Application</code> allows to set a {@link ApplicationListener} which will be invoked when the\r
- * <code>Application</code> is paused, resumed or closing. This can be used to save any state that needs saving. Note that the\r
- * <code>ApplicationListener<code> will not be called in the rendering thread. \r
- * \r
- * <p>\r
  * Generally you will have two projects for your application. The first one will be the \r
  * desktop project which houses all your application code as well as a {@link JoglApplication}. \r
  * The second project will be the Android project which only contains an Activity derived from {@link AndroidApplication}.\r
@@ -127,11 +123,4 @@ public interface Application {
         * @return the Android API level on Android or 0 on the desktop.\r
         */\r
        public int getVersion ();\r
-\r
-       /**\r
-        * Sets the {@link ApplicationListener} that is called when the {@link Application} is paused, resumed or closing.\r
-        * \r
-        * @param listener the ApplicationListener\r
-        */\r
-       public void setApplicationListener (ApplicationListener listener);\r
 }\r
index 92ce4bc..76cf3c7 100644 (file)
@@ -15,35 +15,44 @@ package com.badlogic.gdx;
 \r
 /**\r
  * <p>\r
- * An <code>ApplicationListener</code> is called when the {@link Application} is resumed, paused and destroyed. This allows you to\r
- * save any states you want to save. The methods are not called from within the rendering thread so care has to be taken. Do not\r
- * load or unload any Graphics related resources in the provided by this interface!\r
+ * An <code>ApplicationListener</code> is called when the {@link Application} is created, resumed, rendering, paused or destroyed. All\r
+ * methods are called in a thread that has the OpenGL context current. You can thus safely create and manipulate graphics resources.\r
  * </p>\r
  * \r
  * <p>\r
  * The <code>ApplicationListener</code> interface follows the standard Android activity life-cycle and is emulated on the desktop\r
- * accordingly. The pause method will be called after the rendering thread has been paused. The resume method will be called\r
- * before the rendering thread has been started.\r
+ * accordingly.\r
+ * </p>\r
  * \r
  * @author mzechner\r
  * \r
  */\r
 public interface ApplicationListener {\r
        /**\r
-        * Called when the {@link Application} is paused. An Application is paused before it is destroyed or when a user pressed the\r
-        * Home button on Android. This will not be called in the rendering thread. Instead the rendering thread will be paused before\r
-        * this method is called.\r
+        * Called when the {@link Application} is first created. \r
         */\r
-       public void pause ();\r
+       public void create ();          \r
 \r
        /**\r
-        * Called when the {@link Application} is resumed from a paused state or the Application was just created. This will not be\r
-        * called in the rendering thread. Instead this callback will be first called, then the rendering thread will be resumed.\r
+        * Called when the {@link Application} is resumed from a paused state. On\r
+        * Android this happens when the activity gets focus again, on the desktop\r
+        * that happens when the application is maximized from a minimzed state.\r
         */\r
        public void resume ();\r
+       \r
+       /**\r
+        * Called when the {@link Application} should render itself.\r
+        */\r
+       public void render ();\r
+       \r
+       /**\r
+        * Called when the {@link Application} is paused. An Application is paused before it is destroyed, when a user pressed the\r
+        * Home button on Android or an incoming call happend or when a window on the desktop is minimized. \r
+        */\r
+       public void pause ();\r
 \r
        /**\r
-        * Called when the {@link Application} is destroyed. This will not be called in the rendering thread.\r
+        * Called when the {@link Application} is destroyed. Preceded by a call to {@link #pause()}.\r
         */\r
        public void destroy ();\r
 }\r
index f40be0b..7553deb 100644 (file)
@@ -65,7 +65,7 @@ public interface Graphics {
        }\r
 \r
        /**\r
-        * Returns whether OpenGL ES 1.1 is available. If it is you can get an instance of {@link GL11} via {@link getGL11()} to access\r
+        * Returns whether OpenGL ES 1.1 is available. If it is you can get an instance of {@link GL11} via {@link #getGL11()} to access\r
         * OpenGL ES 1.1 functionality.\r
         * \r
         * @return whether OpenGL ES 1.1 is available\r
@@ -73,14 +73,11 @@ public interface Graphics {
        public boolean isGL11Available ();\r
 \r
        /**\r
-        * Returns whether OpenGL ES 2.0 is available. If it is you can get an instance of {@link GL20} via {@link getGL20()} to access\r
+        * Returns whether OpenGL ES 2.0 is available. If it is you can get an instance of {@link GL20} via {@link #getGL20()} to access\r
         * OpenGL ES 2.0 functionality. Note that this functionality will only be available if you instructed the Application instance\r
         * to use OpenGL ES 2.0!\r
         * \r
         * @return whether OpenGL ES 2.0 is available\r
-        * \r
-        * @see DesktopApplication\r
-        * @see AndroidApplication\r
         */\r
        public boolean isGL20Available ();\r
 \r
@@ -130,16 +127,6 @@ public interface Graphics {
        public int getFramesPerSecond ();\r
 \r
        /**\r
-        * Sets the {@link RenderListener}. The <code>RenderListener</code> will be called once the OpenGL surface has been setup to\r
-        * give it an opportunity to create all its graphic resources like textures and meshes. After the setup is complete the\r
-        * RenderListener will be called continuously to render new frames. When the {@link Application} is closing the RenderListener\r
-        * will be called one last time to clean up.\r
-        * \r
-        * @param listener the RenderListener\r
-        */\r
-       public void setRenderListener (RenderListener listener);\r
-\r
-       /**\r
         * Creates a new {@link Pixmap} with the specified dimensions and format.\r
         * \r
         * @param width the width in pixels\r
@@ -181,7 +168,7 @@ public interface Graphics {
 \r
        /**\r
         * Creates a new {@link Texture} with the specified dimensions, minification and magnification filters and texture wraps in u\r
-        * and v. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer used. The width and\r
+        * and v. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer used. The width and\r
         * height of the texture have to be a power of two! Textures created via this method can not be managed and have to be\r
         * recreated manually when the OpenGL context is lost.\r
         * \r
@@ -200,8 +187,8 @@ public interface Graphics {
 \r
        /**\r
         * Creates a new {@link Texture} from the given {@link Pixmap} using the specified minification and magnification filter and\r
-        * texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter.MipMap} mip maps will be\r
-        * created automatically. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer used.\r
+        * texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter#MipMap} mip maps will be\r
+        * created automatically. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer used.\r
         * The Pixmap's width and height have to be a power of 2! Textures created via this method can not be managed and have to be\r
         * recreated manually when the OpenGL context is lost.\r
         * \r
@@ -218,8 +205,8 @@ public interface Graphics {
 \r
        /**\r
         * Creates a new {@link Texture} from the given {@link FileHandle} using the specified minification and magnification filter\r
-        * and texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter.MipMap} mip maps will\r
-        * be created automatically. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer\r
+        * and texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter#MipMap} mip maps will\r
+        * be created automatically. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer\r
         * used. The FileHandle must point to a valid Jpg, Bmp or Png file. The Pixmap's width and height have to be a power of 2!\r
         * Textures created via this method are managed and will be recreated automatically after the OpenGL context has been lost and\r
         * recreated.\r
index d4f6a8e..296fb33 100644 (file)
@@ -20,20 +20,8 @@ package com.badlogic.gdx;
  * </p>\r
  * \r
  * <p>\r
- * Additionally one can register an {@link InputListener} with this module. The InputListener will then be called each time a key\r
- * is pressed or released or a touch event occures.\r
- * </p>\r
- * \r
- * <p>\r
- * The InputListener will be called in the rendering thread of the graphics module to which a RenderListener is probably attached.\r
- * This means that one does not have to take precautions to guarantee thread safety. One can safely call graphics methods from\r
- * within the InputListener callbacks.\r
- * </p>\r
- * \r
- * <p>\r
- * One or more InputListeners can be registered with the module. The events will then get passed to the InputListeners in the\r
- * order they have been registered with the module. If an InputListeners signals that it consumed the event the InputListeners\r
- * down the chain will not be invoked.\r
+ * Additionally one can process events with an {@link InputProcessor} with this module. Just pass in the InputListener to the\r
+ * {@link #processEvents(InputProcessor)} method in any thread you want.\r
  * </p>\r
  * \r
  * <p>\r
@@ -165,21 +153,6 @@ public interface Input {
        }\r
 \r
        /**\r
-        * Adds an {@link InputListener}. The order InputListeners are added is the same as the order in which they are called in case\r
-        * of an event. If an input listener signals that it processed the event the event is not passed to the other listeners in the\r
-        * chain.\r
-        * \r
-        * @param listener the listener\r
-        */\r
-       public void addInputListener (InputListener listener);\r
-\r
-       /**\r
-        * Removes the {@link InputListener}.\r
-        * @param listener the listener\r
-        */\r
-       public void removeInputListener (InputListener listener);\r
-\r
-       /**\r
         * @return whether an accelerometer is available\r
         */\r
        public boolean isAccelerometerAvailable ();\r
@@ -285,4 +258,13 @@ public interface Input {
         * @param catchBack whether to catch the back button\r
         */\r
        public void setCatchBackKey( boolean catchBack );\r
+       \r
+       /**\r
+        * Passes all events that happened since the last invocation of this\r
+        * method to the provided InputListener. Make sure you call this method\r
+        * each frame otherwise events will accumulate! \r
+        * \r
+        * @param listener the {@link InputProcessor} or null if you want to just discard of all events.\r
+        */\r
+       public void processEvents(InputProcessor listener);\r
 }\r
index b8f216c..6913ae3 100644 (file)
@@ -2,13 +2,13 @@
 package com.badlogic.gdx;\r
 \r
 /**\r
- * An adapter class for {@link InputListener}. You can derive from this\r
+ * An adapter class for {@link InputProcessor}. You can derive from this\r
  * and only override what you are interested in.\r
  * \r
  * @author mzechner\r
  *\r
  */\r
-public class InputAdapter implements InputListener {\r
+public class InputAdapter implements InputProcessor {\r
        public boolean keyDown (int keycode) {\r
                return false;\r
        }\r
similarity index 75%
rename from gdx/src/com/badlogic/gdx/InputListener.java
rename to gdx/src/com/badlogic/gdx/InputProcessor.java
index 371ef9f..5dc021e 100644 (file)
 package com.badlogic.gdx;\r
 \r
 /**\r
- * An InputListener is used to receive input events from the keyboard and the touch screen (mouse on the desktop). For this it has\r
- * to be registered with the {@link Input} instance of an {@link Application}. The events might arrive asynchronously in a UI\r
- * thread, the {@link Input} instance will buffer those events and invoke the methods of the listener in the rendering thread to\r
- * get rid of the need to synchronize the UI and renderer thread for input. If an InputListener signals that it processed an event\r
- * by returning true the the event will not be passed to other listeners in the listener chain (multiple InputListeners can\r
- * register with an Input instance).\r
+ * An InputPr is used to receive input events from the keyboard and the touch screen (mouse on the desktop). For this it has\r
+ * to be used in combination with {@link Input#processEvents(InputProcessor)} method. The methods return a boolean in case\r
+ * you want to write a multiplexing InputProcessor that has a chain of child processors that signal whether they processed\r
+ * the event. \r
  * \r
  * @author badlogicgames@gmail.com\r
  * \r
  */\r
-public interface InputListener {\r
+public interface InputProcessor {\r
        /**\r
         * Called when a key was pressed\r
         * @param keycode one of the constants in {@link Input.Keys}\r
diff --git a/gdx/src/com/badlogic/gdx/RenderListener.java b/gdx/src/com/badlogic/gdx/RenderListener.java
deleted file mode 100644 (file)
index 8b881fd..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************\r
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the\r
- * License. You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"\r
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language\r
- * governing permissions and limitations under the License.\r
- ******************************************************************************/\r
-\r
-package com.badlogic.gdx;\r
-\r
-/**\r
- * A RenderListener can be hooked to a {@link Graphics} instance and will receive setup, render and dispose events. In case of a\r
- * setup event the listener can create any resources it needs later on to draw. The setup method is also called when the OpenGL\r
- * surface has been recreated after a context loss. This happens only on Android in case the application was paused and resumed.\r
- * All OpenGL resources like textures, meshes and shaders are lost and have to be recreated. The render method is called whenever\r
- * the {@link Application} is redrawn. The dispose method is called before the Application is closed or the RenderListener is\r
- * unregistered from the Graphics instance.\r
- * \r
- * The methods will be invoked in the rendering thread of the application and not in the UI thread!\r
- * \r
- * \r
- * @author badlogicgames@gmail.com\r
- * \r
- */\r
-public interface RenderListener {\r
-       /**\r
-        * The setup method is called once upon initialization of the {@link Application} and every time the OpenGL surface is\r
-        * recreated. On Android this happens when the application is unpaused after it was paused by a press of the home button or an\r
-        * incoming call. All unmanaged textures have to be recreated manually, all other resources will be reloaded automatically.\r
-        * \r
-        */\r
-       public void surfaceCreated ();\r
-\r
-       /**\r
-        * Called when the OpenGL surface changed it's dimensions.\r
-        * \r
-        * @param width the width of the surface in pixels\r
-        * @param height the height of the surface in pixels\r
-        */\r
-       public void surfaceChanged (int width, int height);\r
-\r
-       /**\r
-        * The render method is called every time a new frame should be rendered.\r
-        */\r
-       public void render ();\r
-\r
-       /**\r
-        * The dispose method is called when the application is closing or the {@link RenderListener} has been unregistered from the\r
-        * Graphics instance.\r
-        */\r
-       public void dispose ();\r
-}\r
index 84ab880..6a54c6c 100644 (file)
@@ -71,6 +71,8 @@ public class Mesh {
                        indices = new IndexBufferObject(maxIndices);\r
                        isVertexArray = true;\r
                }               \r
+               \r
+               meshes.add(this);\r
        }\r
 \r
        /**\r
index 242b7c7..b540e81 100644 (file)
@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.GL11;
 import com.badlogic.gdx.graphics.GL20;\r
 import com.badlogic.gdx.graphics.VertexAttributes;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
+import com.badlogic.gdx.utils.GdxRuntimeException;\r
 \r
 /**\r
  * <p>\r
@@ -177,6 +178,9 @@ public class IndexBufferObject {
         * Binds this IndexBufferObject for rendering with glDrawElements.\r
         */\r
        public void bind() {\r
+               if( bufferHandle == 0 )\r
+                       throw new GdxRuntimeException("buuh");\r
+               \r
                if (Gdx.gl11 != null) {\r
                        GL11 gl = Gdx.gl11;\r
                        gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, bufferHandle);\r
index d63738f..76754d1 100644 (file)
@@ -16,7 +16,6 @@ public class GdxTestActivity extends AndroidApplication {
                String testName = (String)extras.get("test");\r
                \r
                GdxTest test = GdxTests.newTest(testName);\r
-               initialize(test.needsGL20());\r
-               getGraphics().setRenderListener(test);\r
+               initialize(test, test.needsGL20());             \r
        }\r
 }\r
index 5b234fd..9c2f0e3 100644 (file)
@@ -12,12 +12,12 @@ import android.view.ViewGroup.LayoutParams;
 import android.widget.Button;\r
 import android.widget.LinearLayout;\r
 \r
+import com.badlogic.gdx.ApplicationListener;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.backends.android.AndroidApplication;\r
 import com.badlogic.gdx.graphics.Color;\r
 \r
-public class WindowedTest extends AndroidApplication implements RenderListener {\r
+public class WindowedTest extends AndroidApplication implements ApplicationListener {\r
        Color color = new Color(1, 1, 1, 1);\r
 \r
        public void onCreate (Bundle bundle) {\r
@@ -29,15 +29,14 @@ public class WindowedTest extends AndroidApplication implements RenderListener {
                Button b2 = new Button(this);\r
                b2.setText("New Window");\r
                b2.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));\r
-               View view = initializeForView(false, 16);\r
+               View view = initializeForView(this, false, 16);\r
 \r
                LinearLayout layout = new LinearLayout(this);\r
                layout.setOrientation(LinearLayout.VERTICAL);\r
                layout.addView(b1);\r
                layout.addView(b2);\r
                layout.addView(view, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));\r
-\r
-               getGraphics().setRenderListener(this);\r
+               \r
                setContentView(layout);\r
 \r
                b1.setOnClickListener(new OnClickListener() {\r
@@ -66,15 +65,11 @@ public class WindowedTest extends AndroidApplication implements RenderListener {
                Log.w("WindowedTest", "destroying");\r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                // TODO Auto-generated method stub\r
 \r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
 \r
        @Override public void render () {\r
                Gdx.graphics.getGL10().glClearColor(color.r, color.g, color.g, color.a);\r
@@ -82,8 +77,20 @@ public class WindowedTest extends AndroidApplication implements RenderListener {
 \r
        }\r
 \r
-       @Override public void dispose () {\r
+       @Override public void destroy () {\r
+               // TODO Auto-generated method stub\r
+\r
+       }\r
+\r
+       @Override\r
+       public void pause() {\r
                // TODO Auto-generated method stub\r
+               \r
+       }\r
 \r
+       @Override\r
+       public void resume() {\r
+               // TODO Auto-generated method stub\r
+               \r
        }\r
 }\r
diff --git a/tests/gdx-tests-desktop/.settings/org.eclipse.jdt.core.prefs b/tests/gdx-tests-desktop/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index c6553de..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#Sat Oct 23 16:38:23 PDT 2010\r
-eclipse.preferences.version=1\r
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
-org.eclipse.jdt.core.compiler.compliance=1.6\r
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
-org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled\r
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning\r
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore\r
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning\r
-org.eclipse.jdt.core.compiler.problem.deadCode=ignore\r
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore\r
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled\r
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled\r
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning\r
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore\r
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore\r
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled\r
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore\r
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning\r
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning\r
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning\r
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning\r
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore\r
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled\r
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private\r
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore\r
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning\r
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private\r
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled\r
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore\r
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore\r
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning\r
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning\r
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore\r
-org.eclipse.jdt.core.compiler.problem.nullReference=warning\r
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning\r
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore\r
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning\r
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore\r
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore\r
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore\r
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore\r
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled\r
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning\r
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled\r
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled\r
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning\r
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning\r
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore\r
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore\r
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning\r
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore\r
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore\r
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedImport=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning\r
-org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled\r
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore\r
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning\r
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning\r
-org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/tests/gdx-tests-desktop/LICENSE-2.0.html b/tests/gdx-tests-desktop/LICENSE-2.0.html
deleted file mode 100644 (file)
index 034256c..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html><head>
-  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-  <link rel="stylesheet" href="LICENSE-2.0_fichiers/style.css" type="text/css">
-  <meta name="author" content="The Apache Software Foundation">
-  <meta name="email" content="apache.AT.apache.DOT.org">
-  <title>Apache License, Version 2.0 - The Apache Software Foundation</title>
-</head>
-<body>        
-<p align="center">
-Apache License<br>
-Version 2.0, January 2004<br>
-<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a>
-</p>
-<p>
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-</p>
-<p><b><a name="definitions">1. Definitions</a></b>.</p>
-<p>
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-</p>
-<p>
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-</p>
-<p>
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-</p>
-<p>
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-</p>
-<p>
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-</p>
-<p>
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-</p>
-<p>
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-</p>
-<p>
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-</p>
-<p>
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-</p>
-<p>
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-</p>
-<p><b><a name="copyright">2. Grant of Copyright License</a></b>.
-Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-</p>
-<p><b><a name="patent">3. Grant of Patent License</a></b>.
-Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-</p>
-<p><b><a name="redistribution">4. Redistribution</a></b>.
-You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-</p><ol type="a">
-<li>You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-<br> <br></li>
-
-<li>You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-<br> <br></li>
-
-<li>You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-<br> <br></li>
-
-<li>If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.</li>
-</ol>
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-<p><b><a name="contributions">5. Submission of Contributions</a></b>.
-Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-</p>
-<p><b><a name="trademarks">6. Trademarks</a></b>.
-This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-</p>
-<p><b><a name="no-warranty">7. Disclaimer of Warranty</a></b>.
-Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-</p>
-<p><b><a name="no-liability">8. Limitation of Liability</a></b>.
-In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-</p>
-<p><b><a name="additional">9. Accepting Warranty or Additional Liability</a></b>.
-While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-</p>
-<p>
-END OF TERMS AND CONDITIONS
-</p>
-</body></html>
\ No newline at end of file
diff --git a/tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglDebugStarter.java b/tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglDebugStarter.java
deleted file mode 100644 (file)
index f10fd21..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.badlogic.gdx.tests.desktop;\r
-\r
-import com.badlogic.gdx.backends.desktop.JoglApplication;\r
-\r
-public class JoglDebugStarter {\r
-       \r
-       public static void main( String[] argv ) {\r
-               JoglApplication app = new JoglApplication( "Debug Test", 480, 320, true );\r
-               app.getGraphics().setRenderListener( new com.badlogic.gdx.tests.VertexBufferObjectShaderTest() );\r
-       }\r
-}\r
similarity index 50%
rename from tests/gdx-tests-desktop/.classpath
rename to tests/gdx-tests-jogl/.classpath
index 5487742..f305ffb 100644 (file)
@@ -1,17 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <classpath>\r
-       <classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">\r
-               <attributes>\r
-                       <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="gdx/windows"/>\r
-               </attributes>\r
-       </classpathentry>\r
-       <classpathentry combineaccessrules="false" kind="src" path="/gdx">\r
-               <attributes>\r
-                       <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="gdx/windows"/>\r
-               </attributes>\r
-       </classpathentry>\r
-       <classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-desktop"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+       <classpathentry combineaccessrules="false" kind="src" path="/gdx"/>\r
+       <classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-jogl"/>\r
        <classpathentry combineaccessrules="false" kind="src" path="/gdx-tests"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
similarity index 87%
rename from backends/gdx-backend-desktop/.project
rename to tests/gdx-tests-jogl/.project
index 4ec5fe0..0426097 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <projectDescription>\r
-       <name>gdx-backend-desktop</name>\r
+       <name>gdx-tests-jogl</name>\r
        <comment></comment>\r
        <projects>\r
        </projects>\r
diff --git a/tests/gdx-tests-jogl/.settings/org.eclipse.jdt.core.prefs b/tests/gdx-tests-jogl/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..827e41b
--- /dev/null
@@ -0,0 +1,12 @@
+#Mon Nov 01 18:55:55 CET 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglDebugStarter.java b/tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglDebugStarter.java
new file mode 100644 (file)
index 0000000..9a18a98
--- /dev/null
@@ -0,0 +1,10 @@
+package com.badlogic.gdx.tests.jogl;\r
+\r
+import com.badlogic.gdx.backends.jogl.JoglApplication;\r
+\r
+public class JoglDebugStarter {\r
+       \r
+       public static void main( String[] argv ) {\r
+               new JoglApplication( new com.badlogic.gdx.tests.VertexBufferObjectShaderTest(), "Debug Test", 480, 320, true );         \r
+       }\r
+}\r
@@ -1,5 +1,5 @@
 \r
-package com.badlogic.gdx.tests.desktop;\r
+package com.badlogic.gdx.tests.jogl;\r
 \r
 import java.awt.BorderLayout;\r
 import java.awt.event.ActionEvent;\r
@@ -14,10 +14,8 @@ import javax.swing.JList;
 import javax.swing.JPanel;\r
 import javax.swing.JScrollPane;\r
 import javax.swing.ListSelectionModel;\r
-import javax.swing.event.ListSelectionEvent;\r
-import javax.swing.event.ListSelectionListener;\r
 \r
-import com.badlogic.gdx.backends.desktop.JoglApplication;\r
+import com.badlogic.gdx.backends.jogl.JoglApplication;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.tests.utils.GdxTests;\r
 \r
@@ -45,8 +43,7 @@ public class JoglTestStarter {
                                @Override public void actionPerformed (ActionEvent e) {\r
                                        String testName = (String)list.getSelectedValue();\r
                                        GdxTest test = GdxTests.newTest(testName);\r
-                                       JoglApplication app = new JoglApplication(testName, 480, 320, test.needsGL20());\r
-                                       app.getGraphics().setRenderListener(test);\r
+                                       new JoglApplication(test, testName, 480, 320, test.needsGL20());                                        \r
                                }\r
                        });\r
 \r
index abbf20c..c09f898 100644 (file)
@@ -2,25 +2,30 @@
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Pixmap;\r
-import com.badlogic.gdx.graphics.Pixmap.Format;\r
 import com.badlogic.gdx.graphics.SpriteBatch;\r
 import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.Pixmap.Format;\r
 import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class AlphaTest implements GdxTest {\r
+public class AlphaTest extends GdxTest {\r
        SpriteBatch batch;\r
-       Texture texture;\r
+       Texture texture;        \r
 \r
-       @Override public void dispose () {\r
+       @Override public void create () {\r
+               Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);\r
+               pixmap.setColor(0, 1, 0, 0.7f);\r
+               pixmap.fill();\r
 \r
+               texture = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                       TextureWrap.ClampToEdge);\r
+               batch = new SpriteBatch();\r
        }\r
-\r
+       \r
        @Override public void render () {\r
                Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);\r
 \r
@@ -29,21 +34,6 @@ public class AlphaTest implements GdxTest {
                batch.end();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);\r
-               pixmap.setColor(0, 1, 0, 0.7f);\r
-               pixmap.fill();\r
-\r
-               texture = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
-                       TextureWrap.ClampToEdge);\r
-               batch = new SpriteBatch();\r
-       }\r
-\r
        @Override public boolean needsGL20 () {\r
                return false;\r
        }\r
index aeae5de..132ee06 100644 (file)
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.audio.AudioDevice;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class AudioDeviceTest implements GdxTest {\r
+public class AudioDeviceTest extends GdxTest {\r
        Thread thread;\r
        boolean stop = false;\r
 \r
-       @Override public void dispose () {\r
-               stop = true;\r
-               try {\r
-                       thread.join();\r
-               } catch (InterruptedException e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-       @Override public void render () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                if (thread == null) {\r
                        final AudioDevice device = Gdx.app.getAudio().newAudioDevice(false);\r
                        thread = new Thread(new Runnable() {\r
@@ -68,6 +47,16 @@ public class AudioDeviceTest implements GdxTest {
                        thread.start();\r
                }\r
        }\r
+       \r
+       @Override public void destroy () {\r
+               stop = true;\r
+               try {\r
+                       thread.join();\r
+               } catch (InterruptedException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }\r
+       }\r
 \r
        @Override public boolean needsGL20 () {\r
                // TODO Auto-generated method stub\r
index 2477ac7..ae3a580 100644 (file)
@@ -21,34 +21,13 @@ import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.ImmediateModeRenderer;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class AudioRecorderTest implements GdxTest, ApplicationListener {\r
+public class AudioRecorderTest extends GdxTest {\r
        short[] samples = new short[1024 * 4];\r
        AudioDevice device;\r
        AudioRecorder recorder;\r
        ImmediateModeRenderer renderer;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
-               GL10 gl = Gdx.graphics.getGL10();\r
-               gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
-               gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
-\r
-// float incX = 2.0f / samples.length;\r
-// float x = -1;\r
-// renderer.begin( GL10.GL_LINE_STRIP );\r
-// for( int i = 0; i < samples.length/100; i++, x+=incX )\r
-// renderer.vertex( x, samples[i] / (float)Short.MAX_VALUE, 0 );\r
-// renderer.end();\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                device = Gdx.audio.newAudioDevice(true);\r
                recorder = Gdx.audio.newAudioRecoder(44100, true);\r
                renderer = new ImmediateModeRenderer();\r
@@ -63,14 +42,20 @@ public class AudioRecorderTest implements GdxTest, ApplicationListener {
                        }\r
                });\r
                t.setDaemon(true);\r
-               t.start();\r
-\r
-               Gdx.app.setApplicationListener(this);\r
+               t.start();      \r
        }\r
+       \r
+       @Override public void render () {\r
+               GL10 gl = Gdx.graphics.getGL10();\r
+               gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+               gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
 \r
-       @Override public void destroy () {\r
-               // TODO Auto-generated method stub\r
-\r
+// float incX = 2.0f / samples.length;\r
+// float x = -1;\r
+// renderer.begin( GL10.GL_LINE_STRIP );\r
+// for( int i = 0; i < samples.length/100; i++, x+=incX )\r
+// renderer.vertex( x, samples[i] / (float)Short.MAX_VALUE, 0 );\r
+// renderer.end();\r
        }\r
 \r
        @Override public void pause () {\r
@@ -84,7 +69,6 @@ public class AudioRecorderTest implements GdxTest, ApplicationListener {
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 }\r
index ef399a4..944636f 100644 (file)
@@ -3,6 +3,7 @@ package com.badlogic.gdx.tests;
 \r
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.InputAdapter;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.BitmapFontCache;\r
@@ -16,7 +17,7 @@ import com.badlogic.gdx.graphics.Texture.TextureWrap;
 import com.badlogic.gdx.math.Matrix4;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class BitmapFontFlipTest implements GdxTest {\r
+public class BitmapFontFlipTest extends GdxTest {\r
        private SpriteBatch spriteBatch;\r
        private BitmapFont font;\r
        private Sprite logoSprite;\r
@@ -24,8 +25,10 @@ public class BitmapFontFlipTest implements GdxTest {
        private BitmapFontCache cache1, cache2, cache3, cache4, cache5;\r
        int renderMode;\r
        private float alpha;\r
+       private InputProcessor inputProcessor;\r
 \r
-       public void surfaceCreated () {\r
+       @Override\r
+       public void create () {\r
                if (spriteBatch != null) return;\r
                spriteBatch = new SpriteBatch();\r
                spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));\r
@@ -39,12 +42,12 @@ public class BitmapFontFlipTest implements GdxTest {
                font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle(\r
                        "data/verdana39.png", FileType.Internal), true);\r
 \r
-               Gdx.input.addInputListener(new InputAdapter() {\r
+               inputProcessor = new InputAdapter() {\r
                        public boolean touchDown (int x, int y, int pointer) {\r
                                renderMode = (renderMode + 1) % 2;\r
                                return false;\r
                        }\r
-               });\r
+               };\r
 \r
                cache1 = new BitmapFontCache(font);\r
                cache2 = new BitmapFontCache(font);\r
@@ -67,9 +70,7 @@ public class BitmapFontFlipTest implements GdxTest {
                cache5.setWrappedText(text, 0, 320 - 270, red, 480, HAlignment.CENTER);\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
-       }\r
-\r
+       @Override\r
        public void render () {\r
                alpha = (alpha + Gdx.graphics.getDeltaTime() * 0.1f) % 1;\r
 \r
@@ -86,6 +87,8 @@ public class BitmapFontFlipTest implements GdxTest {
                        break;\r
                }\r
                spriteBatch.end();\r
+               \r
+               Gdx.input.processEvents(inputProcessor);\r
        }\r
 \r
        private void renderNormal () {\r
@@ -121,9 +124,6 @@ public class BitmapFontFlipTest implements GdxTest {
                cache4.draw(spriteBatch);\r
        }\r
 \r
-       public void dispose () {\r
-       }\r
-\r
        public boolean needsGL20 () {\r
                return false;\r
        }\r
index 0e7899c..cc27ce3 100644 (file)
@@ -3,6 +3,7 @@ package com.badlogic.gdx.tests;
 \r
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.InputAdapter;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.BitmapFontCache;\r
@@ -15,7 +16,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class BitmapFontTest implements GdxTest {\r
+public class BitmapFontTest extends GdxTest {\r
        private SpriteBatch spriteBatch;\r
        private BitmapFont font;\r
        private Sprite logoSprite;\r
@@ -23,8 +24,10 @@ public class BitmapFontTest implements GdxTest {
        private BitmapFontCache cache1, cache2, cache3, cache4, cache5;\r
        int renderMode;\r
        private float alpha;\r
+       InputProcessor inputProcessor;\r
 \r
-       public void surfaceCreated () {\r
+       @Override\r
+       public void create () {\r
                if (spriteBatch != null) return;\r
                spriteBatch = new SpriteBatch();\r
 \r
@@ -35,12 +38,12 @@ public class BitmapFontTest implements GdxTest {
                font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle(\r
                        "data/verdana39.png", FileType.Internal), false);\r
 \r
-               Gdx.input.addInputListener(new InputAdapter() {\r
+               inputProcessor = new InputAdapter() {\r
                        public boolean touchDown (int x, int y, int pointer) {\r
                                renderMode = (renderMode + 1) % 2;\r
                                return false;\r
                        }\r
-               });\r
+               };\r
 \r
                cache1 = new BitmapFontCache(font);\r
                cache2 = new BitmapFontCache(font);\r
@@ -63,9 +66,7 @@ public class BitmapFontTest implements GdxTest {
                cache5.setWrappedText(text, 0, 270, red, 480, HAlignment.CENTER);\r
        }\r
 \r
-       public void surfaceChanged (int width, int height) {\r
-       }\r
-\r
+       @Override\r
        public void render () {\r
                alpha = (alpha + Gdx.graphics.getDeltaTime() * 0.1f) % 1;\r
 \r
@@ -82,6 +83,8 @@ public class BitmapFontTest implements GdxTest {
                        break;\r
                }\r
                spriteBatch.end();\r
+               \r
+               Gdx.input.processEvents(inputProcessor);\r
        }\r
 \r
        private void renderNormal () {\r
@@ -117,9 +120,6 @@ public class BitmapFontTest implements GdxTest {
                cache4.draw(spriteBatch);\r
        }\r
 \r
-       public void dispose () {\r
-       }\r
-\r
        public boolean needsGL20 () {\r
                return false;\r
        }\r
index c965b8c..b22ad34 100644 (file)
@@ -16,7 +16,7 @@ package com.badlogic.gdx.tests;
 import java.util.ArrayList;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
@@ -38,7 +38,7 @@ import com.badlogic.gdx.physics.box2d.joints.MouseJoint;
 import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class Box2DTest implements GdxTest, InputListener {\r
+public class Box2DTest extends GdxTest implements InputProcessor {\r
        /** the camera **/\r
        private OrthographicCamera camera;\r
 \r
@@ -64,7 +64,7 @@ public class Box2DTest implements GdxTest, InputListener {
        /** a hit body **/\r
        private Body hitBody = null;\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                // setup the camera. In Box2D we operate on a\r
                // meter scale, pixels won't do it. So we use\r
                // an orthographic camera with a viewport of\r
@@ -85,10 +85,6 @@ public class Box2DTest implements GdxTest, InputListener {
 \r
                // next we create out physics world.\r
                createPhysicsWorld();\r
-\r
-               // finally we register ourselfs as an InputListener so we\r
-               // can manipulate our world\r
-               Gdx.input.addInputListener(this);\r
        }\r
 \r
        private void createPhysicsWorld () {\r
@@ -208,6 +204,9 @@ public class Box2DTest implements GdxTest, InputListener {
                font.draw( batch, "fps: " + Gdx.graphics.getFramesPerSecond() + " update time: " + updateTime, 0,\r
                                20, Color.RED);         \r
                batch.end();\r
+               \r
+               // process the input events\r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
        private void renderBox (GL10 gl, Body body, float halfWidth, float halfHeight) {\r
@@ -310,17 +309,18 @@ public class Box2DTest implements GdxTest, InputListener {
                return false;\r
        }\r
 \r
+       @Override public void destroy () {\r
+               world.dispose();\r
+       }\r
+       \r
+       @Override public boolean needsGL20 () {\r
+               return false;\r
+       }\r
+       \r
        // ---------------------------------------------------------------\r
        // STUBS FOR UNIMPLEMENTED INTERFACE METHODS, NOTHING TO SEE HERE\r
        // MOVE ALONG\r
        // ---------------------------------------------------------------\r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void dispose () {\r
-               world.dispose();\r
-       }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
                return false;\r
@@ -333,9 +333,4 @@ public class Box2DTest implements GdxTest, InputListener {
        @Override public boolean keyUp (int keycode) {\r
                return false;\r
        }\r
-\r
-       @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
-               return false;\r
-       }\r
 }\r
index 905f0be..94a8500 100644 (file)
@@ -15,7 +15,7 @@ package com.badlogic.gdx.tests;
 \r
 import com.badlogic.gdx.Application;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Input.Keys;\r
 import com.badlogic.gdx.tests.box2d.ApplyForce;\r
 import com.badlogic.gdx.tests.box2d.BodyTypes;\r
@@ -36,7 +36,7 @@ import com.badlogic.gdx.tests.box2d.VaryingRestitution;
 import com.badlogic.gdx.tests.box2d.VerticalStack;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class Box2DTestCollection implements GdxTest, InputListener {\r
+public class Box2DTestCollection extends GdxTest implements InputProcessor {\r
        private final Box2DTest[] tests = {new DebugRendererTest(), new CollisionFiltering(), new Chain(), new Bridge(),\r
                new SphereStack(), new Cantilever(), new ApplyForce(), new ContinuousTest(), new Prismatic(), new CharacterCollision(),\r
                new BodyTypes(), new SimpleTest(), new Pyramid(), new OneSidedPlatform(), new VerticalStack(), new VaryingRestitution()};\r
@@ -45,69 +45,64 @@ public class Box2DTestCollection implements GdxTest, InputListener {
 \r
        private Application app = null;\r
 \r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
 \r
        @Override public void render () {\r
                tests[testIndex].render();\r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                if (this.app == null) {\r
                        this.app = Gdx.app;\r
                        Box2DTest test = tests[testIndex];\r
-                       test.surfaceCreated();\r
-                       app.getInput().addInputListener(this);\r
+                       test.create();                  \r
                }\r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
                if (keycode == Keys.KEYCODE_SPACE) {\r
                        app.log("TestCollection", "disposing test '" + tests[testIndex].getClass().getName());\r
-                       tests[testIndex].dispose();\r
+                       tests[testIndex].destroy();\r
                        testIndex++;\r
                        if (testIndex >= tests.length) testIndex = 0;\r
                        Box2DTest test = tests[testIndex];\r
-                       test.surfaceCreated();\r
+                       test.create();\r
                        app.log("TestCollection", "created test '" + tests[testIndex].getClass().getName());\r
                }\r
+               else {\r
+                       tests[testIndex].keyDown(keycode);\r
+               }                       \r
 \r
                return false;\r
        }\r
 \r
        @Override public boolean keyTyped (char character) {\r
-               // TODO Auto-generated method stub\r
+               tests[testIndex].keyTyped(character);\r
                return false;\r
        }\r
 \r
        @Override public boolean keyUp (int keycode) {\r
-               // TODO Auto-generated method stub\r
+               tests[testIndex].keyUp(keycode);\r
                return false;\r
        }\r
 \r
        @Override public boolean touchDown (int x, int y, int pointer) {\r
-               // TODO Auto-generated method stub\r
+               tests[testIndex].touchDown(x, y, pointer);\r
                return false;\r
        }\r
 \r
        @Override public boolean touchDragged (int x, int y, int pointer) {\r
-               // TODO Auto-generated method stub\r
+               tests[testIndex].touchDragged(x, y, pointer);\r
                return false;\r
        }\r
 \r
        @Override public boolean touchUp (int x, int y, int pointer) {\r
-               // TODO Auto-generated method stub\r
+               tests[testIndex].touchUp(x, y, pointer);\r
                return false;\r
        }\r
 \r
        @Override\r
        public boolean needsGL20() {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 }\r
index 68940e9..dfc01cb 100644 (file)
@@ -1,8 +1,7 @@
-\r
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
@@ -13,7 +12,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class FillrateTest implements GdxTest, InputListener {\r
+public class FillrateTest extends GdxTest implements InputProcessor {\r
        Texture texture;\r
        Mesh mesh;\r
        int numFills = 1;\r
@@ -23,50 +22,48 @@ public class FillrateTest implements GdxTest, InputListener {
        float mean = 0;\r
        float frames = 0;\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (texture == null) {\r
-                       Gdx.input.addInputListener(this);\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal),\r
-                               TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-\r
-                       mesh = new Mesh(true, 4, 6, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_pos"),\r
-                               new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"));\r
-\r
-                       float[] vertices = new float[4 * 4];\r
-\r
-                       int idx = 0;\r
-                       vertices[idx++] = -1;\r
-                       vertices[idx++] = -1;\r
-                       vertices[idx++] = 0;\r
-                       vertices[idx++] = 0;\r
-\r
-                       vertices[idx++] = -1;\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = 0;\r
-                       vertices[idx++] = 1;\r
-\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = 1;\r
-\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = -1;\r
-                       vertices[idx++] = 1;\r
-                       vertices[idx++] = 0;\r
-\r
-                       short[] indices = {0, 1, 2, 2, 3, 0};\r
-                       mesh.setVertices(vertices);\r
-                       mesh.setIndices(indices);\r
-               }\r
+       @Override\r
+       public void create() {\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/badlogicsmall.jpg", FileType.Internal),\r
+                               TextureFilter.Linear, TextureFilter.Linear,\r
+                               TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
+\r
+               mesh = new Mesh(true, 4, 6, new VertexAttribute(\r
+                               VertexAttributes.Usage.Position, 2, "a_pos"),\r
+                               new VertexAttribute(VertexAttributes.Usage.TextureCoordinates,\r
+                                               2, "a_texCoords"));\r
+\r
+               float[] vertices = new float[4 * 4];\r
+\r
+               int idx = 0;\r
+               vertices[idx++] = -1;\r
+               vertices[idx++] = -1;\r
+               vertices[idx++] = 0;\r
+               vertices[idx++] = 0;\r
+\r
+               vertices[idx++] = -1;\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = 0;\r
+               vertices[idx++] = 1;\r
+\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = 1;\r
+\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = -1;\r
+               vertices[idx++] = 1;\r
+               vertices[idx++] = 0;\r
+\r
+               short[] indices = { 0, 1, 2, 2, 3, 0 };\r
+               mesh.setVertices(vertices);\r
+               mesh.setIndices(indices);\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);\r
 \r
                if (mode == 3) {\r
@@ -76,7 +73,8 @@ public class FillrateTest implements GdxTest, InputListener {
 \r
                if (mode == 2) {\r
                        Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);\r
-                       Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);\r
+                       Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA,\r
+                                       GL10.GL_ONE_MINUS_SRC_ALPHA);\r
                }\r
 \r
                if (mode >= 1) {\r
@@ -98,54 +96,63 @@ public class FillrateTest implements GdxTest, InputListener {
                mean += numFills;\r
                frames++;\r
 \r
-               if (Gdx.graphics.getDeltaTime() < 1 / 60f) numFills++;\r
+               if (Gdx.graphics.getDeltaTime() < 1 / 60f)\r
+                       numFills++;\r
 \r
                if (System.nanoTime() - lastOut >= 1000000000) {\r
-                       Gdx.app.log("FillrateTest", "fills: " + mean / frames + ", fps: " + frames + ", mode" + mode);\r
+                       Gdx.app.log("FillrateTest", "fills: " + mean / frames + ", fps: "\r
+                                       + frames + ", mode" + mode);\r
                        mean = 0;\r
                        frames = 0;\r
                        lastOut = System.nanoTime();\r
-                       if (Gdx.graphics.getFramesPerSecond() < 60) numFills--;\r
+                       if (Gdx.graphics.getFramesPerSecond() < 60)\r
+                               numFills--;\r
                }\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
-       @Override public boolean keyDown (int keycode) {\r
+       @Override\r
+       public boolean keyDown(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyUp (int keycode) {\r
+       @Override\r
+       public boolean keyUp(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyTyped (char character) {\r
+       @Override\r
+       public boolean keyTyped(char character) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDown (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDown(int x, int y, int pointer) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchUp (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchUp(int x, int y, int pointer) {\r
                mode++;\r
-               if (mode > 3) mode = 0;\r
+               if (mode > 3)\r
+                       mode = 0;\r
                numFills = 0;\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDragged (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDragged(int x, int y, int pointer) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index a3660e2..183a087 100644 (file)
@@ -26,7 +26,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class FloatTest implements GdxTest {\r
+public class FloatTest extends GdxTest {\r
 \r
        Texture tex;\r
        Texture tex2;\r
@@ -35,7 +35,7 @@ public class FloatTest implements GdxTest {
        float angle = 0;\r
        float angleIncrement = 0.1f;\r
 \r
-       @Override public void dispose () {\r
+       @Override public void destroy () {\r
                tex.dispose();\r
                tex2.dispose();\r
        }\r
@@ -75,7 +75,7 @@ public class FloatTest implements GdxTest {
                gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);\r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       private void init() {\r
                if (tex != null) {\r
                        tex.dispose();\r
                        tex2.dispose();\r
@@ -110,10 +110,13 @@ public class FloatTest implements GdxTest {
                tex2 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
                        TextureWrap.ClampToEdge);\r
        }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
+       \r
+       @Override public void create () {\r
+               init();\r
+       }\r
+       \r
+       @Override public void resume() {\r
+               init();\r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
index e13654f..2acf9d8 100644 (file)
@@ -30,17 +30,13 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer;
 import com.badlogic.gdx.graphics.glutils.ShaderProgram;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class FrameBufferTest implements GdxTest {\r
+public class FrameBufferTest extends GdxTest {\r
        FrameBuffer frameBuffer;\r
        Mesh mesh;\r
        ShaderProgram meshShader;\r
        Texture texture;\r
        SpriteBatch spriteBatch;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                frameBuffer.begin();\r
                Gdx.graphics.getGL20().glViewport(0, 0, frameBuffer.getWidth(), frameBuffer.getHeight());\r
@@ -64,29 +60,23 @@ public class FrameBufferTest implements GdxTest {
                spriteBatch.end();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       @Override public void create () {       \r
+               mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(\r
+                       Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
+               float c1 = Color.toFloatBits(255, 0, 0, 255);\r
+               float c2 = Color.toFloatBits(255, 0, 0, 255);\r
+               ;\r
+               float c3 = Color.toFloatBits(0, 0, 255, 255);\r
+               ;\r
 \r
-       }\r
+               mesh.setVertices(new float[] {-0.5f, -0.5f, 0, c1, 0, 0, 0.5f, -0.5f, 0, c2, 1, 0, 0, 0.5f, 0, c3, 0.5f, 1});\r
+\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                       TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (mesh == null) {\r
-                       mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(\r
-                               Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
-                       float c1 = Color.toFloatBits(255, 0, 0, 255);\r
-                       float c2 = Color.toFloatBits(255, 0, 0, 255);\r
-                       ;\r
-                       float c3 = Color.toFloatBits(0, 0, 255, 255);\r
-                       ;\r
-\r
-                       mesh.setVertices(new float[] {-0.5f, -0.5f, 0, c1, 0, 0, 0.5f, -0.5f, 0, c2, 1, 0, 0, 0.5f, 0, c3, 0.5f, 1});\r
-\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-\r
-                       spriteBatch = new SpriteBatch();\r
-                       frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, true);\r
-                       createShader(Gdx.graphics);\r
-               }\r
+               spriteBatch = new SpriteBatch();\r
+               frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, true);\r
+               createShader(Gdx.graphics);             \r
        }\r
 \r
        private void createShader (Graphics graphics) {\r
@@ -106,7 +96,6 @@ public class FrameBufferTest implements GdxTest {
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return true;\r
        }\r
 \r
index a83081d..a27f372 100644 (file)
@@ -13,9 +13,8 @@
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.ImmediateModeRenderer;\r
 import com.badlogic.gdx.graphics.Texture;\r
@@ -23,11 +22,11 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class ImmediateModeRendererTest implements GdxTest {\r
+public class ImmediateModeRendererTest extends GdxTest {\r
        ImmediateModeRenderer renderer;\r
        Texture texture;\r
 \r
-       @Override public void dispose () {\r
+       @Override public void destroy () {\r
                texture.dispose();\r
        }\r
 \r
@@ -48,19 +47,13 @@ public class ImmediateModeRendererTest implements GdxTest {
                renderer.end();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                renderer = new ImmediateModeRenderer();\r
-\r
                texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
                        TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
index a3ee980..a2dab6d 100644 (file)
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class IndexBufferObjectClassTest implements GdxTest {\r
+public class IndexBufferObjectClassTest extends GdxTest {\r
        Texture texture;\r
        VertexBufferObject vbo;\r
        IndexBufferObject ibo;  \r
@@ -26,7 +26,7 @@ public class IndexBufferObjectClassTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
+       public void destroy() {\r
                texture.dispose();\r
                vbo.dispose();\r
                ibo.dispose();\r
@@ -48,13 +48,7 @@ public class IndexBufferObjectClassTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void surfaceChanged(int width, int height) {\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void surfaceCreated() {\r
-               if( texture == null ) {\r
+       public void create() {          \r
                        vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),\r
                                                                        new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),\r
                                                                        new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));\r
@@ -68,9 +62,12 @@ public class IndexBufferObjectClassTest implements GdxTest {
                                         \r
                        texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),\r
                                                                                          TextureFilter.Linear, TextureFilter.Linear, \r
-                                                                                         TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               }\r
-               else\r
-                       vbo.invalidate(); \r
+                                                                                         TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);                                    \r
+       }\r
+       \r
+       @Override\r
+       public void resume() {\r
+               vbo.invalidate(); \r
+               ibo.invalidate();\r
        }\r
 }\r
index b32976b..d65f4a3 100644 (file)
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class IndexBufferObjectShaderTest implements GdxTest {\r
+public class IndexBufferObjectShaderTest extends GdxTest {\r
        Texture texture;\r
        ShaderProgram shader;\r
        VertexBufferObject vbo;\r
@@ -27,7 +27,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
+       public void destroy() {\r
                texture.dispose();\r
                shader.dispose();\r
                ibo.dispose();\r
@@ -35,6 +35,8 @@ public class IndexBufferObjectShaderTest implements GdxTest {
 \r
        @Override\r
        public void render() {\r
+//             System.out.println( "render");\r
+               \r
                GL20 gl = Gdx.gl20;\r
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
                gl.glClear(GL20.GL_COLOR_BUFFER_BIT);\r
@@ -43,7 +45,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
                shader.begin();\r
                shader.setUniformi("u_texture", 0);\r
                texture.bind();         \r
-               vbo.bind(shader);\r
+               vbo.bind(shader);               \r
                ibo.bind();\r
                gl.glDrawElements(GL20.GL_TRIANGLES, 3, GL20.GL_UNSIGNED_SHORT, 0);\r
                ibo.unbind();\r
@@ -52,13 +54,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void surfaceChanged(int width, int height) {\r
-\r
-       }\r
-\r
-       @Override\r
-       public void surfaceCreated() {\r
-               if (texture == null) {\r
+       public void create() {          \r
                        String vertexShader = "attribute vec4 a_position;    \n"\r
                                        + "attribute vec4 a_color;\n"\r
                                        + "attribute vec2 a_texCoords;\n"                                       \r
@@ -96,8 +92,16 @@ public class IndexBufferObjectShaderTest implements GdxTest {
                                        "data/badlogic.jpg", FileType.Internal),\r
                                        TextureFilter.Linear, TextureFilter.Linear,\r
                                        TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               } else\r
-                       vbo.invalidate();\r
+                       \r
+//                     System.out.println( "create");\r
+       }\r
+       \r
+       @Override\r
+       public void resume() {\r
+               vbo.invalidate();\r
+               ibo.invalidate();\r
+               \r
+//             System.out.println( "resume");\r
        }\r
 \r
 }\r
index 14fae30..36a1dea 100644 (file)
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class InputTest implements GdxTest, InputListener {\r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
+public class InputTest extends GdxTest implements InputProcessor {\r
 \r
        @Override public void render () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               Gdx.input.addInputListener(this);\r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
@@ -69,7 +54,6 @@ public class InputTest implements GdxTest, InputListener {
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
index 1a7d3d7..0459c4a 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.ApplicationListener;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
 /**\r
- * A simple test to demonstrate the life cycle of an application and a RenderListener.\r
+ * A simple test to demonstrate the life cycle of an application.\r
  * \r
  * @author mzechner\r
  * \r
  */\r
-public class LifeCycleTest implements ApplicationListener, GdxTest {\r
+public class LifeCycleTest extends GdxTest {\r
 \r
        @Override public void destroy () {\r
                Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app destroyed");\r
@@ -39,27 +37,16 @@ public class LifeCycleTest implements ApplicationListener, GdxTest {
                Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app resumed");\r
        }\r
 \r
-       @Override public void dispose () {\r
-               Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer disposed");\r
-       }\r
-\r
        @Override public void render () {\r
                Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer surface changed: " + Gdx.graphics.getWidth()\r
-                       + "x" + Gdx.graphics.getHeight());\r
-       }\r
+       }       \r
 \r
-       @Override public void surfaceCreated () {\r
-               Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer surface created: " + Gdx.graphics.getWidth()\r
-                       + "x" + Gdx.graphics.getHeight());\r
-               System.out.println(Gdx.graphics.getGL10().glGetString(GL10.GL_VERSION));\r
+       @Override public void create () {\r
+               Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app created: " + Gdx.graphics.getWidth()\r
+                       + "x" + Gdx.graphics.getHeight());              \r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
index fe735c2..9386ecc 100644 (file)
@@ -1,8 +1,7 @@
-\r
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.Color;\r
@@ -17,7 +16,7 @@ import com.badlogic.gdx.graphics.loaders.md5.MD5Model;
 import com.badlogic.gdx.graphics.loaders.md5.MD5Renderer;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class MD5Test implements GdxTest, InputListener {\r
+public class MD5Test extends GdxTest implements InputProcessor {\r
        PerspectiveCamera camera;\r
        MD5Model model;\r
        MD5Animation anim;\r
@@ -27,44 +26,43 @@ public class MD5Test implements GdxTest, InputListener {
        SpriteBatch batch;\r
        BitmapFont font;\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (model == null) {\r
-\r
-                       Gdx.app.log("MD5 Test", "created");\r
-                       model = MD5Loader.loadModel(Gdx.files.readFile("data/zfat.md5mesh", FileType.Internal));\r
-                       anim = MD5Loader.loadAnimation(Gdx.files.readFile("data/walk1.md5anim", FileType.Internal));\r
-                       skeleton = new MD5Joints();\r
-                       skeleton.joints = new float[anim.frames[0].joints.length];\r
-                       animInfo = new MD5AnimationInfo(anim.frames.length, anim.secondsPerFrame);\r
-                       renderer = new MD5Renderer(model, true);\r
-                       renderer.setSkeleton(model.baseSkeleton);\r
-\r
-                       // long start = System.nanoTime();\r
-                       // for( int i = 0; i < 100000; i++ )\r
-                       // renderer.setSkeleton( model.baseSkeleton );\r
-                       // app.log( "MD5 Test", "took: " + (System.nanoTime() - start ) / 1000000000.0 );\r
-\r
-                       camera = new PerspectiveCamera();\r
-                       camera.getPosition().set(0, 25, 100);\r
-                       camera.setFov(60);\r
-                       camera.setNear(1);\r
-                       camera.setFar(1000);\r
-                       camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
-\r
-                       batch = new SpriteBatch();\r
-                       font = new BitmapFont();\r
-                       Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
-                       Gdx.input.addInputListener(this);\r
-               }\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
+       @Override\r
+       public void create() {\r
+               Gdx.app.log("MD5 Test", "created");\r
+               model = MD5Loader.loadModel(Gdx.files.readFile("data/zfat.md5mesh",\r
+                               FileType.Internal));\r
+               anim = MD5Loader.loadAnimation(Gdx.files.readFile("data/walk1.md5anim",\r
+                               FileType.Internal));\r
+               skeleton = new MD5Joints();\r
+               skeleton.joints = new float[anim.frames[0].joints.length];\r
+               animInfo = new MD5AnimationInfo(anim.frames.length,\r
+                               anim.secondsPerFrame);\r
+               renderer = new MD5Renderer(model, true);\r
+               renderer.setSkeleton(model.baseSkeleton);\r
+\r
+               // long start = System.nanoTime();\r
+               // for( int i = 0; i < 100000; i++ )\r
+               // renderer.setSkeleton( model.baseSkeleton );\r
+               // app.log( "MD5 Test", "took: " + (System.nanoTime() - start ) /\r
+               // 1000000000.0 );\r
+\r
+               camera = new PerspectiveCamera();\r
+               camera.getPosition().set(0, 25, 100);\r
+               camera.setFov(60);\r
+               camera.setNear(1);\r
+               camera.setFar(1000);\r
+               camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+\r
+               batch = new SpriteBatch();\r
+               font = new BitmapFont();\r
+               Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(),\r
+                               Gdx.graphics.getHeight());\r
        }\r
 \r
        float angle = 0;\r
 \r
-       @Override @SuppressWarnings("unused") public void render () {\r
+       @Override       \r
+       public void render() {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);\r
 \r
@@ -73,7 +71,6 @@ public class MD5Test implements GdxTest, InputListener {
                animInfo.update(Gdx.graphics.getDeltaTime());\r
 \r
                gl.glEnable(GL10.GL_DEPTH_TEST);\r
-// gl.glPolygonMode( GL10.GL_FRONT_AND_BACK, GL10.GL_LINE );\r
 \r
                long start = 0;\r
                float renderTime = 0;\r
@@ -86,8 +83,9 @@ public class MD5Test implements GdxTest, InputListener {
                        gl.glRotatef(-90, 1, 0, 0);\r
 \r
                        start = System.nanoTime();\r
-                       MD5Animation.interpolate(anim.frames[animInfo.getCurrentFrame()], anim.frames[animInfo.getNextFrame()], skeleton,\r
-                               animInfo.getInterpolation());\r
+                       MD5Animation.interpolate(anim.frames[animInfo.getCurrentFrame()],\r
+                                       anim.frames[animInfo.getNextFrame()], skeleton, animInfo\r
+                                                       .getInterpolation());\r
                        renderer.setSkeleton(skeleton);\r
                        skinTime = (System.nanoTime() - start) / 1000000000.0f;\r
 \r
@@ -97,58 +95,67 @@ public class MD5Test implements GdxTest, InputListener {
                }\r
 \r
                gl.glDisable(GL10.GL_DEPTH_TEST);\r
-// gl.glPolygonMode( GL10.GL_FRONT_AND_BACK, GL10.GL_FILL );\r
+\r
                batch.begin();\r
-               font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond() + (renderer.isJniUsed() ? ", jni" : ", java"), 10, 20,\r
+               font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond()\r
+                               + (renderer.isJniUsed() ? ", jni" : ", java"), 10, 20,\r
                                Color.WHITE);\r
                batch.end();\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public void dispose () {\r
+       @Override\r
+       public void destroy() {\r
                batch.dispose();\r
                renderer.dispose();\r
-//             font.dispose();\r
+               font.dispose();\r
 \r
                batch = null;\r
                renderer = null;\r
-//             font = null;\r
+               font = null;\r
 \r
                System.gc();\r
-\r
-               Gdx.input.removeInputListener(this);\r
        }\r
 \r
-       @Override public boolean keyDown (int keycode) {\r
+       @Override\r
+       public boolean keyDown(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyTyped (char character) {\r
+       @Override\r
+       public boolean keyTyped(char character) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyUp (int keycode) {\r
+       @Override\r
+       public boolean keyUp(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDown (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDown(int x, int y, int pointer) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDragged (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDragged(int x, int y, int pointer) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchUp (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchUp(int x, int y, int pointer) {\r
                renderer.setUseJni(!renderer.isJniUsed());\r
                return false;\r
        }\r
 \r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index 687e0e3..f4c7dcd 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
 import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.VertexAttribute;\r
 import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
-import com.badlogic.gdx.graphics.VertexAttribute;\r
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class ManagedTest implements GdxTest {\r
+public class ManagedTest extends GdxTest {\r
        Mesh mesh;\r
        Texture texture;\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (mesh == null) {\r
-                       mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(\r
-                               Usage.TextureCoordinates, 2, "a_texCoord"));\r
-                       mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 0.5f, -0.5f, 1, 0, 0.5f, 0.5f, 1, 1, -0.5f, 0.5f, 0, 1});\r
-                       mesh.setIndices(new short[] {0, 1, 2, 3});\r
+       @Override public void create () {\r
+               mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(\r
+                       Usage.TextureCoordinates, 2, "a_texCoord"));\r
+               mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 0, 0.5f, -0.5f, 1, 0, 0.5f, 0.5f, 1, 1, -0.5f, 0.5f, 0, 1});\r
+               mesh.setIndices(new short[] {0, 1, 2, 3});\r
 \r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               }\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                       TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
        }\r
 \r
        @Override public void render () {\r
@@ -52,16 +49,7 @@ public class ManagedTest implements GdxTest {
                mesh.render(GL10.GL_TRIANGLE_FAN);\r
        }\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
+       @Override public boolean needsGL20 () { \r
                return false;\r
        }\r
 \r
index b310ff2..e15efd3 100644 (file)
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.Texture.TextureWrap;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class ManualBindTest implements GdxTest {\r
+public class ManualBindTest extends GdxTest {\r
        int vboHandle;\r
        int iboHandle;\r
        ShortBuffer indices;\r
@@ -28,11 +28,6 @@ public class ManualBindTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
-               \r
-       }\r
-\r
-       @Override\r
        public void render() {\r
                GL11 gl = Gdx.gl11;\r
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
@@ -43,8 +38,8 @@ public class ManualBindTest implements GdxTest {
                gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);\r
                gl.glVertexPointer(2, GL11.GL_FLOAT, 5 * 4, 0);\r
                \r
-               gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 4, null, GL11.GL_DYNAMIC_DRAW);\r
-               gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 4, indices, GL11.GL_DYNAMIC_DRAW);              \r
+               gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 2, null, GL11.GL_DYNAMIC_DRAW);\r
+               gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 2, indices, GL11.GL_DYNAMIC_DRAW);              \r
                gl.glBufferData(GL11.GL_ARRAY_BUFFER, vertices1.limit() * 4, null, GL11.GL_DYNAMIC_DRAW);\r
                gl.glBufferData(GL11.GL_ARRAY_BUFFER, vertices1.limit() * 4, vertices1, GL11.GL_DYNAMIC_DRAW);                                                                  \r
                gl.glDrawElements(GL11.GL_TRIANGLES, 12, GL11.GL_UNSIGNED_SHORT, 0);\r
@@ -58,13 +53,7 @@ public class ManualBindTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void surfaceChanged(int width, int height) {\r
-               // TODO Auto-generated method stub\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void surfaceCreated() {                  \r
+       public void create() {                  \r
                GL11 gl = Gdx.graphics.getGL11();\r
                IntBuffer handleBuf = BufferUtils.newIntBuffer(2);              \r
                gl.glGenBuffers(2, handleBuf);\r
@@ -93,5 +82,4 @@ public class ManualBindTest implements GdxTest {
                                                                   -0.5f, 0, c, 1, 0 });\r
                vertices2.flip();\r
        }\r
-\r
 }\r
index ff11cbf..4f0f61b 100644 (file)
@@ -2,28 +2,22 @@
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
 import com.badlogic.gdx.graphics.Pixmap;\r
-import com.badlogic.gdx.graphics.Pixmap.Format;\r
 import com.badlogic.gdx.graphics.Texture;\r
-import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
-import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.graphics.VertexAttribute;\r
 import com.badlogic.gdx.graphics.VertexAttributes;\r
+import com.badlogic.gdx.graphics.Pixmap.Format;\r
+import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
+import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class MeshMultitextureTest implements GdxTest {\r
+public class MeshMultitextureTest extends GdxTest {\r
        Texture tex1;\r
        Texture tex2;\r
        Mesh mesh;\r
 \r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glViewport( 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() );\r
@@ -36,11 +30,22 @@ public class MeshMultitextureTest implements GdxTest {
                mesh.render(GL10.GL_TRIANGLES);\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       @Override public void create () {\r
+               mesh = new Mesh(true, 3, 0, new VertexAttribute(VertexAttributes.Usage.Color, 4, "a_Color"), new VertexAttribute(\r
+                       VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords1"), new VertexAttribute(\r
+                       VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords2"), new VertexAttribute(VertexAttributes.Usage.Position, 3,\r
+                       "a_Position"));\r
 \r
-       }\r
+               mesh.setVertices(new float[] {1, 0, 0, 1, 0, 1, 0, 1, -0.5f, -0.5f, 0,\r
 \r
-       @Override public void surfaceCreated () {\r
+               0, 1, 0, 1, 1, 1, 1, 1, 0.5f, -0.5f, 0,\r
+\r
+               0, 0, 1, 1, 0.5f, 0, 0.5f, 0, 0, 0.5f, 0,});\r
+               \r
+               initUnmanaged();\r
+       }\r
+       \r
+       void initUnmanaged() {\r
                Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);\r
                pixmap.setColor(1, 1, 1, 1);\r
                pixmap.fill();\r
@@ -49,6 +54,7 @@ public class MeshMultitextureTest implements GdxTest {
                pixmap.drawLine(256, 0, 0, 256);\r
                tex1 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
                        TextureWrap.ClampToEdge);\r
+               pixmap.dispose();\r
 \r
                pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);\r
                pixmap.setColor(1, 1, 1, 1);\r
@@ -57,21 +63,14 @@ public class MeshMultitextureTest implements GdxTest {
                pixmap.drawLine(128, 0, 128, 256);\r
                tex2 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
                        TextureWrap.ClampToEdge);\r
-\r
-               mesh = new Mesh(true, 3, 0, new VertexAttribute(VertexAttributes.Usage.Color, 4, "a_Color"), new VertexAttribute(\r
-                       VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords1"), new VertexAttribute(\r
-                       VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords2"), new VertexAttribute(VertexAttributes.Usage.Position, 3,\r
-                       "a_Position"));\r
-\r
-               mesh.setVertices(new float[] {1, 0, 0, 1, 0, 1, 0, 1, -0.5f, -0.5f, 0,\r
-\r
-               0, 1, 0, 1, 1, 1, 1, 1, 0.5f, -0.5f, 0,\r
-\r
-               0, 0, 1, 1, 0.5f, 0, 0.5f, 0, 0, 0.5f, 0,});\r
+               pixmap.dispose();\r
+       }\r
+       \r
+       public void resume() {\r
+               initUnmanaged();\r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
index d3f812b..e61635f 100644 (file)
@@ -29,55 +29,68 @@ import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class MeshShaderTest implements GdxTest {\r
+public class MeshShaderTest extends GdxTest {\r
        SpriteBatch spriteBatch;\r
-//     Font font;\r
+       // Font font;\r
        ShaderProgram shader;\r
        Mesh mesh;\r
        Texture texture;\r
        Matrix4 matrix = new Matrix4();\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (shader == null) {\r
-                       String vertexShader = "attribute vec4 a_position;    \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"\r
-                               + "uniform mat4 u_worldView;\n" + "varying vec4 v_color;" + "varying vec2 v_texCoords;"\r
-                               + "void main()                  \n" + "{                            \n"\r
-                               + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n" + "   v_texCoords = a_texCoords; \n"\r
-                               + "   gl_Position =  u_worldView * a_position;  \n" + "}                            \n";\r
-                       String fragmentShader = "precision mediump float;\n" + "varying vec4 v_color;\n" + "varying vec2 v_texCoords;\n"\r
-                               + "uniform sampler2D u_texture;\n" + "void main()                                  \n"\r
+       @Override\r
+       public void create() {\r
+               String vertexShader = "attribute vec4 a_position;    \n"\r
+                               + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"\r
+                               + "uniform mat4 u_worldView;\n" + "varying vec4 v_color;"\r
+                               + "varying vec2 v_texCoords;"\r
+                               + "void main()                  \n"\r
+                               + "{                            \n"\r
+                               + "   v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"\r
+                               + "   v_texCoords = a_texCoords; \n"\r
+                               + "   gl_Position =  u_worldView * a_position;  \n"\r
+                               + "}                            \n";\r
+               String fragmentShader = "precision mediump float;\n"\r
+                               + "varying vec4 v_color;\n"\r
+                               + "varying vec2 v_texCoords;\n"\r
+                               + "uniform sampler2D u_texture;\n"\r
+                               + "void main()                                  \n"\r
                                + "{                                            \n"\r
-                               + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" + "}";\r
+                               + "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"\r
+                               + "}";\r
 \r
-                       shader = new ShaderProgram(vertexShader, fragmentShader);\r
-                       if (shader.isCompiled() == false) {\r
-                               Gdx.app.log("ShaderTest", shader.getLog());\r
-                               System.exit(0);\r
-                       }\r
+               shader = new ShaderProgram(vertexShader, fragmentShader);\r
+               if (shader.isCompiled() == false) {\r
+                       Gdx.app.log("ShaderTest", shader.getLog());\r
+                       System.exit(0);\r
+               }\r
 \r
-                       mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(\r
-                               Usage.Color, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
+               mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3,\r
+                               "a_position"), new VertexAttribute(Usage.Color, 4, "a_color"),\r
+                               new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
 \r
-                       mesh.setVertices(new float[] {-0.5f, -0.5f, 0, 1, 0, 0, 1, 0, 0, 0.5f, -0.5f, 0, 0, 1, 0, 1, 1, 0, 0, 0.5f, 0, 0, 0, 1,\r
-                               1, 0.5f, 1});\r
-                       mesh.setIndices(new short[] {0, 1, 2});\r
+               mesh.setVertices(new float[] { -0.5f, -0.5f, 0, 1, 0, 0, 1, 0, 0, 0.5f,\r
+                               -0.5f, 0, 0, 1, 0, 1, 1, 0, 0, 0.5f, 0, 0, 0, 1, 1, 0.5f, 1 });\r
+               mesh.setIndices(new short[] { 0, 1, 2 });\r
 \r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                               TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                               TextureWrap.ClampToEdge);\r
 \r
-                       spriteBatch = new SpriteBatch();\r
-//                     font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);\r
-               }\r
+               spriteBatch = new SpriteBatch();\r
+               // font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);\r
        }\r
 \r
        Vector3 axis = new Vector3(0, 0, 1);\r
        float angle = 0;\r
 \r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                angle += Gdx.graphics.getDeltaTime() * 45;\r
                matrix.setToRotation(axis, angle);\r
 \r
-               Gdx.graphics.getGL20().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+               Gdx.graphics.getGL20().glViewport(0, 0, Gdx.graphics.getWidth(),\r
+                               Gdx.graphics.getHeight());\r
                Gdx.graphics.getGL20().glClearColor(0.2f, 0.2f, 0.2f, 1);\r
                Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);\r
                Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);\r
@@ -89,20 +102,12 @@ public class MeshShaderTest implements GdxTest {
                shader.end();\r
 \r
                spriteBatch.begin();\r
-//             spriteBatch.drawText(font, "This is a test", 100, 100, Color.RED);\r
+               // spriteBatch.drawText(font, "This is a test", 100, 100, Color.RED);\r
                spriteBatch.end();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void dispose () {\r
-               Gdx.app.log("MeshShaderTEst", "disposed");\r
-       }\r
-\r
-       @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
+       @Override\r
+       public boolean needsGL20() {    \r
                return true;\r
        }\r
 \r
index 6d61e5b..a6451a1 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
 import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.VertexAttribute;\r
 import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
-import com.badlogic.gdx.graphics.VertexAttribute;\r
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class MeshTest implements GdxTest {\r
+public class MeshTest extends GdxTest {\r
        Mesh mesh;\r
        Texture texture;\r
 \r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
                Gdx.graphics.getGL10().glEnable(GL10.GL_TEXTURE_2D);\r
@@ -42,28 +36,19 @@ public class MeshTest implements GdxTest {
                mesh.render(GL10.GL_TRIANGLES, 0, 3);\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
+       @Override public void create () {\r
+               mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(\r
+                       Usage.ColorPacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (mesh == null) {\r
-                       mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(\r
-                               Usage.ColorPacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
+               mesh.setVertices(new float[] {-0.5f, -0.5f, 0, Color.toFloatBits(255, 0, 0, 255), 0, 0, 0.5f, -0.5f, 0,\r
+                       Color.toFloatBits(0, 255, 0, 255), 1, 0, 0, 0.5f, 0, Color.toFloatBits(0, 0, 255, 255), 0.5f, 1});\r
+               mesh.setIndices(new short[] {0, 1, 2});\r
 \r
-                       mesh.setVertices(new float[] {-0.5f, -0.5f, 0, Color.toFloatBits(255, 0, 0, 255), 0, 0, 0.5f, -0.5f, 0,\r
-                               Color.toFloatBits(0, 255, 0, 255), 1, 0, 0, 0.5f, 0, Color.toFloatBits(0, 0, 255, 255), 0.5f, 1});\r
-                       mesh.setIndices(new short[] {0, 1, 2});\r
-\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               }\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                       TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);                \r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
-\r
 }\r
index 9f2cdcc..c42855e 100644 (file)
@@ -16,31 +16,17 @@ package com.badlogic.gdx.tests;
 import java.nio.FloatBuffer;\r
 import java.nio.ShortBuffer;\r
 \r
-import com.badlogic.gdx.Application.ApplicationType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Application.ApplicationType;\r
 import com.badlogic.gdx.audio.analysis.AudioTools;\r
 import com.badlogic.gdx.audio.analysis.KissFFT;\r
 import com.badlogic.gdx.audio.io.Mpg123Decoder;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class Mpg123Test implements GdxTest {\r
-\r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
-\r
-       }\r
+public class Mpg123Test extends GdxTest {\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
 // Thread thread = new Thread( new Runnable() {\r
 //\r
 // public void run( )\r
@@ -75,7 +61,6 @@ public class Mpg123Test implements GdxTest {
        }\r
 \r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
index 2a39888..93a24cb 100644 (file)
@@ -2,23 +2,19 @@
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.ImmediateModeRenderer;\r
 import com.badlogic.gdx.graphics.OrthographicCamera;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class MultitouchTest implements GdxTest, InputListener {\r
+public class MultitouchTest extends GdxTest implements InputProcessor {\r
        ImmediateModeRenderer renderer;\r
        OrthographicCamera camera;\r
 \r
        Color[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.WHITE};\r
 \r
-       @Override public void dispose () {\r
-       }\r
-\r
        @Override public void render () {\r
                Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);\r
                Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
@@ -40,21 +36,17 @@ public class MultitouchTest implements GdxTest, InputListener {
                }\r
 \r
                renderer.end();\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
 \r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               if (renderer == null) {\r
-                       Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.supportsMultitouch());\r
-                       Gdx.input.addInputListener(this); // only add this once...\r
-                       renderer = new ImmediateModeRenderer();\r
-                       camera = new OrthographicCamera();\r
-                       camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
-                       camera.getPosition().set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);\r
-               }\r
+       @Override public void create () {               \r
+               Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.supportsMultitouch());\r
+               renderer = new ImmediateModeRenderer();\r
+               camera = new OrthographicCamera();\r
+               camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+               camera.getPosition().set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);           \r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
index 8f9d099..787e6f6 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
 import com.badlogic.gdx.graphics.ModelLoader;\r
@@ -26,7 +25,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class ObjTest implements GdxTest, InputListener {\r
+public class ObjTest extends GdxTest implements InputProcessor {\r
        PerspectiveCamera cam;\r
        Mesh mesh;\r
        Texture texture;\r
@@ -35,28 +34,16 @@ public class ObjTest implements GdxTest, InputListener {
        float[] lightColor = {1, 1, 1, 0};\r
        float[] lightPosition = {2, 5, 10, 0};\r
        float touchStartX = 0;\r
-       float touchStartY = 0;\r
-\r
-       long frameStart;\r
-       int frames = 0;\r
-\r
-       @Override public void surfaceCreated () {\r
-               if (mesh == null) {\r
-                       Gdx.input.addInputListener(this);\r
-\r
-                       mesh = ModelLoader.loadObj(Gdx.files.readFile("data/cube.obj", FileType.Internal));\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-\r
-                       cam = new PerspectiveCamera();\r
-                       cam.getPosition().set(2, 2, 2);\r
-                       cam.getDirection().set(-1, -1, -1);\r
-               }\r
-               frameStart = System.nanoTime();\r
-       }\r
+       float touchStartY = 0;  \r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       @Override public void create () {\r
+               mesh = ModelLoader.loadObj(Gdx.files.readFile("data/cube.obj", FileType.Internal));\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                       TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
 \r
+               cam = new PerspectiveCamera();\r
+               cam.getPosition().set(2, 2, 2);\r
+               cam.getDirection().set(-1, -1, -1);             \r
        }\r
 \r
        @Override public void render () {\r
@@ -79,18 +66,8 @@ public class ObjTest implements GdxTest, InputListener {
                gl.glRotatef(angleX, 1, 0, 0);\r
                texture.bind();\r
                mesh.render(GL10.GL_TRIANGLES);\r
-\r
-               if (System.nanoTime() - frameStart > 1000000000) {\r
-                       Gdx.app.log("Obj Test", "fps: " + frames);\r
-                       frames = 0;\r
-                       frameStart = System.nanoTime();\r
-               }\r
-\r
-               frames++;\r
-       }\r
-\r
-       @Override public void dispose () {\r
-\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
index 09e3339..d112476 100644 (file)
@@ -7,7 +7,7 @@ import com.badlogic.gdx.Files.FileType;
 import com.badlogic.gdx.Gdx;\r
 import com.badlogic.gdx.Input;\r
 import com.badlogic.gdx.InputAdapter;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.BitmapFont.HAlignment;\r
 import com.badlogic.gdx.graphics.BitmapFontCache;\r
@@ -22,16 +22,17 @@ import com.badlogic.gdx.graphics.particles.ParticleEmitter;
 import com.badlogic.gdx.math.Matrix4;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class ParticleEmitterTest implements GdxTest {\r
+public class ParticleEmitterTest extends GdxTest {\r
        private SpriteBatch spriteBatch;\r
        ParticleEffect effect;\r
        int emitterIndex;\r
        ArrayList<ParticleEmitter> emitters;\r
        int particleCount = 10;\r
        float fpsCounter;\r
+       InputProcessor inputProcessor;\r
 \r
-       public void surfaceCreated () {\r
-               if (spriteBatch != null) return;\r
+       @Override\r
+       public void create () {\r
                spriteBatch = new SpriteBatch();\r
 \r
                effect = new ParticleEffect();\r
@@ -42,7 +43,7 @@ public class ParticleEmitterTest implements GdxTest {
                effect.getEmitters().clear();\r
                effect.getEmitters().add(emitters.get(0));\r
 \r
-               Gdx.input.addInputListener(new InputListener() {\r
+               inputProcessor = new InputProcessor() {\r
                        public boolean touchUp (int x, int y, int pointer) {\r
                                return false;\r
                        }\r
@@ -84,14 +85,11 @@ public class ParticleEmitterTest implements GdxTest {
                                effect.getEmitters().add(emitter);\r
                                return false;\r
                        }\r
-               });\r
-       }\r
-\r
-       public void surfaceChanged (int width, int height) {\r
-               spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+               };\r
        }\r
 \r
        public void render () {\r
+               spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
                float delta = Gdx.graphics.getDeltaTime();\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
@@ -104,9 +102,8 @@ public class ParticleEmitterTest implements GdxTest {
                        int activeCount = emitters.get(emitterIndex).getActiveCount();\r
                        System.out.println(activeCount + "/" + particleCount + " particles, FPS: " + Gdx.graphics.getFramesPerSecond());\r
                }\r
-       }\r
-\r
-       public void dispose () {\r
+               \r
+               Gdx.input.processEvents(inputProcessor);\r
        }\r
 \r
        public boolean needsGL20 () {\r
index 28f98d5..d59177e 100644 (file)
@@ -14,7 +14,6 @@
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
@@ -31,7 +30,7 @@ import com.badlogic.gdx.tests.utils.GdxTest;
  * @author mzechner\r
  * \r
  */\r
-public class Pong implements GdxTest {\r
+public class Pong extends GdxTest {\r
        /** the camera **/\r
        private OrthographicCamera camera;\r
        /** the MeshRenderer for the paddles **/\r
@@ -68,11 +67,9 @@ public class Pong implements GdxTest {
         * Here we setup all the resources. A {@link MeshRenderer} for the paddles which we use for both, a MeshRenderer for the ball\r
         * and a {@link Text} for rendering the score.\r
         */\r
-       @Override public void surfaceCreated () {\r
-               if (camera == null) {\r
-                       setupGraphics();\r
-                       setupGame();\r
-               }\r
+       @Override public void create () {\r
+               setupGraphics();\r
+               setupGame();            \r
        }\r
 \r
        /**\r
@@ -125,10 +122,6 @@ public class Pong implements GdxTest {
                ballDirection.set(-1, 0);\r
        }\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                // we update the game state so things move.\r
                updateGame();\r
@@ -173,7 +166,7 @@ public class Pong implements GdxTest {
                spriteBatch.begin();\r
 //             spriteBatch.drawText(font, score, Gdx.graphics.getWidth() / 2 - font.getStringWidth(score) / 2, Gdx.graphics.getHeight()\r
 //                     - font.getLineHeight(), Color.WHITE);\r
-               spriteBatch.end();\r
+               spriteBatch.end();              \r
        }\r
 \r
        /**\r
@@ -275,12 +268,7 @@ public class Pong implements GdxTest {
                }\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
        @Override public boolean needsGL20 () {\r
-               // TODO Auto-generated method stub\r
                return false;\r
        }\r
 }\r
index 97ef2af..a379a3e 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.ApplicationListener;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class SimpleTest implements GdxTest, InputListener, ApplicationListener {\r
+public class SimpleTest extends GdxTest implements InputProcessor {\r
        float r = 1, g = 0, b = 0;\r
 \r
-       @Override public void surfaceCreated () {\r
-               Gdx.input.addInputListener(this);\r
-               Gdx.app.setApplicationListener(this);\r
+       @Override public void create () {               \r
                Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", surface created");\r
        }\r
 \r
@@ -34,13 +30,11 @@ public class SimpleTest implements GdxTest, InputListener, ApplicationListener {
 \r
                gl.glClearColor(r, g, b, 1);\r
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
+               \r
+               Gdx.input.processEvents(this);\r
 \r
        }\r
 \r
-       @Override public void dispose () {\r
-               Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", render listener disposed");\r
-       }\r
-\r
        @Override public void destroy () {\r
                Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", application destroyed");\r
        }\r
@@ -87,11 +81,6 @@ public class SimpleTest implements GdxTest, InputListener, ApplicationListener {
 \r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
        @Override public boolean needsGL20 () {\r
                // TODO Auto-generated method stub\r
                return false;\r
index 87224ae..fb187ac 100644 (file)
 \r
 package com.badlogic.gdx.tests;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.audio.Music;\r
 import com.badlogic.gdx.audio.Sound;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class SoundTest implements GdxTest, InputListener {\r
+public class SoundTest extends GdxTest implements InputProcessor {\r
        Sound sound;\r
        Music music;\r
        float volume = 1.0f;\r
 \r
-       @Override public void dispose () {\r
-\r
+       @Override public void render () {               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public void render () {\r
-               try {\r
-                       Thread.sleep(100);\r
-               } catch (InterruptedException e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (music == null) {\r
-                       Gdx.input.addInputListener(this);\r
+       @Override public void create () {               \r
                        sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/shotgun.wav", FileType.Internal));\r
 \r
 //                     music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/threeofaperfectpair.mp3", FileType.Internal));\r
                        music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/cloudconnected.ogg", FileType.Internal));\r
                        music.play();\r
                        music.setLooping(true);\r
-               }\r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
index a5d21da..a205369 100644 (file)
@@ -17,9 +17,8 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;\r
 import java.nio.IntBuffer;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.SpriteBatch;\r
@@ -28,52 +27,59 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class SpriteBatchRotationTest implements GdxTest {\r
+public class SpriteBatchRotationTest extends GdxTest {\r
        SpriteBatch spriteBatch;\r
        Texture texture;\r
-//     Font font;\r
+       // Font font;\r
        float angle = 0;\r
        float scale = 1;\r
        float vScale = 1;\r
        IntBuffer pixelBuffer;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);\r
                spriteBatch.begin();\r
-               spriteBatch.draw(texture, 16, 10, 16, 16, 32, 32, 1, 1, 0, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,\r
-                       false, false);\r
-               spriteBatch.draw(texture, 64, 10, 32, 32, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE, false, false);\r
-               spriteBatch.draw(texture, 112, 10, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE);\r
-\r
-               spriteBatch.draw(texture, 16, 58, 16, 16, 32, 32, 1, 1, angle, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,\r
-                       false, false);\r
-               spriteBatch.draw(texture, 64, 58, 16, 16, 32, 32, scale, scale, 0, 0, 0, texture.getWidth(), texture.getHeight(),\r
-                       Color.WHITE, false, false);\r
-               spriteBatch.draw(texture, 112, 58, 16, 16, 32, 32, scale, scale, angle, 0, 0, texture.getWidth(), texture.getHeight(),\r
-                       Color.WHITE, false, false);\r
-               spriteBatch.draw(texture, 160, 58, 0, 0, 32, 32, scale, scale, angle, 0, 0, texture.getWidth(), texture.getHeight(),\r
-                       Color.WHITE, false, false);\r
-\r
-//             spriteBatch.drawText(font, "Test", 208, 10, Color.WHITE);\r
+               spriteBatch.draw(texture, 16, 10, 16, 16, 32, 32, 1, 1, 0, 0, 0,\r
+                               texture.getWidth(), texture.getHeight(), Color.WHITE, false,\r
+                               false);\r
+               spriteBatch.draw(texture, 64, 10, 32, 32, 0, 0, texture.getWidth(),\r
+                               texture.getHeight(), Color.WHITE, false, false);\r
+               spriteBatch.draw(texture, 112, 10, 0, 0, texture.getWidth(), texture\r
+                               .getHeight(), Color.WHITE);\r
+\r
+               spriteBatch.draw(texture, 16, 58, 16, 16, 32, 32, 1, 1, angle, 0, 0,\r
+                               texture.getWidth(), texture.getHeight(), Color.WHITE, false,\r
+                               false);\r
+               spriteBatch.draw(texture, 64, 58, 16, 16, 32, 32, scale, scale, 0, 0,\r
+                               0, texture.getWidth(), texture.getHeight(), Color.WHITE, false,\r
+                               false);\r
+               spriteBatch.draw(texture, 112, 58, 16, 16, 32, 32, scale, scale, angle,\r
+                               0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,\r
+                               false, false);\r
+               spriteBatch.draw(texture, 160, 58, 0, 0, 32, 32, scale, scale, angle,\r
+                               0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,\r
+                               false, false);\r
+\r
+               // spriteBatch.drawText(font, "Test", 208, 10, Color.WHITE);\r
                spriteBatch.end();\r
                Gdx.graphics.getGL10().glFlush();\r
 \r
-// if( false )\r
-// {\r
-// Gdx.graphics.getGL10().glReadPixels( 16, 10, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
-// if( pixelBuffer.get(0) != 0xff00ff00 )\r
-// throw new GdxRuntimeException( "not pixel perfect!" );\r
-// Gdx.graphics.getGL10().glReadPixels( 47, 10, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
-// if( pixelBuffer.get(0) != 0xffff0000 )\r
-// throw new GdxRuntimeException( "not pixel perfect!" );\r
-// Gdx.graphics.getGL10().glReadPixels( 16, 41, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
-// if( pixelBuffer.get(0) != 0xff0000ff )\r
-// throw new GdxRuntimeException( "not pixel perfect!" );\r
-// }\r
+               // if( false )\r
+               // {\r
+               // Gdx.graphics.getGL10().glReadPixels( 16, 10, 1, 1, GL10.GL_RGBA,\r
+               // GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
+               // if( pixelBuffer.get(0) != 0xff00ff00 )\r
+               // throw new GdxRuntimeException( "not pixel perfect!" );\r
+               // Gdx.graphics.getGL10().glReadPixels( 47, 10, 1, 1, GL10.GL_RGBA,\r
+               // GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
+               // if( pixelBuffer.get(0) != 0xffff0000 )\r
+               // throw new GdxRuntimeException( "not pixel perfect!" );\r
+               // Gdx.graphics.getGL10().glReadPixels( 16, 41, 1, 1, GL10.GL_RGBA,\r
+               // GL10.GL_UNSIGNED_BYTE, pixelBuffer );\r
+               // if( pixelBuffer.get(0) != 0xff0000ff )\r
+               // throw new GdxRuntimeException( "not pixel perfect!" );\r
+               // }\r
 \r
                angle += 20 * Gdx.graphics.getDeltaTime();\r
                scale += vScale * Gdx.graphics.getDeltaTime();\r
@@ -88,23 +94,22 @@ public class SpriteBatchRotationTest implements GdxTest {
 \r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       @Override\r
+       public void create() {\r
+               spriteBatch = new SpriteBatch();\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/test.png", FileType.Internal), TextureFilter.Linear,\r
+                               TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                               TextureWrap.ClampToEdge);\r
+               // font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);\r
+               ByteBuffer buffer = ByteBuffer.allocateDirect(4);\r
+               buffer.order(ByteOrder.nativeOrder());\r
+               pixelBuffer = buffer.asIntBuffer();\r
 \r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (spriteBatch == null) {\r
-                       spriteBatch = new SpriteBatch();\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/test.png", FileType.Internal), TextureFilter.Linear,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-//                     font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);\r
-                       ByteBuffer buffer = ByteBuffer.allocateDirect(4);\r
-                       buffer.order(ByteOrder.nativeOrder());\r
-                       pixelBuffer = buffer.asIntBuffer();\r
-               }\r
-       }\r
-\r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index b8e3df8..9f6afad 100644 (file)
@@ -26,7 +26,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class SpriteBatchShaderTest implements GdxTest {\r
+public class SpriteBatchShaderTest extends GdxTest {\r
        int SPRITES = 400;\r
 \r
        long startTime = System.nanoTime();\r
@@ -44,10 +44,6 @@ public class SpriteBatchShaderTest implements GdxTest {
        Mesh mesh;\r
        float vertices[] = new float[SPRITES * 6 * (2 + 2 + 4)];\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                GL20 gl = Gdx.graphics.getGL20();\r
                gl.glClearColor(0.7f, 0.7f, 0.7f, 1);\r
@@ -93,13 +89,8 @@ public class SpriteBatchShaderTest implements GdxTest {
                frames++;\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               if (spriteBatch == null) spriteBatch = new SpriteBatch();\r
-\r
+       @Override public void create () {\r
+               spriteBatch = new SpriteBatch();\r
                Pixmap pixmap = Gdx.graphics.newPixmap(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal));\r
 // pixmap.setColor( 0, 0, 0, 0 );\r
 // pixmap.fillCircle( 16, 16, 4 );\r
index d20a452..35835f6 100644 (file)
@@ -14,7 +14,7 @@
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
@@ -27,7 +27,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class SpriteBatchTest implements GdxTest, InputListener {\r
+public class SpriteBatchTest extends GdxTest implements InputProcessor {\r
        int SPRITES = 400 / 2;\r
 \r
        long startTime = System.nanoTime();\r
@@ -46,14 +46,13 @@ public class SpriteBatchTest implements GdxTest, InputListener {
        float SCALE_SPEED = -1;\r
        int renderMethod = 0;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
 \r
        @Override public void render () {\r
                if (renderMethod == 0) renderNormal();\r
                ;\r
                if (renderMethod == 1) renderSprites();\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
        private void renderNormal () {\r
@@ -176,12 +175,8 @@ public class SpriteBatchTest implements GdxTest, InputListener {
                frames++;\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
-       @Override public void surfaceCreated () {\r
-               if (spriteBatch == null) spriteBatch = new SpriteBatch(1000);\r
+       @Override public void create () {\r
+               spriteBatch = new SpriteBatch(1000);\r
 \r
                Pixmap pixmap = Gdx.graphics.newPixmap(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal));\r
                texture = Gdx.graphics.newUnmanagedTexture(32, 32, Format.RGB565, TextureFilter.Linear, TextureFilter.Linear,\r
@@ -224,8 +219,7 @@ public class SpriteBatchTest implements GdxTest, InputListener {
                        sprites3[i].setPosition(x, y);\r
                        sprites3[i].setOrigin(16, 16);\r
                }\r
-\r
-               Gdx.input.addInputListener(this);\r
+       \r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
index 9cfc397..06bf8fb 100644 (file)
@@ -17,7 +17,7 @@ import java.util.ArrayList;
 import java.util.List;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.ImmediateModeRenderer;\r
@@ -33,16 +33,16 @@ import com.badlogic.gdx.scenes.scene2d.actors.Image;
 import com.badlogic.gdx.scenes.scene2d.actors.Label;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class StageTest implements GdxTest, InputListener {\r
+public class StageTest extends GdxTest implements InputProcessor {\r
        private static final int NUM_GROUPS = 5;\r
-       private static final int NUM_SPRITES = (int)Math.sqrt(400 / NUM_GROUPS);\r
+       private static final int NUM_SPRITES = (int) Math.sqrt(400 / NUM_GROUPS);\r
        private static final float SPACING = 5;\r
        ImmediateModeRenderer renderer;\r
        Stage stage;\r
        Stage ui;\r
        Texture texture;\r
        Texture uiTexture;\r
-//     Font font;\r
+       // Font font;\r
 \r
        boolean rotateSprites = false;\r
        boolean scaleSprites = false;\r
@@ -52,53 +52,60 @@ public class StageTest implements GdxTest, InputListener {
        float scale = 1;\r
        float vScale = 1;\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (stage == null) {\r
-                       Gdx.input.addInputListener(this);\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal),\r
-                               TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-//                     font = Gdx.graphics.newFont("DroidSans", 12, FontStyle.Plain);\r
-\r
-                       stage = new Stage(480, 320, true);\r
-\r
-                       float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;\r
-                       for (int i = 0; i < NUM_GROUPS; i++) {\r
-                               Group group = new Group("group" + i);\r
-                               group.x = (float)Math.random() * (stage.width() - NUM_SPRITES * (32 + SPACING));\r
-                               group.y = (float)Math.random() * (stage.height() - NUM_SPRITES * (32 + SPACING));\r
-                               group.originX = loc;\r
-                               group.originY = loc;\r
-\r
-                               fillGroup(group, texture);\r
-                               stage.addActor(group);\r
-                       }\r
-\r
-                       uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/ui.png", FileType.Internal), TextureFilter.Linear,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-                       ui = new Stage(480, 320, false);\r
-                       Image blend = new Image("blend button", new TextureRegion(uiTexture, 0, 0, 64, 32));\r
-                       blend.y = ui.height() - 32;\r
-                       Image rotate = new Image("rotate button", new TextureRegion(uiTexture, 64, 0, 64, 32));\r
-                       rotate.y = blend.y;\r
-                       rotate.x = 64;\r
-                       Image scale = new Image("scale button", new TextureRegion(uiTexture, 64, 32, 64, 32));\r
-                       scale.y = blend.y;\r
-                       scale.x = 128;\r
-\r
-                       ui.addActor(blend);\r
-                       ui.addActor(rotate);\r
-                       ui.addActor(scale);\r
-\r
-//                     Label fps = new Label("fps", font, "fps: 0");\r
-//                     fps.color.set(0, 1, 0, 1);\r
-//                     ui.addActor(fps);\r
-\r
-                       Thread.currentThread().setPriority(Thread.MAX_PRIORITY);\r
-                       renderer = new ImmediateModeRenderer();\r
+       @Override\r
+       public void create() {\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/badlogicsmall.jpg", FileType.Internal),\r
+                               TextureFilter.Linear, TextureFilter.Linear,\r
+                               TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
+               // font = Gdx.graphics.newFont("DroidSans", 12, FontStyle.Plain);\r
+\r
+               stage = new Stage(480, 320, true);\r
+\r
+               float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;\r
+               for (int i = 0; i < NUM_GROUPS; i++) {\r
+                       Group group = new Group("group" + i);\r
+                       group.x = (float) Math.random()\r
+                                       * (stage.width() - NUM_SPRITES * (32 + SPACING));\r
+                       group.y = (float) Math.random()\r
+                                       * (stage.height() - NUM_SPRITES * (32 + SPACING));\r
+                       group.originX = loc;\r
+                       group.originY = loc;\r
+\r
+                       fillGroup(group, texture);\r
+                       stage.addActor(group);\r
                }\r
+\r
+               uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/ui.png", FileType.Internal), TextureFilter.Linear,\r
+                               TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                               TextureWrap.ClampToEdge);\r
+               ui = new Stage(480, 320, false);\r
+               Image blend = new Image("blend button", new TextureRegion(uiTexture, 0,\r
+                               0, 64, 32));\r
+               blend.y = ui.height() - 32;\r
+               Image rotate = new Image("rotate button", new TextureRegion(uiTexture,\r
+                               64, 0, 64, 32));\r
+               rotate.y = blend.y;\r
+               rotate.x = 64;\r
+               Image scale = new Image("scale button", new TextureRegion(uiTexture,\r
+                               64, 32, 64, 32));\r
+               scale.y = blend.y;\r
+               scale.x = 128;\r
+\r
+               ui.addActor(blend);\r
+               ui.addActor(rotate);\r
+               ui.addActor(scale);\r
+\r
+               // Label fps = new Label("fps", font, "fps: 0");\r
+               // fps.color.set(0, 1, 0, 1);\r
+               // ui.addActor(fps);\r
+\r
+               Thread.currentThread().setPriority(Thread.MAX_PRIORITY);\r
+               renderer = new ImmediateModeRenderer();\r
        }\r
 \r
-       private void fillGroup (Group group, Texture texture) {\r
+       private void fillGroup(Group group, Texture texture) {\r
                float advance = 32 + SPACING;\r
                for (int y = 0; y < NUM_SPRITES * advance; y += advance)\r
                        for (int x = 0; x < NUM_SPRITES * advance; x += advance) {\r
@@ -112,11 +119,8 @@ public class StageTest implements GdxTest, InputListener {
                        }\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               ui.setViewport(480, 320, false);\r
-       }\r
-\r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
                gl.glClearColor(0.2f, 0.2f, 0.2f, 1);\r
@@ -128,14 +132,16 @@ public class StageTest implements GdxTest, InputListener {
 \r
                        if (actor != null)\r
                                if (actor instanceof Image)\r
-                                       ((Image)actor).color.set((float)Math.random(), (float)Math.random(), (float)Math.random(),\r
-                                               0.5f + 0.5f * (float)Math.random());\r
+                                       ((Image) actor).color.set((float) Math.random(),\r
+                                                       (float) Math.random(), (float) Math.random(),\r
+                                                       0.5f + 0.5f * (float) Math.random());\r
                }\r
 \r
                int len = stage.getGroups().size();\r
                for (int i = 0; i < len; i++)\r
                        if (rotateSprites)\r
-                               stage.getGroups().get(i).rotation += Gdx.graphics.getDeltaTime();\r
+                               stage.getGroups().get(i).rotation += Gdx.graphics\r
+                                               .getDeltaTime();\r
                        else\r
                                stage.getGroups().get(i).rotation = 0;\r
 \r
@@ -174,57 +180,70 @@ public class StageTest implements GdxTest, InputListener {
                for (int i = 0; i < len; i++) {\r
                        renderer.color(1, 0, 0, 1);\r
                        Group group = stage.getRoot().getGroups().get(i);\r
-                       renderer.vertex(group.x + group.originX, group.y + group.originY, 0);\r
+                       renderer\r
+                                       .vertex(group.x + group.originX, group.y + group.originY, 0);\r
                }\r
                renderer.end();\r
                Gdx.graphics.getGL10().glPointSize(4);\r
 \r
-//             ((Label)ui.findActor("fps")).text = "fps: " + Gdx.graphics.getFramesPerSecond() + ", actors " + images.size() + ", groups "\r
-//                     + stage.getGroups().size();\r
+               // ((Label)ui.findActor("fps")).text = "fps: " +\r
+               // Gdx.graphics.getFramesPerSecond() + ", actors " + images.size() +\r
+               // ", groups "\r
+               // + stage.getGroups().size();\r
                ui.render();\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public boolean touchDown (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDown(int x, int y, int pointer) {\r
                boolean touched = ui.touchDown(x, y, pointer);\r
                if (touched) {\r
                        Actor hitActor = ui.getLastTouchedChild();\r
-                       if (hitActor == null) return touched;\r
-                       if (hitActor.name.startsWith("blend")) if (stage.getSpriteBatch().isBlendingEnabled())\r
-                               stage.getSpriteBatch().disableBlending();\r
-                       else\r
-                               stage.getSpriteBatch().enableBlending();\r
-                       if (hitActor.name.startsWith("rotate")) rotateSprites = !rotateSprites;\r
-                       if (hitActor.name.startsWith("scale")) scaleSprites = !scaleSprites;\r
+                       if (hitActor == null)\r
+                               return touched;\r
+                       if (hitActor.name.startsWith("blend"))\r
+                               if (stage.getSpriteBatch().isBlendingEnabled())\r
+                                       stage.getSpriteBatch().disableBlending();\r
+                               else\r
+                                       stage.getSpriteBatch().enableBlending();\r
+                       if (hitActor.name.startsWith("rotate"))\r
+                               rotateSprites = !rotateSprites;\r
+                       if (hitActor.name.startsWith("scale"))\r
+                               scaleSprites = !scaleSprites;\r
                }\r
                return touched;\r
        }\r
 \r
-       @Override public boolean touchUp (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchUp(int x, int y, int pointer) {\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDragged (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDragged(int x, int y, int pointer) {\r
                return false;\r
        }\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
 \r
-       @Override public boolean keyDown (int keycode) {\r
+       @Override\r
+       public boolean keyDown(int keycode) {\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyUp (int keycode) {\r
+       @Override\r
+       public boolean keyUp(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyTyped (char character) {\r
+       @Override\r
+       public boolean keyTyped(char character) {\r
                return false;\r
        }\r
 \r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index 6356c7e..ff64243 100644 (file)
@@ -1,4 +1,3 @@
-\r
 package com.badlogic.gdx.tests;\r
 \r
 import java.util.Random;\r
@@ -18,7 +17,7 @@ import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.collision.Ray;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class TerrainTest implements GdxTest {\r
+public class TerrainTest extends GdxTest {\r
        ImmediateModeRenderer renderer;\r
        TerrainChunk chunk;\r
        Mesh mesh;\r
@@ -27,39 +26,38 @@ public class TerrainTest implements GdxTest {
        boolean intersected = false;\r
        long lastTime = System.nanoTime();\r
 \r
-       @Override public void surfaceCreated () {\r
-               if (chunk == null) {\r
-                       renderer = new ImmediateModeRenderer();\r
-\r
-                       chunk = new TerrainChunk(32, 32, 4);\r
+       @Override\r
+       public void create() {\r
+               renderer = new ImmediateModeRenderer();\r
 \r
-                       Random rand = new Random();\r
-                       int len = chunk.vertices.length;\r
-                       for (int i = 3; i < len; i += 4)\r
-                               chunk.vertices[i] = Color.toFloatBits(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255), 255);\r
+               chunk = new TerrainChunk(32, 32, 4);\r
 \r
-                       mesh = new Mesh(true, chunk.vertices.length / 3, chunk.indices.length, new VertexAttribute(\r
-                               VertexAttributes.Usage.Position, 3, "a_position"), new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4,\r
-                               "a_color"));\r
+               Random rand = new Random();\r
+               int len = chunk.vertices.length;\r
+               for (int i = 3; i < len; i += 4)\r
+                       chunk.vertices[i] = Color.toFloatBits(rand.nextInt(255), rand\r
+                                       .nextInt(255), rand.nextInt(255), 255);\r
 \r
-                       mesh.setVertices(chunk.vertices);\r
-                       mesh.setIndices(chunk.indices);\r
+               mesh = new Mesh(true, chunk.vertices.length / 3, chunk.indices.length,\r
+                               new VertexAttribute(VertexAttributes.Usage.Position, 3,\r
+                                               "a_position"), new VertexAttribute(\r
+                                               VertexAttributes.Usage.ColorPacked, 4, "a_color"));\r
 \r
-                       camera = new PerspectiveCamera();\r
-                       camera.getPosition().set(0, 5, 5);\r
-                       camera.getDirection().set(0, 0, 0).sub(camera.getPosition()).nor();\r
-                       camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
-                       camera.setNear(0.5f);\r
-                       camera.setFar(300);\r
-                       camera.setFov(67);\r
-               }\r
-       }\r
+               mesh.setVertices(chunk.vertices);\r
+               mesh.setIndices(chunk.indices);\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+               camera = new PerspectiveCamera();\r
+               camera.getPosition().set(0, 5, 5);\r
+               camera.getDirection().set(0, 0, 0).sub(camera.getPosition()).nor();\r
+               camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+               camera.setNear(0.5f);\r
+               camera.setFar(300);\r
+               camera.setFov(67);\r
 \r
        }\r
 \r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
                gl.glEnable(GL10.GL_DEPTH_TEST);\r
@@ -80,29 +78,34 @@ public class TerrainTest implements GdxTest {
                handleInput(Gdx.input, Gdx.graphics.getDeltaTime());\r
 \r
                if (System.nanoTime() - lastTime > 1000000000) {\r
-                       Gdx.app.log("TerrainTest", "fps: " + Gdx.graphics.getFramesPerSecond());\r
+                       Gdx.app.log("TerrainTest", "fps: "\r
+                                       + Gdx.graphics.getFramesPerSecond());\r
                        lastTime = System.nanoTime();\r
                }\r
        }\r
 \r
-       private void handleInput (Input input, float delta) {\r
+       private void handleInput(Input input, float delta) {\r
                if (input.isTouched()) {\r
                        Ray ray = camera.getPickRay(input.getX(), input.getY());\r
-                       if (Intersector.intersectRayTriangles(ray, chunk.vertices, chunk.indices, 4, intersection)) intersected = true;\r
+                       if (Intersector.intersectRayTriangles(ray, chunk.vertices,\r
+                                       chunk.indices, 4, intersection))\r
+                               intersected = true;\r
                } else {\r
                        intersected = false;\r
                }\r
 \r
-               if (input.isKeyPressed(Keys.KEYCODE_W)) camera.getPosition().z -= delta;\r
-               if (input.isKeyPressed(Keys.KEYCODE_S)) camera.getPosition().z += delta;\r
-               if (input.isKeyPressed(Keys.KEYCODE_A)) camera.getPosition().x -= delta;\r
-               if (input.isKeyPressed(Keys.KEYCODE_D)) camera.getPosition().x += delta;\r
-               if (input.isKeyPressed(Keys.KEYCODE_Q)) camera.getPosition().y += delta;\r
-               if (input.isKeyPressed(Keys.KEYCODE_E)) camera.getPosition().y -= delta;\r
-       }\r
-\r
-       @Override public void dispose () {\r
-\r
+               if (input.isKeyPressed(Keys.KEYCODE_W))\r
+                       camera.getPosition().z -= delta;\r
+               if (input.isKeyPressed(Keys.KEYCODE_S))\r
+                       camera.getPosition().z += delta;\r
+               if (input.isKeyPressed(Keys.KEYCODE_A))\r
+                       camera.getPosition().x -= delta;\r
+               if (input.isKeyPressed(Keys.KEYCODE_D))\r
+                       camera.getPosition().x += delta;\r
+               if (input.isKeyPressed(Keys.KEYCODE_Q))\r
+                       camera.getPosition().y += delta;\r
+               if (input.isKeyPressed(Keys.KEYCODE_E))\r
+                       camera.getPosition().y -= delta;\r
        }\r
 \r
        final static class TerrainChunk {\r
@@ -113,13 +116,14 @@ public class TerrainTest implements GdxTest {
                public final short[] indices;\r
                public final int vertexSize;\r
 \r
-               public TerrainChunk (int width, int height, int vertexSize) {\r
+               public TerrainChunk(int width, int height, int vertexSize) {\r
                        if ((width + 1) * (height + 1) > Short.MAX_VALUE)\r
-                               throw new IllegalArgumentException("Chunk size too big, (width + 1)*(height+1) must be <= 32767");\r
+                               throw new IllegalArgumentException(\r
+                                               "Chunk size too big, (width + 1)*(height+1) must be <= 32767");\r
 \r
                        this.heightMap = new byte[(width + 1) * (height + 1)];\r
-                       this.width = (short)width;\r
-                       this.height = (short)height;\r
+                       this.width = (short) width;\r
+                       this.height = (short) height;\r
                        this.vertices = new float[heightMap.length * vertexSize];\r
                        this.indices = new short[width * height * 6];\r
                        this.vertexSize = vertexSize;\r
@@ -128,7 +132,7 @@ public class TerrainTest implements GdxTest {
                        buildVertices();\r
                }\r
 \r
-               public void buildVertices () {\r
+               public void buildVertices() {\r
                        int heightPitch = height + 1;\r
                        int widthPitch = width + 1;\r
 \r
@@ -146,12 +150,12 @@ public class TerrainTest implements GdxTest {
                        }\r
                }\r
 \r
-               private void buildIndices () {\r
+               private void buildIndices() {\r
                        int idx = 0;\r
-                       short pitch = (short)(width + 1);\r
+                       short pitch = (short) (width + 1);\r
                        short i1 = 0;\r
                        short i2 = 1;\r
-                       short i3 = (short)(1 + pitch);\r
+                       short i3 = (short) (1 + pitch);\r
                        short i4 = pitch;\r
 \r
                        short row = 0;\r
@@ -174,14 +178,15 @@ public class TerrainTest implements GdxTest {
 \r
                                row += pitch;\r
                                i1 = row;\r
-                               i2 = (short)(row + 1);\r
-                               i3 = (short)(i2 + pitch);\r
-                               i4 = (short)(row + pitch);\r
+                               i2 = (short) (row + 1);\r
+                               i3 = (short) (i2 + pitch);\r
+                               i4 = (short) (row + pitch);\r
                        }\r
                }\r
        }\r
 \r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index 5b735e4..9e385a9 100644 (file)
@@ -17,7 +17,6 @@ import java.util.ArrayList;
 \r
 import com.badlogic.gdx.Files;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.Color;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
@@ -28,7 +27,7 @@ import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class TextureRenderTest implements GdxTest {\r
+public class TextureRenderTest extends GdxTest {\r
 \r
        private OrthographicCamera camera;\r
        private Mesh mesh;\r
@@ -37,7 +36,7 @@ public class TextureRenderTest implements GdxTest {
        private ArrayList<SimpleRect> rects = new ArrayList<SimpleRect>();\r
        Color color = new Color(Color.GREEN);\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                camera = new OrthographicCamera();\r
                camera.setViewport(480, 320);\r
                camera.getPosition().set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);\r
@@ -105,10 +104,6 @@ public class TextureRenderTest implements GdxTest {
 \r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
 \r
                GL10 gl = Gdx.graphics.getGL10();\r
@@ -146,9 +141,6 @@ public class TextureRenderTest implements GdxTest {
 \r
        }\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
 \r
        private ArrayList<SimpleRect> createRects () {\r
                ArrayList<SimpleRect> l = new ArrayList<SimpleRect>();\r
index af2bcb7..1b3d26c 100644 (file)
@@ -1,8 +1,7 @@
-\r
 package com.badlogic.gdx.tests;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Texture;\r
@@ -32,138 +31,151 @@ import com.badlogic.gdx.scenes.scene2d.actors.Button.ClickListener;
 import com.badlogic.gdx.scenes.scene2d.actors.LinearGroup.LinearGroupLayout;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class UITest implements GdxTest, InputListener {\r
+public class UITest extends GdxTest implements InputProcessor {\r
        Texture uiTexture;\r
        Texture badlogic;\r
        TextureAtlas atlas;\r
        Stage ui;\r
-//     Font font;\r
-\r
-       @Override public void surfaceCreated () {\r
-               if (uiTexture == null) {\r
-                       Gdx.input.addInputListener(this);\r
-                       Gdx.input.setCatchBackKey( true );\r
-\r
-//                     font = Gdx.graphics.newFont( "Droid Sans", 20, FontStyle.Plain );\r
-                       \r
-                       uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/ui.png", FileType.Internal), TextureFilter.Linear,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-\r
-                       badlogic = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),\r
-                               TextureFilter.MipMap, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);                          \r
-\r
-                       ui = new Stage(480, 320, false);\r
-                       atlas = new TextureAtlas(uiTexture);\r
-                       atlas.addRegion("blend", 0, 0, 64, 32);\r
-                       atlas.addRegion("blendDown", -1, -1, 64, 32);\r
-                       atlas.addRegion("rotate", 64, 0, 64, 32);\r
-                       atlas.addRegion("rotateDown", 63, -1, 64, 32);\r
-                       atlas.addRegion("scale", 64, 32, 64, 32);\r
-                       atlas.addRegion("scaleDown", 63, 31, 64, 32);\r
-                       atlas.addRegion("button", 0, 64, 64, 32);\r
-                       atlas.addRegion("buttonDown", -1, 63, 64, 32);\r
-\r
-                       Image img1 = new Image("image1", new TextureRegion(badlogic, 0, 0, 256, 256));\r
-                       img1.width = img1.height = 64;\r
-                       img1.originX = img1.originY = 32;\r
-                       img1.action(Sequence.$(FadeOut.$(1), \r
-                                                                                 FadeIn.$(1), \r
-                                                                                 Delay.$(MoveTo.$(100, 100, 1), 2), ScaleTo.$(0.5f, 0.5f, 1),\r
-                                                                                 FadeOut.$(0.5f), \r
-                                                                                 Delay.$(Parallel.$(RotateTo.$(360, 1), FadeIn.$(1), ScaleTo.$(1, 1, 1)), 1)));\r
-                       ui.addActor(img1);\r
-\r
-                       Image img2 = new Image("image2", new TextureRegion(badlogic, 0, 0, 256, 256));\r
-                       img2.width = img2.height = 64;\r
-                       img2.originX = img2.originY = 32;\r
-                       img2.action(Repeat.$(Sequence.$(MoveBy.$(50, 0, 1), \r
-                                                                                                         MoveBy.$(0, 50, 1), \r
-                                                                                                         MoveBy.$(-50, 0, 1), \r
-                                                                                                         MoveBy.$(0, -50, 1)), 3));\r
-                       ui.addActor(img2);\r
-\r
-                       Button button = new Button("button", atlas.getRegion("button"), atlas.getRegion("buttonDown"));\r
-                       button.action(Forever.$(RotateBy.$(360, 4)));\r
-                       button.clickListener = new ClickListener() {\r
-                               \r
-                               @Override public void clicked (Button button) {\r
-                                       if( Gdx.input.supportsOnscreenKeyboard() )\r
-                                               Gdx.input.setOnscreenKeyboardVisible( true );\r
-                               }\r
-                       };\r
-                       ui.addActor(button);                    \r
-                       \r
-//                     Label label = new Label( "label", font, "text input: " );\r
-//                     label.x = 10; label.y = Gdx.graphics.getHeight() - 20;\r
-//                     ui.addActor(label);\r
-\r
-                       LinearGroup linear = new LinearGroup("linear", 64, 32 * 3, LinearGroupLayout.Vertical);\r
-                       linear.x = 200;\r
-                       linear.y = 150;\r
-                       linear.scaleX = linear.scaleY = 0;\r
-                       linear.addActor(new Button("blend", atlas.getRegion("blend"), atlas.getRegion("blendDown")));\r
-                       linear.addActor(new Button("scale", atlas.getRegion("scale"), atlas.getRegion("scaleDown")));\r
-                       linear.addActor(new Button("rotate", atlas.getRegion("rotate"), atlas.getRegion("rotateDown")));\r
-                       linear.action(Parallel.$(ScaleTo.$(1, 1, 2), RotateTo.$(720, 2)));\r
-                       ui.addActor(linear);\r
-\r
-                       LinearGroup linearh = new LinearGroup("linearh", 64 * 3, 32, LinearGroupLayout.Horizontal);\r
-                       linearh.x = 500;\r
-                       linearh.y = 10;\r
-                       linearh.addActor(new Button("blendh", atlas.getRegion("blend"), atlas.getRegion("blendDown")));\r
-                       linearh.addActor(new Button("scaleh", atlas.getRegion("scale"), atlas.getRegion("scaleDown")));\r
-                       linearh.addActor(new Button("rotateh", atlas.getRegion("rotate"), atlas.getRegion("rotateDown")));\r
-                       linearh.action(MoveTo.$(100, 10, 1.5f));\r
-                       ui.addActor(linearh);\r
-\r
-// Group.enableDebugging( "data/debug.png" );\r
-               }\r
-       }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       // Font font;\r
+\r
+       @Override\r
+       public void create() {\r
+//             Gdx.input.setCatchBackKey(true);\r
+\r
+               // font = Gdx.graphics.newFont( "Droid Sans", 20, FontStyle.Plain );\r
+\r
+               uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/ui.png", FileType.Internal), TextureFilter.Linear,\r
+                               TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                               TextureWrap.ClampToEdge);\r
+\r
+               badlogic = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
+                               "data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
+                               TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+                               TextureWrap.ClampToEdge);\r
+\r
+               ui = new Stage(480, 320, false);\r
+               atlas = new TextureAtlas(uiTexture);\r
+               atlas.addRegion("blend", 0, 0, 64, 32);\r
+               atlas.addRegion("blendDown", -1, -1, 64, 32);\r
+               atlas.addRegion("rotate", 64, 0, 64, 32);\r
+               atlas.addRegion("rotateDown", 63, -1, 64, 32);\r
+               atlas.addRegion("scale", 64, 32, 64, 32);\r
+               atlas.addRegion("scaleDown", 63, 31, 64, 32);\r
+               atlas.addRegion("button", 0, 64, 64, 32);\r
+               atlas.addRegion("buttonDown", -1, 63, 64, 32);\r
+\r
+               Image img1 = new Image("image1", new TextureRegion(badlogic, 0, 0, 256,\r
+                               256));\r
+               img1.width = img1.height = 64;\r
+               img1.originX = img1.originY = 32;\r
+               img1.action(Sequence.$(FadeOut.$(1), FadeIn.$(1), Delay.$(MoveTo.$(100,\r
+                               100, 1), 2), ScaleTo.$(0.5f, 0.5f, 1), FadeOut.$(0.5f), Delay\r
+                               .$(Parallel.$(RotateTo.$(360, 1), FadeIn.$(1), ScaleTo.$(1, 1,\r
+                                               1)), 1)));\r
+               ui.addActor(img1);\r
+\r
+               Image img2 = new Image("image2", new TextureRegion(badlogic, 0, 0, 256,\r
+                               256));\r
+               img2.width = img2.height = 64;\r
+               img2.originX = img2.originY = 32;\r
+               img2.action(Repeat.$(Sequence.$(MoveBy.$(50, 0, 1), MoveBy.$(0, 50, 1),\r
+                               MoveBy.$(-50, 0, 1), MoveBy.$(0, -50, 1)), 3));\r
+               ui.addActor(img2);\r
+\r
+               Button button = new Button("button", atlas.getRegion("button"), atlas\r
+                               .getRegion("buttonDown"));\r
+               button.action(Forever.$(RotateBy.$(360, 4)));\r
+               button.clickListener = new ClickListener() {\r
+\r
+                       @Override\r
+                       public void clicked(Button button) {\r
+                               if (Gdx.input.supportsOnscreenKeyboard())\r
+                                       Gdx.input.setOnscreenKeyboardVisible(true);\r
+                       }\r
+               };\r
+               ui.addActor(button);\r
+\r
+               // Label label = new Label( "label", font, "text input: " );\r
+               // label.x = 10; label.y = Gdx.graphics.getHeight() - 20;\r
+               // ui.addActor(label);\r
+\r
+               LinearGroup linear = new LinearGroup("linear", 64, 32 * 3,\r
+                               LinearGroupLayout.Vertical);\r
+               linear.x = 200;\r
+               linear.y = 150;\r
+               linear.scaleX = linear.scaleY = 0;\r
+               linear.addActor(new Button("blend", atlas.getRegion("blend"), atlas\r
+                               .getRegion("blendDown")));\r
+               linear.addActor(new Button("scale", atlas.getRegion("scale"), atlas\r
+                               .getRegion("scaleDown")));\r
+               linear.addActor(new Button("rotate", atlas.getRegion("rotate"), atlas\r
+                               .getRegion("rotateDown")));\r
+               linear.action(Parallel.$(ScaleTo.$(1, 1, 2), RotateTo.$(720, 2)));\r
+               ui.addActor(linear);\r
+\r
+               LinearGroup linearh = new LinearGroup("linearh", 64 * 3, 32,\r
+                               LinearGroupLayout.Horizontal);\r
+               linearh.x = 500;\r
+               linearh.y = 10;\r
+               linearh.addActor(new Button("blendh", atlas.getRegion("blend"), atlas\r
+                               .getRegion("blendDown")));\r
+               linearh.addActor(new Button("scaleh", atlas.getRegion("scale"), atlas\r
+                               .getRegion("scaleDown")));\r
+               linearh.addActor(new Button("rotateh", atlas.getRegion("rotate"), atlas\r
+                               .getRegion("rotateDown")));\r
+               linearh.action(MoveTo.$(100, 10, 1.5f));\r
+               ui.addActor(linearh);\r
+\r
+               // Group.enableDebugging( "data/debug.png" );\r
 \r
        }\r
 \r
-       @Override public void render () {\r
+       @Override\r
+       public void render() {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
                ui.act(Gdx.graphics.getDeltaTime());\r
                ui.render();\r
-       }\r
-\r
-       @Override public void dispose () {\r
 \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
-       @Override public boolean keyDown (int keycode) {\r
+       @Override\r
+       public boolean keyDown(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyUp (int keycode) {\r
+       @Override\r
+       public boolean keyUp(int keycode) {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
 \r
-       @Override public boolean keyTyped (char character) {\r
-//             Label label = ((Label)ui.findActor( "label" ));\r
-//             if( character == '\b' ) {\r
-//                     if( label.text.length() > "text input: ".length() )\r
-//                             label.text = label.text.substring( 0, label.text.length()-1 ); \r
-//             } else {                        \r
-//                     label.text += character;\r
-//             }\r
+       @Override\r
+       public boolean keyTyped(char character) {\r
+               // Label label = ((Label)ui.findActor( "label" ));\r
+               // if( character == '\b' ) {\r
+               // if( label.text.length() > "text input: ".length() )\r
+               // label.text = label.text.substring( 0, label.text.length()-1 );\r
+               // } else {\r
+               // label.text += character;\r
+               // }\r
                return false;\r
        }\r
 \r
-       @Override public boolean touchDown (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDown(int x, int y, int pointer) {\r
                ui.touchDown(x, y, pointer);\r
                return false;\r
        }\r
 \r
        Vector2 point = new Vector2();\r
 \r
-       @Override public boolean touchUp (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchUp(int x, int y, int pointer) {\r
                if (!ui.touchUp(x, y, pointer)) {\r
                        Actor actor = ui.findActor("image1");\r
                        if (actor != null) {\r
@@ -180,12 +192,14 @@ public class UITest implements GdxTest, InputListener {
                return false;\r
        }\r
 \r
-       @Override public boolean touchDragged (int x, int y, int pointer) {\r
+       @Override\r
+       public boolean touchDragged(int x, int y, int pointer) {\r
                ui.touchDragged(x, y, pointer);\r
                return false;\r
        }\r
 \r
-       @Override public boolean needsGL20 () {\r
+       @Override\r
+       public boolean needsGL20() {\r
                // TODO Auto-generated method stub\r
                return false;\r
        }\r
index 807579c..b882d9f 100644 (file)
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexArray;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class VertexArrayClassTest implements GdxTest {\r
+public class VertexArrayClassTest extends GdxTest {\r
        Texture texture;\r
        VertexArray va;\r
        ShortBuffer indices;\r
@@ -26,7 +26,7 @@ public class VertexArrayClassTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
+       public void destroy() {\r
                texture.dispose();\r
                va.dispose();\r
        }\r
@@ -50,13 +50,9 @@ public class VertexArrayClassTest implements GdxTest {
                va.unbind();\r
        }\r
 \r
-       @Override\r
-       public void surfaceChanged(int width, int height) {\r
-               \r
-       }\r
 \r
        @Override\r
-       public void surfaceCreated() {\r
+       public void create() {\r
                va = new VertexArray(3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),\r
                                                                new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),\r
                                                                new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));\r
@@ -67,11 +63,9 @@ public class VertexArrayClassTest implements GdxTest {
                indices = BufferUtils.newShortBuffer(3);\r
                indices.put( new short[] { 0, 1, 2 } );\r
                indices.flip();\r
-               \r
-               if( texture == null ) {\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),\r
-                                                                                         TextureFilter.Linear, TextureFilter.Linear, \r
-                                                                                         TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               }\r
+                               \r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),\r
+                                                                                 TextureFilter.Linear, TextureFilter.Linear, \r
+                                                                                 TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);            \r
        }\r
 }\r
index ae9fbfd..2b8ab8f 100644 (file)
@@ -19,19 +19,14 @@ import java.nio.FloatBuffer;
 import java.nio.ShortBuffer;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class VertexArrayTest implements GdxTest {\r
+public class VertexArrayTest extends GdxTest {\r
        FloatBuffer vertices;\r
        ShortBuffer indices;\r
        final int BYTES_PER_VERTEX = (3 + 4) * 4;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                GL10 gl = Gdx.graphics.getGL10();\r
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
@@ -49,7 +44,7 @@ public class VertexArrayTest implements GdxTest {
                gl.glDrawElements(GL10.GL_TRIANGLES, 3, GL10.GL_UNSIGNED_SHORT, indices);\r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                ByteBuffer buffer = ByteBuffer.allocateDirect(BYTES_PER_VERTEX * 3);\r
                buffer.order(ByteOrder.nativeOrder());\r
                vertices = buffer.asFloatBuffer();\r
@@ -69,11 +64,6 @@ public class VertexArrayTest implements GdxTest {
                indices.flip();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
        @Override public boolean needsGL20 () {\r
                // TODO Auto-generated method stub\r
                return false;\r
index dd1ac8f..7aabcb5 100644 (file)
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class VertexBufferObjectClassTest implements GdxTest {\r
+public class VertexBufferObjectClassTest extends GdxTest {\r
        Texture texture;\r
        VertexBufferObject vbo;\r
        ShortBuffer indices;\r
@@ -26,7 +26,7 @@ public class VertexBufferObjectClassTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
+       public void destroy() {\r
                texture.dispose();\r
                vbo.dispose();          \r
        }\r
@@ -51,13 +51,7 @@ public class VertexBufferObjectClassTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void surfaceChanged(int width, int height) {\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void surfaceCreated() {\r
-               if( texture == null ) {\r
+       public void create() {          \r
                        vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),\r
                                                                        new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),\r
                                                                        new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));\r
@@ -70,10 +64,12 @@ public class VertexBufferObjectClassTest implements GdxTest {
                        indices.flip();\r
                                         \r
                        texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),\r
-                                                                                         TextureFilter.Linear, TextureFilter.Linear, \r
-                                                                                         TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               }\r
-               else\r
-                       vbo.invalidate(); \r
+                                                                                         TextureFilter.Linear, TextureFilter.Linear,                                                   \r
+                                                                                         TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); \r
+       }\r
+       \r
+       @Override\r
+       public void resume() {\r
+               vbo.invalidate();\r
        }\r
 }\r
index 8207e6b..d7b17bb 100644 (file)
@@ -16,7 +16,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class VertexBufferObjectShaderTest implements GdxTest {\r
+public class VertexBufferObjectShaderTest extends GdxTest {\r
        Texture texture;\r
        ShaderProgram shader;\r
        VertexBufferObject vbo;\r
@@ -28,7 +28,7 @@ public class VertexBufferObjectShaderTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void dispose() {\r
+       public void destroy() {\r
                texture.dispose();\r
                vbo.dispose();\r
                shader.dispose();\r
@@ -51,13 +51,7 @@ public class VertexBufferObjectShaderTest implements GdxTest {
        }\r
 \r
        @Override\r
-       public void surfaceChanged(int width, int height) {\r
-\r
-       }\r
-\r
-       @Override\r
-       public void surfaceCreated() {\r
-               if (texture == null) {\r
+       public void create() {\r
                        String vertexShader = "attribute vec4 a_position;    \n"\r
                                        + "attribute vec4 a_color;\n"\r
                                        + "attribute vec2 a_texCoords;\n"                                       \r
@@ -94,9 +88,12 @@ public class VertexBufferObjectShaderTest implements GdxTest {
                        texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(\r
                                        "data/badlogic.jpg", FileType.Internal),\r
                                        TextureFilter.Linear, TextureFilter.Linear,\r
-                                       TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-               } else\r
-                       vbo.invalidate();\r
+                                       TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);                                      \r
+       }\r
+       \r
+       @Override\r
+       public void resume() {\r
+               vbo.invalidate();\r
        }\r
 \r
 }\r
index 50e79ee..9ce70d6 100644 (file)
@@ -17,19 +17,14 @@ import java.nio.FloatBuffer;
 import java.nio.ShortBuffer;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
 import com.badlogic.gdx.graphics.GL11;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 import com.badlogic.gdx.utils.BufferUtils;\r
 \r
-public class VertexBufferObjectTest implements GdxTest {\r
+public class VertexBufferObjectTest extends GdxTest {\r
        int vboHandle;\r
        int vboIndexHandle;\r
 \r
-       @Override public void dispose () {\r
-\r
-       }\r
-\r
        @Override public void render () {\r
                GL11 gl = Gdx.graphics.getGL11();\r
 \r
@@ -48,7 +43,7 @@ public class VertexBufferObjectTest implements GdxTest {
                gl.glDrawElements(GL11.GL_TRIANGLES, 3, GL11.GL_UNSIGNED_SHORT, 0);\r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
 \r
                FloatBuffer vertices = BufferUtils.newFloatBuffer(3 * 7);\r
                vertices.put(new float[] {-0.5f, -0.5f, 0, 1, 0, 0, 1, 0.5f, -0.5f, 0, 0, 1, 0, 1, 0.0f, 0.5f, 0, 0, 0, 1, 1});\r
@@ -71,10 +66,28 @@ public class VertexBufferObjectTest implements GdxTest {
                gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, 3 * 2, indices, GL11.GL_STATIC_DRAW);\r
                gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);\r
        }\r
+       \r
+       public void resume() {\r
+               FloatBuffer vertices = BufferUtils.newFloatBuffer(3 * 7);\r
+               vertices.put(new float[] {-0.5f, -0.5f, 0, 1, 0, 0, 1, 0.5f, -0.5f, 0, 0, 1, 0, 1, 0.0f, 0.5f, 0, 0, 0, 1, 1});\r
+               vertices.flip();\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
+               GL11 gl = Gdx.graphics.getGL11();\r
+               int[] handle = new int[1];\r
+               gl.glGenBuffers(1, handle, 0);\r
+               vboHandle = handle[0];\r
+               gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, vboHandle);\r
+               gl.glBufferData(GL11.GL_ARRAY_BUFFER, 3 * 7 * 4, vertices, GL11.GL_STATIC_DRAW);\r
+               gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);\r
 \r
+               ShortBuffer indices = BufferUtils.newShortBuffer(3);\r
+               indices.put(new short[] {0, 1, 2});\r
+               indices.flip();\r
+               gl.glGenBuffers(1, handle, 0);\r
+               vboIndexHandle = handle[0];\r
+               gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, vboIndexHandle);\r
+               gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, 3 * 2, indices, GL11.GL_STATIC_DRAW);\r
+               gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);\r
        }\r
 \r
        @Override public boolean needsGL20 () {\r
index c41eb4f..87827fd 100644 (file)
@@ -15,31 +15,15 @@ package com.badlogic.gdx.tests;
 \r
 import java.nio.ShortBuffer;\r
 \r
-import com.badlogic.gdx.Application.ApplicationType;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Application.ApplicationType;\r
 import com.badlogic.gdx.audio.analysis.AudioTools;\r
 import com.badlogic.gdx.audio.io.VorbisDecoder;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class VorbisTest implements GdxTest {\r
-\r
-       @Override public void dispose () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void render () {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
-       }\r
+public class VorbisTest extends GdxTest {\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                VorbisDecoder decoder = null;\r
                if (Gdx.app.getType() == ApplicationType.Android)\r
                        decoder = new VorbisDecoder("/sdcard/audio/schism.ogg");\r
index 48d12e4..8c377e6 100644 (file)
@@ -4,7 +4,7 @@ package com.badlogic.gdx.tests;
 import java.util.Random;\r
 \r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.Mesh;\r
@@ -21,7 +21,7 @@ import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.collision.Ray;\r
 import com.badlogic.gdx.tests.utils.GdxTest;\r
 \r
-public class WaterRipples implements GdxTest, InputListener {\r
+public class WaterRipples extends GdxTest implements InputProcessor {\r
        static final short WIDTH = 50;\r
        static final short HEIGHT = 50;\r
        static final float INV_WIDTH = 1.0f / WIDTH;\r
@@ -45,34 +45,30 @@ public class WaterRipples implements GdxTest, InputListener {
        float[][] intp;\r
        float[] vertices;\r
 \r
-       @Override public void surfaceCreated () {\r
-\r
-               if (!initialized) {\r
-                       camera = new PerspectiveCamera();\r
-                       camera.getPosition().set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);\r
-                       camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth());\r
-                       camera.setFov(90);\r
-                       camera.setNear(0.1f);\r
-                       camera.setFar(1000);\r
-                       last = new float[WIDTH + 1][HEIGHT + 1];\r
-                       curr = new float[WIDTH + 1][HEIGHT + 1];\r
-                       intp = new float[WIDTH + 1][HEIGHT + 1];\r
-                       vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];\r
-                       mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6, new VertexAttribute(\r
-                               VertexAttributes.Usage.Position, 3, "a_Position"), new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2,\r
-                               "a_texCoords"));\r
-                       texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/stones.jpg", FileType.Internal), TextureFilter.Linear,\r
-                               TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
-\r
-                       createIndices();\r
-                       updateVertices(curr);\r
-                       initialized = true;\r
-\r
-                       batch = new SpriteBatch();\r
+       @Override public void create () {\r
+               \r
+               camera = new PerspectiveCamera();\r
+               camera.getPosition().set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);\r
+               camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth());\r
+               camera.setFov(90);\r
+               camera.setNear(0.1f);\r
+               camera.setFar(1000);\r
+               last = new float[WIDTH + 1][HEIGHT + 1];\r
+               curr = new float[WIDTH + 1][HEIGHT + 1];\r
+               intp = new float[WIDTH + 1][HEIGHT + 1];\r
+               vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];\r
+               mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6, new VertexAttribute(\r
+                       VertexAttributes.Usage.Position, 3, "a_Position"), new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2,\r
+                       "a_texCoords"));\r
+               texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/stones.jpg", FileType.Internal), TextureFilter.Linear,\r
+                       TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
+\r
+               createIndices();\r
+               updateVertices(curr);\r
+               initialized = true;\r
+\r
+               batch = new SpriteBatch();\r
 //                     font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);\r
-\r
-                       Gdx.input.addInputListener(this);\r
-               }\r
        }\r
 \r
        private void createIndices () {\r
@@ -195,10 +191,8 @@ public class WaterRipples implements GdxTest, InputListener {
                batch.begin();\r
 //             batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20, Color.WHITE);\r
                batch.end();\r
-       }\r
-\r
-       @Override public void dispose () {\r
-\r
+               \r
+               Gdx.input.processEvents(this);\r
        }\r
 \r
        @Override public boolean keyDown (int keycode) {\r
@@ -235,10 +229,6 @@ public class WaterRipples implements GdxTest, InputListener {
                return false;\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
-\r
-       }\r
-\r
        @Override public boolean needsGL20 () {\r
                // TODO Auto-generated method stub\r
                return false;\r
index 443aeae..5961a94 100644 (file)
 \r
 package com.badlogic.gdx.tests.box2d;\r
 \r
+import com.badlogic.gdx.ApplicationListener;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputListener;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.InputProcessor;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.OrthographicCamera;\r
 import com.badlogic.gdx.math.Vector2;\r
 import com.badlogic.gdx.physics.box2d.Body;\r
 import com.badlogic.gdx.physics.box2d.BodyDef;\r
-import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;\r
 import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;\r
 import com.badlogic.gdx.physics.box2d.Fixture;\r
 import com.badlogic.gdx.physics.box2d.QueryCallback;\r
 import com.badlogic.gdx.physics.box2d.World;\r
+import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;\r
 import com.badlogic.gdx.physics.box2d.joints.MouseJoint;\r
 import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;\r
 \r
@@ -35,7 +35,7 @@ import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;
  * @author badlogicgames@gmail.com\r
  * \r
  */\r
-public abstract class Box2DTest implements RenderListener, InputListener {\r
+public abstract class Box2DTest implements ApplicationListener, InputProcessor {\r
        /** the camera **/\r
        protected OrthographicCamera camera;\r
 \r
@@ -69,15 +69,10 @@ public abstract class Box2DTest implements RenderListener, InputListener {
                camera.setMatrices();\r
 \r
                // render the world using the debug renderer\r
-               renderer.render(world);\r
-       }\r
-\r
-       @Override public void surfaceChanged (int width, int height) {\r
-               // TODO Auto-generated method stub\r
-\r
+               renderer.render(world);                 \r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                // setup the camera. In Box2D we operate on a\r
                // meter scale, pixels won't do it. So we use\r
                // an orthographic camera with a viewport of\r
@@ -100,17 +95,11 @@ public abstract class Box2DTest implements RenderListener, InputListener {
                BodyDef bodyDef = new BodyDef();\r
                groundBody = world.createBody(bodyDef);\r
 \r
-               // finally we register ourself as an InputListener so we\r
-               // can manipulate our world\r
-               Gdx.input.addInputListener(this);\r
-\r
                // call abstract method to populate the world\r
                createWorld(world);\r
        }\r
 \r
-       @Override public void dispose () {\r
-               Gdx.input.removeInputListener(this);\r
-\r
+       @Override public void destroy () {              \r
                renderer.dispose();\r
                world.dispose();\r
 \r
@@ -201,4 +190,12 @@ public abstract class Box2DTest implements RenderListener, InputListener {
                }\r
                return false;\r
        }\r
+       \r
+       public void pause() {\r
+               \r
+       }\r
+       \r
+       public void resume() {\r
+               \r
+       }\r
 }\r
index 27384ea..76c6685 100644 (file)
@@ -1,9 +1,13 @@
 package com.badlogic.gdx.tests.utils;\r
 \r
-import com.badlogic.gdx.RenderListener;\r
-import com.badlogic.gdx.utils.GdxRuntimeException;\r
+import com.badlogic.gdx.ApplicationListener;\r
 \r
-public interface GdxTest extends RenderListener\r
+public abstract class GdxTest implements ApplicationListener\r
 {\r
-       public boolean needsGL20( );    \r
+       public abstract boolean needsGL20( );   \r
+       public void create( ) { };\r
+       public void resume( ) { };\r
+       public void render( ) { };\r
+       public void pause( ) { };\r
+       public void destroy( ) { };\r
 }\r