- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
-
- "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.
-
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
-
- "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.
-
-
- "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).
-
-
- "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.
-
-
- "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."
-
-
- "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.
-
-
2. Grant of Copyright License.
-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.
-
-
3. Grant of Patent License.
-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.
-
-
4. Redistribution.
-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:
-
-
You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
-
-
You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
-
-
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
-
-
-
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.
-
- 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.
-
-
5. Submission of Contributions.
-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.
-
-
6. Trademarks.
-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.
-
-
7. Disclaimer of Warranty.
-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.
-
-
8. Limitation of Liability.
-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.
-
-
9. Accepting Warranty or Additional Liability.
-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.
-
-
-END OF TERMS AND CONDITIONS
-
-
\ 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
index c8fedaffa..000000000
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglApplication.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx.backends.desktop;
-
-import com.badlogic.gdx.Application;
-import com.badlogic.gdx.ApplicationListener;
-import com.badlogic.gdx.Audio;
-import com.badlogic.gdx.Files;
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.Graphics;
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
-import com.badlogic.gdx.Version;
-import com.badlogic.gdx.graphics.GL10;
-import com.badlogic.gdx.graphics.GL11;
-
-/**
- * An implemenation of the {@link Application} interface based on Jogl for Windows, Linux and Mac. Instantiate this class with
- * apropriate parameters and then register {@link ApplicationListener}, {@link RenderListener} or {@link InputListener} instances.
- *
- * @author mzechner
- *
- */
-public final class JoglApplication implements Application {
- static {
- Version.loadLibrary();
- }
-
- /** the graphics instance **/
- private final JoglGraphics graphics;
-
- /** the input instance **/
- private final JoglInput input;
-
- /** the audio instance **/
- private final JoglAudio audio;
-
- /** the DestroyListener **/
- ApplicationListener listener;
-
- /**
- * Creates a new {@link JoglApplication} with the given title and dimensions. If useGL20IfAvailable is set the JoglApplication
- * will try to create an OpenGL 2.0 context which can then be used via {@link JoglApplication.getGraphics().getGL20()}. The
- * {@link GL10} and {@link GL11} interfaces should not be used when OpenGL 2.0 is enabled. To query whether enabling OpenGL 2.0
- * was successful use the {@link JoglApplication.getGraphics().isGL20Available()} method.
- *
- * @param title the title of the application
- * @param width the width of the surface in pixels
- * @param height the height of the surface in pixels
- * @param useGL20IfAvailable wheter to use OpenGL 2.0 if it is available or not
- */
- public JoglApplication (String title, int width, int height, boolean useGL20IfAvailable) {
- graphics = new JoglGraphics(this, title, width, height, useGL20IfAvailable);
- input = new JoglInput(graphics.graphicPanel);
- audio = new JoglAudio();
-
- Gdx.app = this;
- Gdx.graphics = this.getGraphics();
- Gdx.input = this.getInput();
- Gdx.audio = this.getAudio();
- Gdx.files = this.getFiles();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public Audio getAudio () {
- return audio;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public Files getFiles () {
- return new JoglFiles();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public Graphics getGraphics () {
- return graphics;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public Input getInput () {
- return input;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public void setApplicationListener (ApplicationListener listener) {
- this.listener = listener;
- }
-
- @Override public void log (String tag, String message) {
- System.out.println(tag + ": " + message);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public ApplicationType getType () {
- return ApplicationType.Desktop;
- }
-
- @Override public int getVersion () {
- return 0;
- }
-
-}
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
index 430cb4ed9..000000000
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGraphics.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx.backends.desktop;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.image.BufferedImage;
-import java.io.InputStream;
-
-import javax.imageio.ImageIO;
-import javax.media.opengl.GL;
-import javax.swing.JFrame;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.Graphics;
-import com.badlogic.gdx.RenderListener;
-import com.badlogic.gdx.files.FileHandle;
-import com.badlogic.gdx.graphics.GL10;
-import com.badlogic.gdx.graphics.GL11;
-import com.badlogic.gdx.graphics.GL20;
-import com.badlogic.gdx.graphics.GLCommon;
-import com.badlogic.gdx.graphics.Pixmap;
-import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.Pixmap.Format;
-import com.badlogic.gdx.graphics.Texture.TextureFilter;
-import com.badlogic.gdx.graphics.Texture.TextureWrap;
-import com.badlogic.gdx.math.WindowedMean;
-import com.badlogic.gdx.utils.GdxRuntimeException;
-
-/**
- * An implementation of the {@link Graphics} interface based on Jogl.
- * @author mzechner
- *
- */
-public final class JoglGraphics implements Graphics, RenderListener {
- /** the jframe **/
- private final JFrame frame;
-
- /** the graphic panel **/
- protected final JoglPanel graphicPanel;
-
- /** the render listener **/
- private RenderListener listener;
-
- /** Common instance **/
- private GLCommon gl;
-
- /** GL10 instance **/
- private GL10 gl10;
-
- /** GL11 instance **/
- private GL11 gl11;
-
- /** GL20 instance **/
- private GL20 gl20;
-
- /** wheter to use opengl 2 **/
- private final boolean useGL2;
-
- /** the last frame time **/
- private long lastFrameTime = System.nanoTime();
-
- /** the deltaTime **/
- private float deltaTime = 0;
-
- /** frame start time **/
- private long frameStart = System.nanoTime();
-
- /** frame counter **/
- private int frames = 0;
-
- /** last fps **/
- private int fps;
-
- /** the deltaTime mean **/
- private WindowedMean mean = new WindowedMean(5);
-
- JoglGraphics (final JoglApplication application, String title, int width, int height, boolean useGL2IfAvailable) {
- frame = new JFrame(title);
- graphicPanel = new JoglPanel(application);
- graphicPanel.setPreferredSize(new Dimension(width, height));
- frame.setSize(width + frame.getInsets().left + frame.getInsets().right, frame.getInsets().top + frame.getInsets().bottom
- + height);
- frame.add(graphicPanel, BorderLayout.CENTER);
- frame.pack();
- frame.setVisible(true);
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing (WindowEvent e) {
- if (application.listener != null) application.listener.pause();
- graphicPanel.dispose();
- if (application.listener != null) application.listener.destroy();
- }
- });
- useGL2 = useGL2IfAvailable;
- graphicPanel.addGraphicListener(this);
- graphicPanel.requestFocusInWindow();
- }
-
- @Override public GL10 getGL10 () {
- return gl10;
- }
-
- @Override public GL11 getGL11 () {
- return gl11;
- }
-
- @Override public GL20 getGL20 () {
- return gl20;
- }
-
- @Override public int getHeight () {
- return graphicPanel.getHeight();
- }
-
- @Override public int getWidth () {
- return graphicPanel.getWidth();
- }
-
- @Override public boolean isGL11Available () {
- return gl11 != null;
- }
-
- @Override public boolean isGL20Available () {
- return gl20 != null;
- }
-
- @Override public Pixmap newPixmap (int width, int height, Format format) {
- return new JoglPixmap(width, height, format);
- }
-
- @Override public Pixmap newPixmap (InputStream in) {
- try {
- BufferedImage img = (BufferedImage)ImageIO.read(in);
- return new JoglPixmap(img);
- } catch (Exception ex) {
- throw new GdxRuntimeException("Couldn't load Pixmap from InputStream", ex);
- }
- }
-
- @Override public Pixmap newPixmap (FileHandle file) {
- return newPixmap(file.getInputStream());
- }
-
- @Override public Pixmap newPixmap (Object nativePixmap) {
- return new JoglPixmap((BufferedImage)nativePixmap);
- }
-
- private static boolean isPowerOfTwo (int value) {
- return ((value != 0) && (value & (value - 1)) == 0);
- }
-
- @Override public Texture newUnmanagedTexture (int width, int height, Pixmap.Format format, TextureFilter minFilter,
- TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {
- if (!isPowerOfTwo(width) || !isPowerOfTwo(height))
- throw new GdxRuntimeException("Texture dimensions must be a power of two");
-
- if (format == Format.Alpha)
- return new JoglTexture(width, height, BufferedImage.TYPE_BYTE_GRAY, minFilter, magFilter, uWrap, vWrap, false);
- else
- return new JoglTexture(width, height, BufferedImage.TYPE_4BYTE_ABGR, minFilter, magFilter, uWrap, vWrap, false);
- }
-
- @Override public Texture newUnmanagedTexture (Pixmap pixmap, TextureFilter minFilter, TextureFilter magFilter,
- TextureWrap uWrap, TextureWrap vWrap) {
- if (!isPowerOfTwo(pixmap.getHeight()) || !isPowerOfTwo(pixmap.getWidth()))
- throw new GdxRuntimeException("Texture dimensions must be a power of two");
-
- return new JoglTexture((BufferedImage)pixmap.getNativePixmap(), minFilter, magFilter, uWrap, vWrap, false);
- }
-
- @Override public Texture newTexture (FileHandle file, TextureFilter minFilter, TextureFilter magFilter, TextureWrap uWrap,
- TextureWrap vWrap) {
- Pixmap pixmap = newPixmap(file);
- if (!isPowerOfTwo(pixmap.getHeight()) || !isPowerOfTwo(pixmap.getWidth()))
- throw new GdxRuntimeException("Texture dimensions must be a power of two");
-
- return new JoglTexture((BufferedImage)pixmap.getNativePixmap(), minFilter, magFilter, uWrap, vWrap, false);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public void setRenderListener (RenderListener listener) {
- if (this.listener != null) graphicPanel.removeGraphicListener(this.listener);
- graphicPanel.addGraphicListener(listener);
- this.listener = listener;
- }
-
- @Override public void dispose () {
-
- }
-
- @Override public void render () {
- // calculate delta time
- deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;
- lastFrameTime = System.nanoTime();
- mean.addValue(deltaTime);
-
- if (System.nanoTime() - frameStart > 1000000000) {
- fps = frames;
- frames = 0;
- frameStart = System.nanoTime();
- }
- frames++;
- }
-
- @Override public void surfaceCreated () {
- String version = graphicPanel.getGL().glGetString(GL.GL_VERSION);
- int major = Integer.parseInt("" + version.charAt(0));
- int minor = Integer.parseInt("" + version.charAt(2));
-
- if (useGL2 && major >= 2) {
- // FIXME add check wheter gl 2.0 is supported
- gl20 = new JoglGL20(graphicPanel.getGL());
- gl = gl20;
- } else {
- if (major == 1 && minor < 5) {
- gl10 = new JoglGL10(graphicPanel.getGL());
- } else {
- gl11 = new JoglGL11(graphicPanel.getGL());
- gl10 = gl11;
- }
- gl = gl10;
- }
-
- Gdx.gl = gl;
- Gdx.gl10 = gl10;
- Gdx.gl11 = gl11;
- Gdx.gl20 = gl20;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public float getDeltaTime () {
- return mean.getMean() == 0 ? deltaTime : mean.getMean();
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public GraphicsType getType () {
- return GraphicsType.JoglGL;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override public int getFramesPerSecond () {
- return fps;
- }
-
- @Override public GLCommon getGLCommon () {
- return gl;
- }
-}
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
index 5068f73ca..000000000
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInput.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx.backends.desktop;
-
-import java.awt.event.MouseEvent;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
-
-/**
- * An implementation of the {@link Input} interface hooking a Jogl panel for input.
- *
- * @author mzechner
- *
- */
-final class JoglInput implements Input, RenderListener {
- /** the multiplexer **/
- private final JoglInputMultiplexer multiplexer;
-
- /** the graphics panel **/
- private final JoglPanel panel;
-
- /** user input **/
- private String text;
-
- /** user input listener **/
- private TextInputListener textListener;
-
- JoglInput (JoglPanel panel) {
- multiplexer = new JoglInputMultiplexer(panel.getCanvas());
- this.panel = panel;
- this.panel.addGraphicListener(this);
- }
-
- @Override public void addInputListener (InputListener listener) {
- multiplexer.addListener(listener);
- }
-
- @Override public float getAccelerometerX () {
- return 0;
- }
-
- @Override public float getAccelerometerY () {
- return 0;
- }
-
- @Override public float getAccelerometerZ () {
- return 0;
- }
-
- @Override public void getTextInput (final TextInputListener listener, final String title, final String text) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override public void run () {
- JoglInput.this.text = JOptionPane.showInputDialog(null, title, text);
- if (JoglInput.this.text != null) textListener = listener;
- }
- });
- }
-
- @Override public int getX () {
- return panel.getMouseX();
- }
-
- @Override public int getY () {
- return panel.getMouseY();
- }
-
- @Override public boolean isAccelerometerAvailable () {
- return false;
- }
-
- @Override public boolean isKeyPressed (int key) {
- return panel.isKeyDown(key);
- }
-
- @Override public boolean isTouched () {
- return panel.isButtonDown(MouseEvent.BUTTON1) || panel.isButtonDown(MouseEvent.BUTTON2)
- || panel.isButtonDown(MouseEvent.BUTTON3);
- }
-
- @Override public void removeInputListener (InputListener listener) {
- multiplexer.removeListener(listener);
- }
-
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void render () {
- multiplexer.processEvents();
-
- if (textListener != null) {
- textListener.input(text);
- textListener = null;
- }
- }
-
- @Override public void surfaceCreated () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public int getX (int pointer) {
- if (pointer > 0)
- return 0;
- else
- return getX();
- }
-
- @Override public int getY (int pointer) {
- if (pointer > 0)
- return 0;
- else
- return getY();
- }
-
- @Override public boolean isTouched (int pointer) {
- if (pointer > 0)
- return false;
- else
- return isTouched();
- }
-
- @Override public boolean supportsMultitouch () {
- return false;
- }
-
- @Override public void setOnscreenKeyboardVisible (boolean visible) {
-
- }
-
- @Override public boolean supportsOnscreenKeyboard () {
- return false;
- }
-
- @Override public void setCatchBackKey (boolean catchBack) {
-
- }
-}
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
index f45f174c3..000000000
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglInputMultiplexer.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx.backends.desktop;
-
-import java.awt.Component;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.awt.event.MouseWheelEvent;
-import java.awt.event.MouseWheelListener;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputListener;
-
-/**
- * Hooks a swing component and multiplexes any input events to all registered listeners in order. a listener can signal wheter he
- * has consumed the event therefor ending the multiplexing.
- *
- * @author badlogicgames@gmail.com
- *
- */
-final class JoglInputMultiplexer implements MouseListener, MouseMotionListener, MouseWheelListener, KeyListener {
- private enum EventType {
- MouseDown, MouseUp, MouseMoved, MouseDragged, KeyDown, KeyUp, KeyTyped
- }
-
- private class Event {
- public int x, y;
- public int keycode;
- public char keychar;
- public EventType type;
-
- public void set (EventType type, int x, int y, int keycode, char keychar) {
- this.type = type;
- this.x = x;
- this.y = y;
- this.keycode = keycode;
- this.keychar = keychar;
- }
- }
-
- private final ArrayList eventQueue = new ArrayList();
- private final ArrayList freeEvents = new ArrayList();
- private int freeEventIndex = 0;
-
- private final ArrayList listeners = new ArrayList();
- private final HashMap disabled = new HashMap();
- private Component component;
-
- /**
- * constructor, hooks the given component
- * @param component the component to hook
- */
- JoglInputMultiplexer (Component component) {
- hook(component);
- for (int i = 0; i < 1000; i++)
- freeEvents.add(new Event());
- }
-
- /**
- * adds callback hooks to the component. unhooks from the old component if any was set.
- *
- * @param component the component to hook
- */
- public void hook (Component component) {
- unhook();
- component.addMouseListener(this);
- component.addMouseMotionListener(this);
- component.addMouseWheelListener(this);
- component.addKeyListener(this);
- this.component = component;
- }
-
- /**
- * removes the callback hooks from the swing component
- */
- public void unhook () {
- if (component != null) {
- component.removeMouseListener(this);
- component.removeMouseMotionListener(this);
- component.removeMouseWheelListener(this);
- component.removeKeyListener(this);
- }
- }
-
- public void disableListener (InputListener listener) {
- disabled.put(listener, true);
- }
-
- public void enableListener (InputListener listener) {
- disabled.put(listener, false);
- }
-
- public void processEvents () {
- synchronized (eventQueue) {
- for (int i = 0; i < eventQueue.size(); i++) {
- Event event = eventQueue.get(i);
- if (event.type == EventType.MouseDown) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).touchDown(event.x, event.y, 0)) break;
- if (event.type == EventType.MouseUp) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).touchUp(event.x, event.y, 0)) break;
- if (event.type == EventType.MouseDragged) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).touchDragged(event.x, event.y, 0)) break;
- if (event.type == EventType.KeyDown) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).keyDown(event.keycode)) break;
- if (event.type == EventType.KeyUp) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).keyUp(event.keycode)) break;
- if (event.type == EventType.KeyTyped) for (int j = 0; j < listeners.size(); j++)
- if (listeners.get(j).keyTyped(event.keychar)) break;
- }
- eventQueue.clear();
- freeEventIndex = 0;
- }
- }
-
- /**
- * adds an {@link InputListener} to this multiplexer. The order in which listeners are added is the order in which they are
- * asked to consume events.
- *
- * @param listener the listener to add
- */
- public void addListener (InputListener listener) {
- synchronized (eventQueue) {
- if (!listeners.contains(listener)) {
- listeners.add(listener);
- disabled.put(listener, false);
- }
- }
- }
-
- public void removeListener (InputListener listener) {
- synchronized (eventQueue) {
- listeners.remove(listener);
- disabled.remove(listener);
- }
- }
-
- public void mouseClicked (MouseEvent e) {
-
- }
-
- public void mousePressed (MouseEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.MouseDown, e.getX(), e.getY(), 0, '\0');
- eventQueue.add(event);
- }
- }
-
- public void mouseReleased (MouseEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.MouseUp, e.getX(), e.getY(), 0, '\0');
- eventQueue.add(event);
- }
-
- }
-
- public void mouseDragged (MouseEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.MouseDragged, e.getX(), e.getY(), 0, '\0');
- eventQueue.add(event);
- }
- }
-
- public void mouseMoved (MouseEvent e) {
- }
-
- public void keyPressed (KeyEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.KeyDown, 0, 0, translateKeyCode(e.getKeyCode()), '\0');
- eventQueue.add(event);
- }
- }
-
- public void keyReleased (KeyEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.KeyUp, 0, 0, translateKeyCode(e.getKeyCode()), '\0');
- eventQueue.add(event);
- }
- }
-
- public void keyTyped (KeyEvent e) {
- synchronized (eventQueue) {
- Event event = freeEvents.get(freeEventIndex++);
- event.set(EventType.KeyTyped, 0, 0, translateKeyCode(e.getKeyCode()), e.getKeyChar());
- eventQueue.add(event);
- }
- }
-
- @Override public void mouseEntered (MouseEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void mouseExited (MouseEvent e) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void mouseWheelMoved (MouseWheelEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- protected static int translateKeyCode (int keyCode) {
- if (keyCode == KeyEvent.VK_0) return Input.Keys.KEYCODE_0;
- if (keyCode == KeyEvent.VK_1) return Input.Keys.KEYCODE_1;
- if (keyCode == KeyEvent.VK_2) return Input.Keys.KEYCODE_2;
- if (keyCode == KeyEvent.VK_3) return Input.Keys.KEYCODE_3;
- if (keyCode == KeyEvent.VK_4) return Input.Keys.KEYCODE_4;
- if (keyCode == KeyEvent.VK_5) return Input.Keys.KEYCODE_5;
- if (keyCode == KeyEvent.VK_6) return Input.Keys.KEYCODE_6;
- if (keyCode == KeyEvent.VK_7) return Input.Keys.KEYCODE_7;
- if (keyCode == KeyEvent.VK_8) return Input.Keys.KEYCODE_8;
- if (keyCode == KeyEvent.VK_9) return Input.Keys.KEYCODE_9;
- if (keyCode == KeyEvent.VK_A) return Input.Keys.KEYCODE_A;
- if (keyCode == KeyEvent.VK_B) return Input.Keys.KEYCODE_B;
- if (keyCode == KeyEvent.VK_C) return Input.Keys.KEYCODE_C;
- if (keyCode == KeyEvent.VK_D) return Input.Keys.KEYCODE_D;
- if (keyCode == KeyEvent.VK_E) return Input.Keys.KEYCODE_E;
- if (keyCode == KeyEvent.VK_F) return Input.Keys.KEYCODE_F;
- if (keyCode == KeyEvent.VK_G) return Input.Keys.KEYCODE_G;
- if (keyCode == KeyEvent.VK_H) return Input.Keys.KEYCODE_H;
- if (keyCode == KeyEvent.VK_I) return Input.Keys.KEYCODE_I;
- if (keyCode == KeyEvent.VK_J) return Input.Keys.KEYCODE_J;
- if (keyCode == KeyEvent.VK_K) return Input.Keys.KEYCODE_K;
- if (keyCode == KeyEvent.VK_L) return Input.Keys.KEYCODE_L;
- if (keyCode == KeyEvent.VK_M) return Input.Keys.KEYCODE_M;
- if (keyCode == KeyEvent.VK_N) return Input.Keys.KEYCODE_N;
- if (keyCode == KeyEvent.VK_O) return Input.Keys.KEYCODE_O;
- if (keyCode == KeyEvent.VK_P) return Input.Keys.KEYCODE_P;
- if (keyCode == KeyEvent.VK_Q) return Input.Keys.KEYCODE_Q;
- if (keyCode == KeyEvent.VK_R) return Input.Keys.KEYCODE_R;
- if (keyCode == KeyEvent.VK_S) return Input.Keys.KEYCODE_S;
- if (keyCode == KeyEvent.VK_T) return Input.Keys.KEYCODE_T;
- if (keyCode == KeyEvent.VK_U) return Input.Keys.KEYCODE_U;
- if (keyCode == KeyEvent.VK_V) return Input.Keys.KEYCODE_V;
- if (keyCode == KeyEvent.VK_W) return Input.Keys.KEYCODE_W;
- if (keyCode == KeyEvent.VK_X) return Input.Keys.KEYCODE_X;
- if (keyCode == KeyEvent.VK_Y) return Input.Keys.KEYCODE_Y;
- if (keyCode == KeyEvent.VK_Z) return Input.Keys.KEYCODE_Z;
- if (keyCode == KeyEvent.VK_ALT) return Input.Keys.KEYCODE_ALT_LEFT;
- if (keyCode == KeyEvent.VK_ALT_GRAPH) return Input.Keys.KEYCODE_ALT_RIGHT;
- if (keyCode == KeyEvent.VK_BACK_SLASH) return Input.Keys.KEYCODE_BACKSLASH;
- if (keyCode == KeyEvent.VK_COMMA) return Input.Keys.KEYCODE_COMMA;
- if (keyCode == KeyEvent.VK_DELETE) return Input.Keys.KEYCODE_DEL;
- if (keyCode == KeyEvent.VK_LEFT) return Input.Keys.KEYCODE_DPAD_LEFT;
- if (keyCode == KeyEvent.VK_RIGHT) return Input.Keys.KEYCODE_DPAD_RIGHT;
- if (keyCode == KeyEvent.VK_UP) return Input.Keys.KEYCODE_DPAD_UP;
- if (keyCode == KeyEvent.VK_DOWN) return Input.Keys.KEYCODE_DPAD_DOWN;
- if (keyCode == KeyEvent.VK_ENTER) return Input.Keys.KEYCODE_ENTER;
- if (keyCode == KeyEvent.VK_HOME) return Input.Keys.KEYCODE_HOME;
- if (keyCode == KeyEvent.VK_MINUS) return Input.Keys.KEYCODE_MINUS;
- if (keyCode == KeyEvent.VK_PERIOD) return Input.Keys.KEYCODE_PERIOD;
- if (keyCode == KeyEvent.VK_PLUS) return Input.Keys.KEYCODE_PLUS;
- if (keyCode == KeyEvent.VK_SEMICOLON) return Input.Keys.KEYCODE_SEMICOLON;
- if (keyCode == KeyEvent.VK_SHIFT) return Input.Keys.KEYCODE_SHIFT_LEFT;
- if (keyCode == KeyEvent.VK_SLASH) return Input.Keys.KEYCODE_SLASH;
- if (keyCode == KeyEvent.VK_SPACE) return Input.Keys.KEYCODE_SPACE;
- if (keyCode == KeyEvent.VK_TAB) return Input.Keys.KEYCODE_TAB;
-
- return Input.Keys.KEYCODE_UNKNOWN;
- }
-}
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
index b3a6d5c50..000000000
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPanel.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx.backends.desktop;
-
-import java.awt.BorderLayout;
-import java.awt.Point;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
-import java.io.BufferedOutputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GLAutoDrawable;
-import javax.media.opengl.GLCanvas;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLEventListener;
-import javax.swing.JPanel;
-
-import com.badlogic.gdx.Application;
-import com.badlogic.gdx.RenderListener;
-import com.badlogic.gdx.math.WindowedMean;
-import com.sun.opengl.impl.NativeLibLoader;
-import com.sun.opengl.util.Animator;
-
-/**
- * An OpenGL based graphics panel. Shares its context with all other GraphicPanels in the application. Has a continous render
- * thread constantly invoking the paint method. Note that you have to dispose the panel before it is being removed from another
- * gui component such as a JFrame.
- *
- * @author badlogicgames@gmail.com
- *
- */
-final class JoglPanel extends JPanel implements GLEventListener, MouseMotionListener, MouseListener, KeyListener {
- private static final long serialVersionUID = -3638194405409146221L;
-
- /** global flag used to check wheter the libraries are loaded already **/
- private static boolean loaded = false;
-
- /** the context to be used by all GraphicPanels **/
- private static GLContext context = null;
-
- /** the canvas object **/
- private final GLCanvas canvas;
-
- /** animator for continous updates **/
- private final Animator animator;
-
- /** vsynch flag **/
- private boolean vSynch = true;
-
- /** last mouse position **/
- private final Point mousePosition = new Point();
-
- /** last mouse button states **/
- private final HashSet buttons = new HashSet();
-
- /** last key states **/
- private final HashSet keys = new HashSet();
-
- /** listeners **/
- private final ArrayList listeners = new ArrayList();
-
- /** listeners **/
- private final ArrayList setupListeners = new ArrayList();
-
- /** start time of last frame **/
- private long frameStart = System.nanoTime();
-
- /** delta time between current and last frame **/
- private float deltaTime = 0;
- private WindowedMean mean = new WindowedMean(10);
-
- private JoglInputMultiplexer multiplexer;
-
- /**
- * loads the necessary libraries depending on the operating system
- */
- private static void loadLibraries () {
- if (loaded) return;
-
- NativeLibLoader.disableLoading();
- com.sun.gluegen.runtime.NativeLibLoader.disableLoading();
- // By wkien: On some systems (read: mine) jogl_awt would not find its dependency jawt if not loaded before
- System.loadLibrary("jawt");
- loadLibrary("gluegen-rt");
- loadLibrary("jogl_awt");
- loadLibrary("jogl");
-
- loaded = true;
- }
-
- /**
- * helper method to load a specific library in an operation system dependant manner
- * @param resource the name of the resource
- */
- private static void loadLibrary (String resource) {
- String package_path = "/javax/media/";
- String library = "";
-
- String os = System.getProperty("os.name");
- String arch = System.getProperty("os.arch");
-
- if (os.contains("Windows")) {
- if (!arch.equals("amd64"))
- library = resource + "-win32.dll";
- else {
- library = resource + "-win64.dll";
- }
- }
-
- if (os.contains("Linux")) {
- if (!arch.equals("amd64"))
- library = "lib" + resource + "-linux32.so";
- else
- library = "lib" + resource + "-linux64.so";
- }
-
- if (os.contains("Mac")) {
- library = "lib" + resource + ".jnilib";
- }
-
- String so = System.getProperty("java.io.tmpdir") + "/" + System.nanoTime() + library;
- InputStream in = JoglPanel.class.getResourceAsStream(package_path + library);
- if (in == null) throw new RuntimeException("couldn't find " + library + " in jar file.");
-
- try {
- BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(so));
- byte[] bytes = new byte[1024 * 4];
- while (true) {
- int read_bytes = in.read(bytes);
- if (read_bytes == -1) break;
-
- out.write(bytes, 0, read_bytes);
- }
- out.close();
- in.close();
- System.load(so);
- } catch (FileNotFoundException e) {
- throw new RuntimeException("couldn't write " + library + " to temporary file " + so);
- } catch (IOException e) {
- throw new RuntimeException("couldn't write " + library + " to temporary file " + so);
- }
- }
-
- /**
- * Constructor loading the libraries if needed and creating/reusing a {@link GLContext}. A standard back/depth/stencil buffer
- * combination is created (32-bit, 16-bit, 8-bit). Additionally an animator thread is created that is responsible for redrawing
- * the panel as fast as possible in case the continous flag is set to true. Keyboard and Mouse events are processed by the
- * panel so that a client can poll for specific states.
- */
- JoglPanel (Application application) {
- super();
- loadLibraries();
-
- GLCapabilities caps = new GLCapabilities();
- caps.setRedBits(8);
- caps.setGreenBits(8);
- caps.setBlueBits(8);
- caps.setAlphaBits(8);
- caps.setDepthBits(16);
- caps.setStencilBits(8);
- caps.setNumSamples(0);
- caps.setSampleBuffers(false);
- caps.setDoubleBuffered(true);
-
- if (context == null) {
- canvas = new GLCanvas(caps);
- context = canvas.getContext();
- } else
- canvas = new GLCanvas(caps, null, context, null);
-
- canvas.addGLEventListener(this);
- this.setLayout(new BorderLayout());
- add(canvas, BorderLayout.CENTER);
-
- animator = new Animator(canvas);
- animator.setRunAsFastAsPossible(true);
- animator.start();
-
- canvas.addMouseListener(this);
- canvas.addMouseMotionListener(this);
- canvas.addKeyListener(this);
- }
-
- /**
- * stops the animator thread and releases any resources
- */
- public void dispose () {
- if (animator != null) animator.stop();
- canvas.getContext().makeCurrent();
- for (RenderListener listener : listeners)
- listener.dispose();
- remove(canvas);
- }
-
- /**
- * @return the delta time between the current and last frame
- */
- public float getDeltaTime () {
- return mean.hasEnoughData() ? mean.getMean() : deltaTime;
- }
-
- /**
- * @return the underlying GLCanvas
- */
- public GLCanvas getCanvas () {
- return canvas;
- }
-
- /**
- * sets wheter vsynch is enabled or disabled. true by default.
- *
- * @param v_synch
- */
- public void setVerticalSynch (boolean v_synch) {
- this.vSynch = v_synch;
- if (v_synch)
- GLContext.getCurrent().getGL().setSwapInterval(1);
- else
- GLContext.getCurrent().getGL().setSwapInterval(0);
- }
-
- /**
- * @return wheter vsynch is on or not
- */
- public boolean getVerticalSynch () {
- return vSynch;
- }
-
- public void mouseDragged (MouseEvent arg0) {
- mousePosition.x = arg0.getX();
- mousePosition.y = arg0.getY();
-
- }
-
- public void mouseMoved (MouseEvent arg0) {
- mousePosition.x = arg0.getX();
- mousePosition.y = arg0.getY();
- }
-
- public int getMouseX () {
- return mousePosition.x;
- }
-
- public int getMouseY () {
- return mousePosition.y;
- }
-
- public void mouseClicked (MouseEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- public void mouseEntered (MouseEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- public void mouseExited (MouseEvent arg0) {
- // TODO Auto-generated method stub
-
- }
-
- public void mousePressed (MouseEvent arg0) {
- buttons.add(arg0.getButton());
- }
-
- public void mouseReleased (MouseEvent arg0) {
- buttons.remove(arg0.getButton());
- }
-
- public void keyPressed (KeyEvent arg0) {
- keys.add(JoglInputMultiplexer.translateKeyCode(arg0.getKeyCode()));
- }
-
- public void keyReleased (KeyEvent arg0) {
-// getCanvas().getContext().makeCurrent();
- keys.remove(JoglInputMultiplexer.translateKeyCode(arg0.getKeyCode()));
- }
-
- public void keyTyped (KeyEvent arg0) {
-
- }
-
- /**
- * returns wheter the given mousebutton is down. use the constants in {@link MouseEvent}.
- *
- * @param button the button in question
- * @return wheter the button is down or not
- */
- public boolean isButtonDown (int button) {
- return buttons.size() > 0;
- }
-
- /**
- * returns wheter the given key is down. use the constants in {@link KeyEvent}.
- *
- * @param key the key in question
- * @return wheter the key is down or not
- */
- public boolean isKeyDown (int key) {
- return keys.contains(key);
- }
-
- /**
- * adds a new graphic listener
- * @param listener the listener
- */
- public void addGraphicListener (RenderListener listener) {
- synchronized (this) {
- setupListeners.add(listener);
- }
- }
-
- /**
- * removes a graphic listener
- * @param listener the listener
- */
- public void removeGraphicListener (RenderListener listener) {
- synchronized (this) {
- setupListeners.remove(listener);
- listeners.remove(listener);
- listener.dispose();
- }
- }
-
- @Override public void display (GLAutoDrawable arg0) {
- if (multiplexer != null) multiplexer.processEvents();
- deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;
- frameStart = System.nanoTime();
- mean.addValue(deltaTime);
-
- synchronized (this) {
- for (RenderListener listener : setupListeners) {
- listener.surfaceCreated();
- listener.surfaceChanged(this.getWidth(), this.getHeight());
- }
- listeners.addAll(setupListeners);
- setupListeners.clear();
-
- for (RenderListener listener : listeners)
- listener.render();
- }
-
- }
-
- @Override public void displayChanged (GLAutoDrawable arg0, boolean arg1, boolean arg2) {
- deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;
- frameStart = System.nanoTime();
-
- for (RenderListener listener : listeners)
- listener.render();
- }
-
- @Override public void init (GLAutoDrawable arg0) {
- for (RenderListener listener : listeners)
- listener.surfaceCreated();
- setVerticalSynch(true);
- }
-
- @Override public void reshape (GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) {
- deltaTime = (System.nanoTime() - frameStart) / 1000000000.0f;
- frameStart = System.nanoTime();
-
- for (RenderListener listener : listeners) {
- listener.surfaceChanged(this.getWidth(), this.getHeight());
- listener.render();
- }
- }
-
- /**
- * @return the gl context this panel works on
- */
- public GL getGL () {
- return canvas.getGL();
- }
-
- public Point getLastMousePosition () {
- return mousePosition;
- }
-
- public void setInputMultiplexer (JoglInputMultiplexer inputMultiplexer) {
- multiplexer = inputMultiplexer;
- }
-
- public boolean isAnyKeyDown () {
- return keys.size() > 0;
- }
-}
diff --git a/backends/gdx-backend-desktop/.classpath b/backends/gdx-backend-jogl/.classpath
similarity index 92%
rename from backends/gdx-backend-desktop/.classpath
rename to backends/gdx-backend-jogl/.classpath
index bf21c6a13..c242aa380 100644
--- a/backends/gdx-backend-desktop/.classpath
+++ b/backends/gdx-backend-jogl/.classpath
@@ -1,14 +1,14 @@
-
+
-
+
+
-
diff --git a/tests/gdx-tests-desktop/.project b/backends/gdx-backend-jogl/.project
similarity index 87%
rename from tests/gdx-tests-desktop/.project
rename to backends/gdx-backend-jogl/.project
index 4a765a044..26d4f95ef 100644
--- a/tests/gdx-tests-desktop/.project
+++ b/backends/gdx-backend-jogl/.project
@@ -1,6 +1,6 @@
- gdx-tests-desktop
+ gdx-backend-jogl
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
index 000000000..67539e7f4
--- /dev/null
+++ b/backends/gdx-backend-jogl/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Nov 01 14:12:24 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
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
index 000000000..cd980812f
--- /dev/null
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglApplication.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
+ * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ ******************************************************************************/
+
+package com.badlogic.gdx.backends.jogl;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JFrame;
+
+import com.badlogic.gdx.Application;
+import com.badlogic.gdx.ApplicationListener;
+import com.badlogic.gdx.Audio;
+import com.badlogic.gdx.Files;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Graphics;
+import com.badlogic.gdx.Input;
+import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.Version;
+
+/**
+ * An implemenation of the {@link Application} interface based on Jogl for Windows, Linux and Mac. Instantiate this class with
+ * apropriate parameters and then register {@link ApplicationListener}, {@link RenderListener} or {@link InputProcessor} instances.
+ *
+ * @author mzechner
+ *
+ */
+public final class JoglApplication implements Application {
+ static {
+ Version.loadLibrary();
+ }
+
+ final JoglGraphics graphics;
+ final JoglInput input;
+ final JoglFiles files;
+ final JoglAudio audio;
+ JFrame frame;
+
+
+ /**
+ * Creates a new {@link JoglApplication} with the given title and dimensions. If useGL20IfAvailable is set the JoglApplication
+ * 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
+ * was successful use the {@link JoglApplication.getGraphics().isGL20Available()} method.
+ *
+ * @param listener the ApplicationListener implementing the program logic
+ * @param title the title of the application
+ * @param width the width of the surface in pixels
+ * @param height the height of the surface in pixels
+ * @param useGL20IfAvailable wheter to use OpenGL 2.0 if it is available or not
+ */
+ public JoglApplication (ApplicationListener listener, String title, int width, int height, boolean useGL20IfAvailable) {
+ graphics = new JoglGraphics(listener, title, width, height, useGL20IfAvailable);
+ input = new JoglInput(graphics.getCanvas());
+ audio = new JoglAudio();
+ files = new JoglFiles();
+
+ Gdx.app = this;
+ Gdx.graphics = this.getGraphics();
+ Gdx.input = this.getInput();
+ Gdx.audio = this.getAudio();
+ Gdx.files = this.getFiles();
+
+ initialize(title, width, height);
+ }
+
+ private void initialize(String title, int width, int height) {
+ graphics.getCanvas().setPreferredSize(new Dimension(width, height));
+
+ frame = new JFrame(title);
+ frame.setSize(width + frame.getInsets().left + frame.getInsets().right, frame.getInsets().top + frame.getInsets().bottom
+ + height);
+ frame.add(graphics.getCanvas(), BorderLayout.CENTER);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ frame.setLocationRelativeTo(null);
+
+ frame.addWindowListener( new WindowAdapter() {
+ @Override
+ public void windowOpened(WindowEvent arg0) {
+ graphics.getCanvas().requestFocus();
+ graphics.getCanvas().requestFocusInWindow();
+ }
+
+ @Override
+ public void windowIconified(WindowEvent arg0) {
+ graphics.pause();
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent arg0) {
+ graphics.resume();
+ }
+
+ @Override
+ public void windowClosing(WindowEvent arg0) {
+ graphics.pause();
+ graphics.destroy();
+ frame.remove(graphics.getCanvas());
+ }
+ });
+
+ frame.pack();
+ frame.setVisible(true);
+ graphics.create();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Audio getAudio () {
+ return audio;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Files getFiles () {
+ return files;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Graphics getGraphics () {
+ return graphics;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public Input getInput () {
+ return input;
+ }
+
+ @Override public void log (String tag, String message) {
+ System.out.println(tag + ": " + message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override public ApplicationType getType () {
+ return ApplicationType.Desktop;
+ }
+
+ @Override public int getVersion () {
+ return 0;
+ }
+
+ public static void main(String[] argv) {
+ ApplicationListener listener = new ApplicationListener() {
+
+ @Override
+ public void resume() {
+ System.out.println("resumed");
+ }
+
+ @Override
+ public void render() {
+ System.out.println("render");
+ }
+
+ @Override
+ public void pause() {
+ System.out.println("paused");
+ }
+
+ @Override
+ public void destroy() {
+ System.out.println("destroy");
+ }
+
+ @Override
+ public void create() {
+ System.out.println("created");
+ }
+ };
+
+ new JoglApplication(listener, "Jogl Application Test", 480, 320, false);
+ }
+}
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudio.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudio.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudio.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudio.java
index a726ca4bb..1a3279500 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudio.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudio.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.util.ArrayList;
import java.util.Iterator;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioDevice.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioDevice.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioDevice.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioDevice.java
index ac73730bb..3bbfc5435 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioDevice.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioDevice.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioRecorder.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioRecorder.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioRecorder.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioRecorder.java
index 999af695e..b5cba93d2 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglAudioRecorder.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglAudioRecorder.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFileHandle.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFileHandle.java
similarity index 94%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFileHandle.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFileHandle.java
index 93e7619c8..ebd7ea9cd 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFileHandle.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFileHandle.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.io.File;
import java.io.FileInputStream;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFiles.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFiles.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFiles.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFiles.java
index acfa89299..6f007e39e 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglFiles.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglFiles.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.io.File;
import java.io.FileInputStream;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL10.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL10.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL10.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL10.java
index b43002ad3..14e9743b4 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL10.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL10.java
@@ -11,11 +11,9 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL11.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL11.java
similarity index 96%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL11.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL11.java
index b8435ac4b..3fd80b0d4 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL11.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL11.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.nio.Buffer;
import java.nio.FloatBuffer;
@@ -19,7 +19,6 @@ import java.nio.IntBuffer;
import javax.media.opengl.GL;
-import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GL11;
/**
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL20.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL20.java
similarity index 96%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL20.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL20.java
index 80d51a2fb..08054276b 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglGL20.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGL20.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.nio.Buffer;
import java.nio.ByteBuffer;
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
index 000000000..50418f7b8
--- /dev/null
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphics.java
@@ -0,0 +1,84 @@
+package com.badlogic.gdx.backends.jogl;
+
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLEventListener;
+
+import com.badlogic.gdx.ApplicationListener;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Graphics;
+import com.badlogic.gdx.utils.GdxRuntimeException;
+
+/**
+ * Implements the {@link Graphics} interface with Jogl.
+ *
+ * @author mzechner
+ *
+ */
+public class JoglGraphics extends JoglGraphicsBase implements GLEventListener {
+ ApplicationListener listener = null;
+ boolean useGL2;
+ boolean created = false;
+
+ public JoglGraphics(ApplicationListener listener, String title, int width, int height, boolean useGL2) {
+ initialize(title, width, height, useGL2);
+ if(listener==null) throw new GdxRuntimeException("RenderListener must not be null");
+ this.listener = listener;
+ }
+
+ public void create () {
+ super.create();
+ }
+
+ public void pause () {
+ super.pause();
+ canvas.getContext().makeCurrent();
+ listener.pause();
+ }
+
+ public void resume () {
+ canvas.getContext().makeCurrent();
+ listener.resume();
+ super.resume();
+ }
+
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ initializeGLInstances(drawable);
+
+ if( !created ) {
+ listener.create();
+ synchronized (this) {
+ paused = false;
+ }
+ created = true;
+ }
+ }
+
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width,
+ int height) {
+ }
+
+ @Override
+ public void display(GLAutoDrawable arg0) {
+ synchronized (this) {
+ if (!paused) {
+ updateTimes();
+ listener.render();
+ }
+ }
+
+ Gdx.input.processEvents(null);
+ }
+
+ @Override
+ public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {
+
+ }
+
+ public void destroy() {
+ canvas.getContext().makeCurrent();
+ listener.destroy();
+ }
+}
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
index 000000000..303dcb110
--- /dev/null
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglGraphicsBase.java
@@ -0,0 +1,261 @@
+package com.badlogic.gdx.backends.jogl;
+
+import java.awt.image.BufferedImage;
+import java.io.InputStream;
+
+import javax.imageio.ImageIO;
+import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCanvas;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Graphics;
+import com.badlogic.gdx.files.FileHandle;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.GL11;
+import com.badlogic.gdx.graphics.GL20;
+import com.badlogic.gdx.graphics.GLCommon;
+import com.badlogic.gdx.graphics.Pixmap;
+import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.Pixmap.Format;
+import com.badlogic.gdx.graphics.Texture.TextureFilter;
+import com.badlogic.gdx.graphics.Texture.TextureWrap;
+import com.badlogic.gdx.math.WindowedMean;
+import com.badlogic.gdx.utils.GdxRuntimeException;
+import com.sun.opengl.util.Animator;
+
+public abstract class JoglGraphicsBase implements Graphics, GLEventListener {
+ GLCanvas canvas;
+ Animator animator;
+ boolean useGL2;
+ long frameStart = System.nanoTime();
+ long lastFrameTime = System.nanoTime();
+ float deltaTime = 0;
+ WindowedMean mean = new WindowedMean(10);
+ int fps;
+ int frames;
+ boolean paused = true;
+
+ GLCommon gl;
+ GL10 gl10;
+ GL11 gl11;
+ GL20 gl20;
+
+ void initialize(String title, int width, int height, boolean useGL2) {
+ JoglNativesLoader.loadLibraries();
+
+ GLCapabilities caps = new GLCapabilities();
+ caps.setRedBits(8);
+ caps.setGreenBits(8);
+ caps.setBlueBits(8);
+ caps.setAlphaBits(8);
+ caps.setDepthBits(16);
+ caps.setStencilBits(8);
+ caps.setNumSamples(0);
+ caps.setSampleBuffers(false);
+ caps.setDoubleBuffered(true);
+
+ canvas = new GLCanvas(caps);
+
+ canvas.addGLEventListener(this);
+ this.useGL2 = useGL2;
+ }
+
+ GLCanvas getCanvas() {
+ return canvas;
+ }
+
+ void create() {
+ frameStart = System.nanoTime();
+ lastFrameTime = frameStart;
+ deltaTime = 0;
+ mean.clear();
+ animator = new Animator(canvas);
+ animator.setRunAsFastAsPossible(true);
+ animator.start();
+ }
+
+ void pause() {
+ synchronized (this) {
+ paused = true;
+ }
+ animator.stop();
+ }
+
+ void resume() {
+ paused = false;
+ frameStart = System.nanoTime();
+ lastFrameTime = frameStart;
+ deltaTime = 0;
+ mean.clear();
+ animator = new Animator(canvas);
+ animator.setRunAsFastAsPossible(true);
+ animator.start();
+ }
+
+ void initializeGLInstances (GLAutoDrawable drawable) {
+ String version = drawable.getGL().glGetString(GL.GL_VERSION);
+ int major = Integer.parseInt("" + version.charAt(0));
+ int minor = Integer.parseInt("" + version.charAt(2));
+
+ if (useGL2 && major >= 2) {
+ gl20 = new JoglGL20(drawable.getGL());
+ gl = gl20;
+ } else {
+ if (major == 1 && minor < 5) {
+ gl10 = new JoglGL10(drawable.getGL());
+ } else {
+ gl11 = new JoglGL11(drawable.getGL());
+ gl10 = gl11;
+ }
+ gl = gl10;
+ }
+
+ Gdx.gl = gl;
+ Gdx.gl10 = gl10;
+ Gdx.gl11 = gl11;
+ Gdx.gl20 = gl20;
+ }
+
+ void updateTimes () {
+ deltaTime = (System.nanoTime() - lastFrameTime) / 1000000000.0f;
+ lastFrameTime = System.nanoTime();
+ mean.addValue(deltaTime);
+
+ if (System.nanoTime() - frameStart > 1000000000) {
+ fps = frames;
+ frames = 0;
+ frameStart = System.nanoTime();
+ }
+ frames++;
+ }
+
+ @Override
+ public float getDeltaTime() {
+ return mean.getMean() == 0 ? deltaTime : mean.getMean();
+ }
+
+ @Override
+ public int getFramesPerSecond() {
+ return fps;
+ }
+
+ @Override
+ public int getHeight() {
+ return canvas.getHeight();
+ }
+
+ @Override
+ public int getWidth() {
+ return canvas.getWidth();
+ }
+
+ @Override
+ public GL10 getGL10() {
+ return gl10;
+ }
+
+ @Override
+ public GL11 getGL11() {
+ return gl11;
+ }
+
+ @Override
+ public GL20 getGL20() {
+ return gl20;
+ }
+
+ @Override
+ public GLCommon getGLCommon() {
+ return gl;
+ }
+
+ @Override
+ public boolean isGL11Available() {
+ return gl11 != null;
+ }
+
+ @Override
+ public boolean isGL20Available() {
+ return gl20 != null;
+ }
+
+ @Override
+ public GraphicsType getType() {
+ return GraphicsType.JoglGL;
+ }
+
+ @Override
+ public Pixmap newPixmap(int width, int height, Format format) {
+ return new JoglPixmap(width, height, format);
+ }
+
+ @Override
+ public Pixmap newPixmap(InputStream in) {
+ try {
+ BufferedImage img = (BufferedImage) ImageIO.read(in);
+ return new JoglPixmap(img);
+ } catch (Exception ex) {
+ throw new GdxRuntimeException(
+ "Couldn't load Pixmap from InputStream", ex);
+ }
+ }
+
+ @Override
+ public Pixmap newPixmap(FileHandle file) {
+ return newPixmap(file.getInputStream());
+ }
+
+ @Override
+ public Pixmap newPixmap(Object nativePixmap) {
+ return new JoglPixmap((BufferedImage) nativePixmap);
+ }
+
+ private static boolean isPowerOfTwo(int value) {
+ return ((value != 0) && (value & (value - 1)) == 0);
+ }
+
+ @Override
+ public Texture newUnmanagedTexture(int width, int height,
+ Pixmap.Format format, TextureFilter minFilter,
+ TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {
+ if (!isPowerOfTwo(width) || !isPowerOfTwo(height))
+ throw new GdxRuntimeException(
+ "Texture dimensions must be a power of two");
+
+ if (format == Format.Alpha)
+ return new JoglTexture(width, height, BufferedImage.TYPE_BYTE_GRAY,
+ minFilter, magFilter, uWrap, vWrap, false);
+ else
+ return new JoglTexture(width, height,
+ BufferedImage.TYPE_4BYTE_ABGR, minFilter, magFilter, uWrap,
+ vWrap, false);
+ }
+
+ @Override
+ public Texture newUnmanagedTexture(Pixmap pixmap, TextureFilter minFilter,
+ TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {
+ if (!isPowerOfTwo(pixmap.getHeight())
+ || !isPowerOfTwo(pixmap.getWidth()))
+ throw new GdxRuntimeException(
+ "Texture dimensions must be a power of two");
+
+ return new JoglTexture((BufferedImage) pixmap.getNativePixmap(),
+ minFilter, magFilter, uWrap, vWrap, false);
+ }
+
+ @Override
+ public Texture newTexture(FileHandle file, TextureFilter minFilter,
+ TextureFilter magFilter, TextureWrap uWrap, TextureWrap vWrap) {
+ Pixmap pixmap = newPixmap(file);
+ if (!isPowerOfTwo(pixmap.getHeight())
+ || !isPowerOfTwo(pixmap.getWidth()))
+ throw new GdxRuntimeException(
+ "Texture dimensions must be a power of two");
+
+ return new JoglTexture((BufferedImage) pixmap.getNativePixmap(),
+ minFilter, magFilter, uWrap, vWrap, false);
+ }
+}
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
index 000000000..bcf8e1881
--- /dev/null
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglInput.java
@@ -0,0 +1,377 @@
+package com.badlogic.gdx.backends.jogl;
+
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.media.opengl.GLCanvas;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import com.badlogic.gdx.Input;
+import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.utils.Pool;
+import com.badlogic.gdx.utils.Pool.PoolObjectFactory;
+
+public class JoglInput implements Input, MouseMotionListener, MouseListener,
+ KeyListener {
+ class KeyEvent {
+ static final int KEY_DOWN = 0;
+ static final int KEY_UP = 1;
+ static final int KEY_TYPED = 2;
+
+ int type;
+ int keyCode;
+ char keyChar;
+ }
+
+ class TouchEvent {
+ static final int TOUCH_DOWN = 0;
+ static final int TOUCH_UP = 1;
+ static final int TOUCH_DRAGGED = 2;
+
+ int type;
+ int x;
+ int y;
+ int pointer;
+ }
+
+ Pool freeKeyEvents = new Pool(
+ new PoolObjectFactory() {
+
+ @Override
+ public KeyEvent createObject() {
+ return new KeyEvent();
+ }
+ }, 1000);
+
+ Pool freeTouchEvents = new Pool(
+ new PoolObjectFactory() {
+
+ @Override
+ public TouchEvent createObject() {
+ return new TouchEvent();
+ }
+ }, 1000);
+
+ List keyEvents = new ArrayList();
+ List touchEvents = new ArrayList();
+ int touchX = 0;
+ int touchY = 0;
+ boolean touchDown = false;
+ Set keys = new HashSet();
+
+ public JoglInput(GLCanvas canvas) {
+ canvas.addMouseListener(this);
+ canvas.addMouseMotionListener(this);
+ canvas.addKeyListener(this);
+ }
+
+ @Override
+ public float getAccelerometerX() {
+ return 0;
+ }
+
+ @Override
+ public float getAccelerometerY() {
+ return 0;
+ }
+
+ @Override
+ public float getAccelerometerZ() {
+ return 0;
+ }
+
+ @Override
+ public void getTextInput(final TextInputListener listener, final String title,
+ final String text) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override public void run () {
+ String output = JOptionPane.showInputDialog(null, title, text);
+ if (output != null) listener.input(output);
+ }
+ });
+ }
+
+ @Override
+ public int getX() {
+ return touchX;
+ }
+
+ @Override
+ public int getX(int pointer) {
+ if (pointer == 0)
+ return touchX;
+ else
+ return 0;
+ }
+
+ @Override
+ public int getY() {
+ return touchY;
+ }
+
+ @Override
+ public int getY(int pointer) {
+ if (pointer == 0)
+ return touchY;
+ else
+ return 0;
+ }
+
+ @Override
+ public boolean isAccelerometerAvailable() {
+ return false;
+ }
+
+ @Override
+ public boolean isKeyPressed(int key) {
+ synchronized(this) {
+ if( key == Input.Keys.ANY_KEY )
+ return keys.size() > 0;
+ else
+ return keys.contains(key);
+ }
+ }
+
+ @Override
+ public boolean isTouched() {
+ return touchDown;
+ }
+
+ @Override
+ public boolean isTouched(int pointer) {
+ if (pointer == 0)
+ return touchDown;
+ else
+ return false;
+ }
+
+ @Override
+ public void processEvents(InputProcessor listener) {
+ synchronized(this) {
+ if(listener!=null) {
+ for(KeyEvent e: keyEvents) {
+ switch(e.type) {
+ case KeyEvent.KEY_DOWN:
+ listener.keyDown(e.keyCode);
+ break;
+ case KeyEvent.KEY_UP:
+ listener.keyUp(e.keyCode);
+ break;
+ case KeyEvent.KEY_TYPED:
+ listener.keyTyped(e.keyChar);
+ }
+ freeKeyEvents.free(e);
+ }
+
+ for(TouchEvent e: touchEvents) {
+ switch(e.type) {
+ case TouchEvent.TOUCH_DOWN:
+ listener.touchDown(e.x, e.y, e.pointer);
+ break;
+ case TouchEvent.TOUCH_UP:
+ listener.touchUp(e.x, e.y, e.pointer);
+ break;
+ case TouchEvent.TOUCH_DRAGGED:
+ listener.touchDragged(e.x, e.y, e.pointer);
+ }
+ freeTouchEvents.free(e);
+ }
+ }
+
+ keyEvents.clear();
+ touchEvents.clear();
+ }
+ }
+
+ @Override
+ public void setCatchBackKey(boolean catchBack) {
+
+ }
+
+ @Override
+ public void setOnscreenKeyboardVisible(boolean visible) {
+
+ }
+
+ @Override
+ public boolean supportsMultitouch() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOnscreenKeyboard() {
+ return false;
+ }
+
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ synchronized(this) {
+ TouchEvent event = freeTouchEvents.newObject();
+ event.pointer = 0;
+ event.x = e.getX();
+ event.y = e.getY();
+ event.type = TouchEvent.TOUCH_DRAGGED;
+ touchEvents.add(event);
+
+ touchX = event.x;
+ touchY = event.y;
+ touchDown = true;
+ }
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent arg0) {
+
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent arg0) {
+
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ synchronized(this) {
+ TouchEvent event = freeTouchEvents.newObject();
+ event.pointer = 0;
+ event.x = e.getX();
+ event.y = e.getY();
+ event.type = TouchEvent.TOUCH_DOWN;
+ touchEvents.add(event);
+
+ touchX = event.x;
+ touchY = event.y;
+ touchDown = true;
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ synchronized(this) {
+ TouchEvent event = freeTouchEvents.newObject();
+ event.pointer = 0;
+ event.x = e.getX();
+ event.y = e.getY();
+ event.type = TouchEvent.TOUCH_UP;
+ touchEvents.add(event);
+
+ touchX = event.x;
+ touchY = event.y;
+ touchDown = false;
+ }
+ }
+
+ @Override
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ synchronized(this) {
+ KeyEvent event = freeKeyEvents.newObject();
+ event.keyChar = 0;
+ event.keyCode = translateKeyCode(e.getKeyCode());
+ event.type = KeyEvent.KEY_DOWN;
+ keyEvents.add(event);
+ keys.add(event.keyCode);
+ }
+ }
+
+ @Override
+ public void keyReleased(java.awt.event.KeyEvent e) {
+ synchronized(this) {
+ KeyEvent event = freeKeyEvents.newObject();
+ event.keyChar = 0;
+ event.keyCode = translateKeyCode(e.getKeyCode());
+ event.type = KeyEvent.KEY_UP;
+ keyEvents.add(event);
+ keys.remove(event.keyCode);
+ }
+ }
+
+ @Override
+ public void keyTyped(java.awt.event.KeyEvent e) {
+ synchronized(this) {
+ KeyEvent event = freeKeyEvents.newObject();
+ event.keyChar = e.getKeyChar();
+ event.keyCode = 0;
+ event.type = KeyEvent.KEY_TYPED;
+ keyEvents.add(event);
+ }
+ }
+
+ protected static int translateKeyCode (int keyCode) {
+ if (keyCode == java.awt.event.KeyEvent.VK_0) return Input.Keys.KEYCODE_0;
+ if (keyCode == java.awt.event.KeyEvent.VK_1) return Input.Keys.KEYCODE_1;
+ if (keyCode == java.awt.event.KeyEvent.VK_2) return Input.Keys.KEYCODE_2;
+ if (keyCode == java.awt.event.KeyEvent.VK_3) return Input.Keys.KEYCODE_3;
+ if (keyCode == java.awt.event.KeyEvent.VK_4) return Input.Keys.KEYCODE_4;
+ if (keyCode == java.awt.event.KeyEvent.VK_5) return Input.Keys.KEYCODE_5;
+ if (keyCode == java.awt.event.KeyEvent.VK_6) return Input.Keys.KEYCODE_6;
+ if (keyCode == java.awt.event.KeyEvent.VK_7) return Input.Keys.KEYCODE_7;
+ if (keyCode == java.awt.event.KeyEvent.VK_8) return Input.Keys.KEYCODE_8;
+ if (keyCode == java.awt.event.KeyEvent.VK_9) return Input.Keys.KEYCODE_9;
+ if (keyCode == java.awt.event.KeyEvent.VK_A) return Input.Keys.KEYCODE_A;
+ if (keyCode == java.awt.event.KeyEvent.VK_B) return Input.Keys.KEYCODE_B;
+ if (keyCode == java.awt.event.KeyEvent.VK_C) return Input.Keys.KEYCODE_C;
+ if (keyCode == java.awt.event.KeyEvent.VK_D) return Input.Keys.KEYCODE_D;
+ if (keyCode == java.awt.event.KeyEvent.VK_E) return Input.Keys.KEYCODE_E;
+ if (keyCode == java.awt.event.KeyEvent.VK_F) return Input.Keys.KEYCODE_F;
+ if (keyCode == java.awt.event.KeyEvent.VK_G) return Input.Keys.KEYCODE_G;
+ if (keyCode == java.awt.event.KeyEvent.VK_H) return Input.Keys.KEYCODE_H;
+ if (keyCode == java.awt.event.KeyEvent.VK_I) return Input.Keys.KEYCODE_I;
+ if (keyCode == java.awt.event.KeyEvent.VK_J) return Input.Keys.KEYCODE_J;
+ if (keyCode == java.awt.event.KeyEvent.VK_K) return Input.Keys.KEYCODE_K;
+ if (keyCode == java.awt.event.KeyEvent.VK_L) return Input.Keys.KEYCODE_L;
+ if (keyCode == java.awt.event.KeyEvent.VK_M) return Input.Keys.KEYCODE_M;
+ if (keyCode == java.awt.event.KeyEvent.VK_N) return Input.Keys.KEYCODE_N;
+ if (keyCode == java.awt.event.KeyEvent.VK_O) return Input.Keys.KEYCODE_O;
+ if (keyCode == java.awt.event.KeyEvent.VK_P) return Input.Keys.KEYCODE_P;
+ if (keyCode == java.awt.event.KeyEvent.VK_Q) return Input.Keys.KEYCODE_Q;
+ if (keyCode == java.awt.event.KeyEvent.VK_R) return Input.Keys.KEYCODE_R;
+ if (keyCode == java.awt.event.KeyEvent.VK_S) return Input.Keys.KEYCODE_S;
+ if (keyCode == java.awt.event.KeyEvent.VK_T) return Input.Keys.KEYCODE_T;
+ if (keyCode == java.awt.event.KeyEvent.VK_U) return Input.Keys.KEYCODE_U;
+ if (keyCode == java.awt.event.KeyEvent.VK_V) return Input.Keys.KEYCODE_V;
+ if (keyCode == java.awt.event.KeyEvent.VK_W) return Input.Keys.KEYCODE_W;
+ if (keyCode == java.awt.event.KeyEvent.VK_X) return Input.Keys.KEYCODE_X;
+ if (keyCode == java.awt.event.KeyEvent.VK_Y) return Input.Keys.KEYCODE_Y;
+ if (keyCode == java.awt.event.KeyEvent.VK_Z) return Input.Keys.KEYCODE_Z;
+ if (keyCode == java.awt.event.KeyEvent.VK_ALT) return Input.Keys.KEYCODE_ALT_LEFT;
+ if (keyCode == java.awt.event.KeyEvent.VK_ALT_GRAPH) return Input.Keys.KEYCODE_ALT_RIGHT;
+ if (keyCode == java.awt.event.KeyEvent.VK_BACK_SLASH) return Input.Keys.KEYCODE_BACKSLASH;
+ if (keyCode == java.awt.event.KeyEvent.VK_COMMA) return Input.Keys.KEYCODE_COMMA;
+ if (keyCode == java.awt.event.KeyEvent.VK_DELETE) return Input.Keys.KEYCODE_DEL;
+ if (keyCode == java.awt.event.KeyEvent.VK_LEFT) return Input.Keys.KEYCODE_DPAD_LEFT;
+ if (keyCode == java.awt.event.KeyEvent.VK_RIGHT) return Input.Keys.KEYCODE_DPAD_RIGHT;
+ if (keyCode == java.awt.event.KeyEvent.VK_UP) return Input.Keys.KEYCODE_DPAD_UP;
+ if (keyCode == java.awt.event.KeyEvent.VK_DOWN) return Input.Keys.KEYCODE_DPAD_DOWN;
+ if (keyCode == java.awt.event.KeyEvent.VK_ENTER) return Input.Keys.KEYCODE_ENTER;
+ if (keyCode == java.awt.event.KeyEvent.VK_HOME) return Input.Keys.KEYCODE_HOME;
+ if (keyCode == java.awt.event.KeyEvent.VK_MINUS) return Input.Keys.KEYCODE_MINUS;
+ if (keyCode == java.awt.event.KeyEvent.VK_PERIOD) return Input.Keys.KEYCODE_PERIOD;
+ if (keyCode == java.awt.event.KeyEvent.VK_PLUS) return Input.Keys.KEYCODE_PLUS;
+ if (keyCode == java.awt.event.KeyEvent.VK_SEMICOLON) return Input.Keys.KEYCODE_SEMICOLON;
+ if (keyCode == java.awt.event.KeyEvent.VK_SHIFT) return Input.Keys.KEYCODE_SHIFT_LEFT;
+ if (keyCode == java.awt.event.KeyEvent.VK_SLASH) return Input.Keys.KEYCODE_SLASH;
+ if (keyCode == java.awt.event.KeyEvent.VK_SPACE) return Input.Keys.KEYCODE_SPACE;
+ if (keyCode == java.awt.event.KeyEvent.VK_TAB) return Input.Keys.KEYCODE_TAB;
+
+ return Input.Keys.KEYCODE_UNKNOWN;
+ }
+}
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglMusic.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglMusic.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglMusic.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglMusic.java
index e995db152..fbcd93267 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglMusic.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglMusic.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.io.File;
import java.io.IOException;
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
index 000000000..25d640325
--- /dev/null
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglNativesLoader.java
@@ -0,0 +1,96 @@
+package com.badlogic.gdx.backends.jogl;
+
+import java.io.BufferedOutputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.sun.opengl.impl.NativeLibLoader;
+
+public class JoglNativesLoader {
+ static boolean nativesLoaded = false;
+
+ /**
+ * loads the necessary libraries depending on the operating system
+ */
+ static void loadLibraries() {
+ if (nativesLoaded)
+ return;
+
+ NativeLibLoader.disableLoading();
+ com.sun.gluegen.runtime.NativeLibLoader.disableLoading();
+ // By wkien: On some systems (read: mine) jogl_awt would not find its
+ // dependency jawt if not loaded before
+ System.loadLibrary("jawt");
+ loadLibrary("gluegen-rt");
+ loadLibrary("jogl_awt");
+ loadLibrary("jogl");
+
+ nativesLoaded = true;
+ }
+
+ /**
+ * helper method to load a specific library in an operation system dependant
+ * manner
+ *
+ * @param resource
+ * the name of the resource
+ */
+ private static void loadLibrary(String resource) {
+ String package_path = "/javax/media/";
+ String library = "";
+
+ String os = System.getProperty("os.name");
+ String arch = System.getProperty("os.arch");
+
+ if (os.contains("Windows")) {
+ if (!arch.equals("amd64"))
+ library = resource + "-win32.dll";
+ else {
+ library = resource + "-win64.dll";
+ }
+ }
+
+ if (os.contains("Linux")) {
+ if (!arch.equals("amd64"))
+ library = "lib" + resource + "-linux32.so";
+ else
+ library = "lib" + resource + "-linux64.so";
+ }
+
+ if (os.contains("Mac")) {
+ library = "lib" + resource + ".jnilib";
+ }
+
+ String so = System.getProperty("java.io.tmpdir") + "/"
+ + System.nanoTime() + library;
+ InputStream in = JoglGraphics.class.getResourceAsStream(package_path
+ + library);
+ if (in == null)
+ throw new RuntimeException("couldn't find " + library
+ + " in jar file.");
+
+ try {
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(so));
+ byte[] bytes = new byte[1024 * 4];
+ while (true) {
+ int read_bytes = in.read(bytes);
+ if (read_bytes == -1)
+ break;
+
+ out.write(bytes, 0, read_bytes);
+ }
+ out.close();
+ in.close();
+ System.load(so);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException("couldn't write " + library
+ + " to temporary file " + so);
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't write " + library
+ + " to temporary file " + so);
+ }
+ }
+}
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPixmap.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglPixmap.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPixmap.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglPixmap.java
index 4f7b27cac..9c9ecab58 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglPixmap.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglPixmap.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglSound.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglSound.java
similarity index 95%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglSound.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglSound.java
index e5e5a1ccd..3d8d5e01d 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglSound.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglSound.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
diff --git a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglTexture.java b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglTexture.java
similarity index 96%
rename from backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglTexture.java
rename to backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglTexture.java
index 7a001f883..c509b45ed 100644
--- a/backends/gdx-backend-desktop/src/com/badlogic/gdx/backends/desktop/JoglTexture.java
+++ b/backends/gdx-backend-jogl/src/com/badlogic/gdx/backends/jogl/JoglTexture.java
@@ -11,7 +11,7 @@
* governing permissions and limitations under the License.
******************************************************************************/
-package com.badlogic.gdx.backends.desktop;
+package com.badlogic.gdx.backends.jogl;
import java.awt.image.BufferedImage;
import java.io.InputStream;
diff --git a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java
index 657c0ed27..abb5a3c4d 100644
--- a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java
+++ b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java
@@ -166,7 +166,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
this.width = width;
this.height = height;
for (RenderListener listener : listeners)
- listener.surfaceChanged(getWidth(), getHeight());
+ listener.resized(getWidth(), getHeight());
}
void start () throws LWJGLException {
@@ -175,7 +175,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
setupDisplay();
for (RenderListener listener : listeners)
- listener.surfaceCreated();
+ listener.created();
setSize(width, height);
graphics.lastTime = System.nanoTime();
for (RenderListener listener : listeners)
diff --git a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java
index d73ba1a2d..b32467032 100644
--- a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java
+++ b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java
@@ -158,7 +158,7 @@ public final class LwjglGraphics implements Graphics, RenderListener {
frames++;
}
- public void surfaceCreated () {
+ public void created () {
String version = org.lwjgl.opengl.GL11.glGetString(GL11.GL_VERSION);
int major = Integer.parseInt("" + version.charAt(0));
int minor = Integer.parseInt("" + version.charAt(2));
@@ -187,7 +187,7 @@ public final class LwjglGraphics implements Graphics, RenderListener {
return deltaTime;
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
}
public GraphicsType getType () {
diff --git a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglInput.java b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglInput.java
index 587336823..43a8aee9e 100644
--- a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglInput.java
+++ b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglInput.java
@@ -23,7 +23,7 @@ import org.lwjgl.input.Mouse;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.RenderListener;
/**
@@ -35,9 +35,9 @@ import com.badlogic.gdx.RenderListener;
final class LwjglInput implements Input, RenderListener {
String text;
TextInputListener textListener;
- @SuppressWarnings("unchecked") private final ArrayList listeners = new ArrayList();
+ @SuppressWarnings("unchecked") private final ArrayList listeners = new ArrayList();
- public void addInputListener (InputListener listener) {
+ public void addInputListener (InputProcessor listener) {
listeners.add(listener);
}
@@ -84,7 +84,7 @@ final class LwjglInput implements Input, RenderListener {
return button;
}
- public void removeInputListener (InputListener listener) {
+ public void removeInputListener (InputProcessor listener) {
listeners.remove(listener);
}
@@ -99,12 +99,12 @@ final class LwjglInput implements Input, RenderListener {
}
}
- public void surfaceCreated () {
+ public void created () {
// TODO Auto-generated method stub
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
// TODO Auto-generated method stub
}
diff --git a/build.xml b/build.xml
index 5f3831e1b..d6fad07bb 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
@@ -23,7 +23,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -40,8 +40,8 @@
-
-
+
+
@@ -82,8 +82,8 @@
-
-
+
+
@@ -108,7 +108,7 @@
-
+
@@ -120,7 +120,7 @@
-
+
diff --git a/extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java b/extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java
index 46738afc7..162c413d1 100644
--- a/extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java
+++ b/extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java
@@ -1135,7 +1135,7 @@ public class Hiero extends JFrame {
class Renderer implements RenderListener {
private String sampleText;
- public void surfaceCreated () {
+ public void created () {
glEnable(GL_SCISSOR_TEST);
glEnable(GL_TEXTURE_2D);
@@ -1151,7 +1151,7 @@ public class Hiero extends JFrame {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
glViewport(0, 0, width, height);
glScissor(0, 0, width, height);
@@ -1263,16 +1263,16 @@ public class Hiero extends JFrame {
}
public static void main (String[] args) throws Exception {
- LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
- for (int i = 0, n = lookAndFeels.length; i < n; i++) {
- if ("Nimbus".equals(lookAndFeels[i].getName())) {
- try {
- UIManager.setLookAndFeel(lookAndFeels[i].getClassName());
- } catch (Throwable ignored) {
- }
- break;
- }
- }
+// LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
+// for (int i = 0, n = lookAndFeels.length; i < n; i++) {
+// if ("Nimbus".equals(lookAndFeels[i].getName())) {
+// try {
+// UIManager.setLookAndFeel(lookAndFeels[i].getClassName());
+// } catch (Throwable ignored) {
+// }
+// break;
+// }
+// }
new Hiero();
}
}
diff --git a/extensions/hiero/src/com/badlogic/gdx/hiero/unicodefont/UnicodeFontTest.java b/extensions/hiero/src/com/badlogic/gdx/hiero/unicodefont/UnicodeFontTest.java
index 3ad0f4d5b..46152fc02 100644
--- a/extensions/hiero/src/com/badlogic/gdx/hiero/unicodefont/UnicodeFontTest.java
+++ b/extensions/hiero/src/com/badlogic/gdx/hiero/unicodefont/UnicodeFontTest.java
@@ -13,14 +13,14 @@ import com.badlogic.gdx.hiero.unicodefont.effects.ColorEffect;
public class UnicodeFontTest implements RenderListener {
private UnicodeFont unicodeFont;
- public void surfaceCreated () {
+ public void created () {
unicodeFont = new UnicodeFont("c:/windows/fonts/arial.ttf", 48, false, false);
unicodeFont.getEffects().add(new ColorEffect(java.awt.Color.white));
// unicodeFont.addAsciiGlyphs();
// unicodeFont.loadGlyphs();
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
glViewport(0, 0, width, height);
glScissor(0, 0, width, height);
glEnable(GL_SCISSOR_TEST);
diff --git a/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java b/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java
index ead59b1b8..4db9576f4 100644
--- a/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java
+++ b/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java
@@ -35,7 +35,7 @@ import org.lwjgl.opengl.Display;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.backends.desktop.LwjglApplication;
import com.badlogic.gdx.graphics.BitmapFont;
@@ -248,7 +248,7 @@ public class ParticleEditor extends JFrame {
splitPane.setDividerLocation(325);
}
- class Renderer implements RenderListener, InputListener {
+ class Renderer implements RenderListener, InputProcessor {
private float maxActiveTimer;
private int maxActive, lastMaxActive;
private boolean mouseDown;
@@ -258,7 +258,7 @@ public class ParticleEditor extends JFrame {
private SpriteBatch spriteBatch;
private Sprite bgImage; // BOZO - Add setting background image to UI.
- public void surfaceCreated () {
+ public void created () {
if (spriteBatch != null) return;
spriteBatch = new SpriteBatch();
@@ -270,7 +270,7 @@ public class ParticleEditor extends JFrame {
Gdx.input.addInputListener(this);
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
int viewWidth = Gdx.graphics.getWidth();
int viewHeight = Gdx.graphics.getHeight();
diff --git a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/ButtonTest.java b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/ButtonTest.java
index 734debfb6..d3a77de63 100644
--- a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/ButtonTest.java
+++ b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/ButtonTest.java
@@ -23,7 +23,7 @@ import de.matthiasmann.twl.textarea.Value;
public class ButtonTest implements RenderListener {
GUI gui;
- public void surfaceCreated () {
+ public void created () {
if (gui != null) return;
Button button = new Button("Click Me");
@@ -42,7 +42,7 @@ public class ButtonTest implements RenderListener {
gui.update();
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
gui.setSize();
}
diff --git a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java
index c74b5090b..7f4b7af4b 100644
--- a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java
+++ b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java
@@ -22,7 +22,7 @@ import de.matthiasmann.twl.textarea.Value;
public class TextAreaTest implements RenderListener {
GUI gui;
- public void surfaceCreated () {
+ public void created () {
if (gui != null) return;
final HTMLTextAreaModel htmlText = new HTMLTextAreaModel();
@@ -75,7 +75,7 @@ public class TextAreaTest implements RenderListener {
gui.update();
}
- public void surfaceChanged (int width, int height) {
+ public void resized (int width, int height) {
TwlRenderer.updateSize(gui);
}
diff --git a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlInputListener.java b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlInputListener.java
index 72c8028f8..748f3bd6d 100644
--- a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlInputListener.java
+++ b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlInputListener.java
@@ -1,7 +1,7 @@
package com.badlogic.gdx.twl.renderer;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.RenderListener;
import de.matthiasmann.twl.GUI;
@@ -9,7 +9,7 @@ import de.matthiasmann.twl.GUI;
/**
* @author Nathan Sweet
*/
-public class TwlInputListener implements InputListener {
+public class TwlInputListener implements InputProcessor {
private final GUI gui;
public TwlInputListener (GUI gui) {
diff --git a/gdx/build.xml b/gdx/build.xml
index c99ade73d..fd527e59b 100644
--- a/gdx/build.xml
+++ b/gdx/build.xml
@@ -1,8 +1,7 @@
@@ -24,7 +23,7 @@
-
+
@@ -33,7 +32,7 @@
-
+
@@ -41,8 +40,8 @@
-
-
+
+
@@ -84,8 +83,8 @@
-
-
+
+
@@ -109,7 +108,7 @@
-
+
@@ -121,7 +120,7 @@
-
+
diff --git a/gdx/src/com/badlogic/gdx/Application.java b/gdx/src/com/badlogic/gdx/Application.java
index 7471161cd..f1ea34f0a 100644
--- a/gdx/src/com/badlogic/gdx/Application.java
+++ b/gdx/src/com/badlogic/gdx/Application.java
@@ -23,7 +23,8 @@ package com.badlogic.gdx;
*
* An application can either be a desktop application ({@link JoglApplication}, {@link LwjglApplication}), or an
* Android application ({@link AndroidApplication}). Each application class has it's own startup and initialization methods.
- * Please refer to their documentation for more information.
+ * Please refer to their documentation for more information. In any case you will have to specify an {@link ApplicationListener} that
+ * implements your program logic.
*
*
*
@@ -41,7 +42,7 @@ package com.badlogic.gdx;
*
*
* {@link Input} offers you various methods to poll user input from the keyboard, touch screen, mouse and accelerometer.
- * Additionally you can register an {@link InputListener} which allows for event based input processing. The
+ * Additionally you can register an {@link InputProcessor} which allows for event based input processing. The
* InputListener will be called in the rendering thread which will also call your RenderListener. This
* way you don't have to care about thread synchronization when you process input events.
*
@@ -56,11 +57,6 @@ package com.badlogic.gdx;
*
*
*
- * Additionally an Application allows to set a {@link ApplicationListener} which will be invoked when the
- * Application is paused, resumed or closing. This can be used to save any state that needs saving. Note that the
- * ApplicationListener will not be called in the rendering thread.
- *
- *
* Generally you will have two projects for your application. The first one will be the
* desktop project which houses all your application code as well as a {@link JoglApplication}.
* The second project will be the Android project which only contains an Activity derived from {@link AndroidApplication}.
@@ -127,11 +123,4 @@ public interface Application {
* @return the Android API level on Android or 0 on the desktop.
*/
public int getVersion ();
-
- /**
- * Sets the {@link ApplicationListener} that is called when the {@link Application} is paused, resumed or closing.
- *
- * @param listener the ApplicationListener
- */
- public void setApplicationListener (ApplicationListener listener);
}
diff --git a/gdx/src/com/badlogic/gdx/ApplicationListener.java b/gdx/src/com/badlogic/gdx/ApplicationListener.java
index 92ce4bc98..76cf3c775 100644
--- a/gdx/src/com/badlogic/gdx/ApplicationListener.java
+++ b/gdx/src/com/badlogic/gdx/ApplicationListener.java
@@ -15,35 +15,44 @@ package com.badlogic.gdx;
/**
*
- * An ApplicationListener is called when the {@link Application} is resumed, paused and destroyed. This allows you to
- * 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
- * load or unload any Graphics related resources in the provided by this interface!
+ * An ApplicationListener is called when the {@link Application} is created, resumed, rendering, paused or destroyed. All
+ * methods are called in a thread that has the OpenGL context current. You can thus safely create and manipulate graphics resources.
*
*
*
* The ApplicationListener interface follows the standard Android activity life-cycle and is emulated on the desktop
- * accordingly. The pause method will be called after the rendering thread has been paused. The resume method will be called
- * before the rendering thread has been started.
+ * accordingly.
+ *
*
* @author mzechner
*
*/
public interface ApplicationListener {
/**
- * Called when the {@link Application} is paused. An Application is paused before it is destroyed or when a user pressed the
- * Home button on Android. This will not be called in the rendering thread. Instead the rendering thread will be paused before
- * this method is called.
+ * Called when the {@link Application} is first created.
*/
- public void pause ();
+ public void create ();
/**
- * Called when the {@link Application} is resumed from a paused state or the Application was just created. This will not be
- * called in the rendering thread. Instead this callback will be first called, then the rendering thread will be resumed.
+ * Called when the {@link Application} is resumed from a paused state. On
+ * Android this happens when the activity gets focus again, on the desktop
+ * that happens when the application is maximized from a minimzed state.
*/
public void resume ();
+
+ /**
+ * Called when the {@link Application} should render itself.
+ */
+ public void render ();
+
+ /**
+ * Called when the {@link Application} is paused. An Application is paused before it is destroyed, when a user pressed the
+ * Home button on Android or an incoming call happend or when a window on the desktop is minimized.
+ */
+ public void pause ();
/**
- * Called when the {@link Application} is destroyed. This will not be called in the rendering thread.
+ * Called when the {@link Application} is destroyed. Preceded by a call to {@link #pause()}.
*/
public void destroy ();
}
diff --git a/gdx/src/com/badlogic/gdx/Graphics.java b/gdx/src/com/badlogic/gdx/Graphics.java
index f40be0b9c..7553debeb 100644
--- a/gdx/src/com/badlogic/gdx/Graphics.java
+++ b/gdx/src/com/badlogic/gdx/Graphics.java
@@ -65,7 +65,7 @@ public interface Graphics {
}
/**
- * Returns whether OpenGL ES 1.1 is available. If it is you can get an instance of {@link GL11} via {@link getGL11()} to access
+ * Returns whether OpenGL ES 1.1 is available. If it is you can get an instance of {@link GL11} via {@link #getGL11()} to access
* OpenGL ES 1.1 functionality.
*
* @return whether OpenGL ES 1.1 is available
@@ -73,14 +73,11 @@ public interface Graphics {
public boolean isGL11Available ();
/**
- * Returns whether OpenGL ES 2.0 is available. If it is you can get an instance of {@link GL20} via {@link getGL20()} to access
+ * Returns whether OpenGL ES 2.0 is available. If it is you can get an instance of {@link GL20} via {@link #getGL20()} to access
* OpenGL ES 2.0 functionality. Note that this functionality will only be available if you instructed the Application instance
* to use OpenGL ES 2.0!
*
* @return whether OpenGL ES 2.0 is available
- *
- * @see DesktopApplication
- * @see AndroidApplication
*/
public boolean isGL20Available ();
@@ -130,16 +127,6 @@ public interface Graphics {
public int getFramesPerSecond ();
/**
- * Sets the {@link RenderListener}. The RenderListener will be called once the OpenGL surface has been setup to
- * give it an opportunity to create all its graphic resources like textures and meshes. After the setup is complete the
- * RenderListener will be called continuously to render new frames. When the {@link Application} is closing the RenderListener
- * will be called one last time to clean up.
- *
- * @param listener the RenderListener
- */
- public void setRenderListener (RenderListener listener);
-
- /**
* Creates a new {@link Pixmap} with the specified dimensions and format.
*
* @param width the width in pixels
@@ -181,7 +168,7 @@ public interface Graphics {
/**
* Creates a new {@link Texture} with the specified dimensions, minification and magnification filters and texture wraps in u
- * and v. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer used. The width and
+ * and v. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer used. The width and
* height of the texture have to be a power of two! Textures created via this method can not be managed and have to be
* recreated manually when the OpenGL context is lost.
*
@@ -200,8 +187,8 @@ public interface Graphics {
/**
* Creates a new {@link Texture} from the given {@link Pixmap} using the specified minification and magnification filter and
- * texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter.MipMap} mip maps will be
- * created automatically. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer used.
+ * texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter#MipMap} mip maps will be
+ * created automatically. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer used.
* 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
* recreated manually when the OpenGL context is lost.
*
@@ -218,8 +205,8 @@ public interface Graphics {
/**
* Creates a new {@link Texture} from the given {@link FileHandle} using the specified minification and magnification filter
- * and texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter.MipMap} mip maps will
- * be created automatically. The Texture has to be disposed via the {@link Texture.dispose()} methods once it is no longer
+ * and texture wraps in u and v. If the minification filter is specified as {@link Texture.TextureFilter#MipMap} mip maps will
+ * be created automatically. The Texture has to be disposed via the {@link Texture#dispose()} methods once it is no longer
* 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!
* Textures created via this method are managed and will be recreated automatically after the OpenGL context has been lost and
* recreated.
diff --git a/gdx/src/com/badlogic/gdx/Input.java b/gdx/src/com/badlogic/gdx/Input.java
index d4f6a8ecf..296fb3331 100644
--- a/gdx/src/com/badlogic/gdx/Input.java
+++ b/gdx/src/com/badlogic/gdx/Input.java
@@ -20,20 +20,8 @@ package com.badlogic.gdx;
*
*
*
- * Additionally one can register an {@link InputListener} with this module. The InputListener will then be called each time a key
- * is pressed or released or a touch event occures.
- *
- *
- *
- * The InputListener will be called in the rendering thread of the graphics module to which a RenderListener is probably attached.
- * This means that one does not have to take precautions to guarantee thread safety. One can safely call graphics methods from
- * within the InputListener callbacks.
- *
- *
- *
- * One or more InputListeners can be registered with the module. The events will then get passed to the InputListeners in the
- * order they have been registered with the module. If an InputListeners signals that it consumed the event the InputListeners
- * down the chain will not be invoked.
+ * Additionally one can process events with an {@link InputProcessor} with this module. Just pass in the InputListener to the
+ * {@link #processEvents(InputProcessor)} method in any thread you want.
*
*
*
@@ -165,21 +153,6 @@ public interface Input {
}
/**
- * Adds an {@link InputListener}. The order InputListeners are added is the same as the order in which they are called in case
- * of an event. If an input listener signals that it processed the event the event is not passed to the other listeners in the
- * chain.
- *
- * @param listener the listener
- */
- public void addInputListener (InputListener listener);
-
- /**
- * Removes the {@link InputListener}.
- * @param listener the listener
- */
- public void removeInputListener (InputListener listener);
-
- /**
* @return whether an accelerometer is available
*/
public boolean isAccelerometerAvailable ();
@@ -285,4 +258,13 @@ public interface Input {
* @param catchBack whether to catch the back button
*/
public void setCatchBackKey( boolean catchBack );
+
+ /**
+ * Passes all events that happened since the last invocation of this
+ * method to the provided InputListener. Make sure you call this method
+ * each frame otherwise events will accumulate!
+ *
+ * @param listener the {@link InputProcessor} or null if you want to just discard of all events.
+ */
+ public void processEvents(InputProcessor listener);
}
diff --git a/gdx/src/com/badlogic/gdx/InputAdapter.java b/gdx/src/com/badlogic/gdx/InputAdapter.java
index b8f216c68..6913ae393 100644
--- a/gdx/src/com/badlogic/gdx/InputAdapter.java
+++ b/gdx/src/com/badlogic/gdx/InputAdapter.java
@@ -2,13 +2,13 @@
package com.badlogic.gdx;
/**
- * An adapter class for {@link InputListener}. You can derive from this
+ * An adapter class for {@link InputProcessor}. You can derive from this
* and only override what you are interested in.
*
* @author mzechner
*
*/
-public class InputAdapter implements InputListener {
+public class InputAdapter implements InputProcessor {
public boolean keyDown (int keycode) {
return false;
}
diff --git a/gdx/src/com/badlogic/gdx/InputListener.java b/gdx/src/com/badlogic/gdx/InputProcessor.java
similarity index 75%
rename from gdx/src/com/badlogic/gdx/InputListener.java
rename to gdx/src/com/badlogic/gdx/InputProcessor.java
index 371ef9f21..5dc021eb3 100644
--- a/gdx/src/com/badlogic/gdx/InputListener.java
+++ b/gdx/src/com/badlogic/gdx/InputProcessor.java
@@ -14,17 +14,15 @@
package com.badlogic.gdx;
/**
- * An InputListener is used to receive input events from the keyboard and the touch screen (mouse on the desktop). For this it has
- * to be registered with the {@link Input} instance of an {@link Application}. The events might arrive asynchronously in a UI
- * thread, the {@link Input} instance will buffer those events and invoke the methods of the listener in the rendering thread to
- * get rid of the need to synchronize the UI and renderer thread for input. If an InputListener signals that it processed an event
- * by returning true the the event will not be passed to other listeners in the listener chain (multiple InputListeners can
- * register with an Input instance).
+ * An InputPr is used to receive input events from the keyboard and the touch screen (mouse on the desktop). For this it has
+ * to be used in combination with {@link Input#processEvents(InputProcessor)} method. The methods return a boolean in case
+ * you want to write a multiplexing InputProcessor that has a chain of child processors that signal whether they processed
+ * the event.
*
* @author badlogicgames@gmail.com
*
*/
-public interface InputListener {
+public interface InputProcessor {
/**
* Called when a key was pressed
* @param keycode one of the constants in {@link Input.Keys}
diff --git a/gdx/src/com/badlogic/gdx/RenderListener.java b/gdx/src/com/badlogic/gdx/RenderListener.java
deleted file mode 100644
index 8b881fd8f..000000000
--- a/gdx/src/com/badlogic/gdx/RenderListener.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- ******************************************************************************/
-
-package com.badlogic.gdx;
-
-/**
- * A RenderListener can be hooked to a {@link Graphics} instance and will receive setup, render and dispose events. In case of a
- * setup event the listener can create any resources it needs later on to draw. The setup method is also called when the OpenGL
- * surface has been recreated after a context loss. This happens only on Android in case the application was paused and resumed.
- * All OpenGL resources like textures, meshes and shaders are lost and have to be recreated. The render method is called whenever
- * the {@link Application} is redrawn. The dispose method is called before the Application is closed or the RenderListener is
- * unregistered from the Graphics instance.
- *
- * The methods will be invoked in the rendering thread of the application and not in the UI thread!
- *
- *
- * @author badlogicgames@gmail.com
- *
- */
-public interface RenderListener {
- /**
- * The setup method is called once upon initialization of the {@link Application} and every time the OpenGL surface is
- * recreated. On Android this happens when the application is unpaused after it was paused by a press of the home button or an
- * incoming call. All unmanaged textures have to be recreated manually, all other resources will be reloaded automatically.
- *
- */
- public void surfaceCreated ();
-
- /**
- * Called when the OpenGL surface changed it's dimensions.
- *
- * @param width the width of the surface in pixels
- * @param height the height of the surface in pixels
- */
- public void surfaceChanged (int width, int height);
-
- /**
- * The render method is called every time a new frame should be rendered.
- */
- public void render ();
-
- /**
- * The dispose method is called when the application is closing or the {@link RenderListener} has been unregistered from the
- * Graphics instance.
- */
- public void dispose ();
-}
diff --git a/gdx/src/com/badlogic/gdx/graphics/Mesh.java b/gdx/src/com/badlogic/gdx/graphics/Mesh.java
index 84ab88089..6a54c6c77 100644
--- a/gdx/src/com/badlogic/gdx/graphics/Mesh.java
+++ b/gdx/src/com/badlogic/gdx/graphics/Mesh.java
@@ -71,6 +71,8 @@ public class Mesh {
indices = new IndexBufferObject(maxIndices);
isVertexArray = true;
}
+
+ meshes.add(this);
}
/**
diff --git a/gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java b/gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java
index 242b7c719..b540e814b 100644
--- a/gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java
+++ b/gdx/src/com/badlogic/gdx/graphics/glutils/IndexBufferObject.java
@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.GL11;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.utils.BufferUtils;
+import com.badlogic.gdx.utils.GdxRuntimeException;
/**
*
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
-
- "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.
-
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
-
- "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.
-
-
- "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).
-
-
- "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.
-
-
- "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."
-
-
- "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.
-
-
2. Grant of Copyright License.
-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.
-
-
3. Grant of Patent License.
-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.
-
-
4. Redistribution.
-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:
-
-
You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
-
-
You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
-
-
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
-
-
-
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.
-
- 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.
-
-
5. Submission of Contributions.
-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.
-
-
6. Trademarks.
-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.
-
-
7. Disclaimer of Warranty.
-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.
-
-
8. Limitation of Liability.
-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.
-
-
9. Accepting Warranty or Additional Liability.
-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.
-
-
-END OF TERMS AND CONDITIONS
-
-
\ 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
index f10fd210c..000000000
--- a/tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglDebugStarter.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.badlogic.gdx.tests.desktop;
-
-import com.badlogic.gdx.backends.desktop.JoglApplication;
-
-public class JoglDebugStarter {
-
- public static void main( String[] argv ) {
- JoglApplication app = new JoglApplication( "Debug Test", 480, 320, true );
- app.getGraphics().setRenderListener( new com.badlogic.gdx.tests.VertexBufferObjectShaderTest() );
- }
-}
diff --git a/tests/gdx-tests-desktop/.classpath b/tests/gdx-tests-jogl/.classpath
similarity index 50%
rename from tests/gdx-tests-desktop/.classpath
rename to tests/gdx-tests-jogl/.classpath
index 5487742ec..f305ffb0d 100644
--- a/tests/gdx-tests-desktop/.classpath
+++ b/tests/gdx-tests-jogl/.classpath
@@ -1,17 +1,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/backends/gdx-backend-desktop/.project b/tests/gdx-tests-jogl/.project
similarity index 87%
rename from backends/gdx-backend-desktop/.project
rename to tests/gdx-tests-jogl/.project
index 4ec5fe0b8..042609702 100644
--- a/backends/gdx-backend-desktop/.project
+++ b/tests/gdx-tests-jogl/.project
@@ -1,6 +1,6 @@
- gdx-backend-desktop
+ gdx-tests-jogl
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
index 000000000..827e41b90
--- /dev/null
+++ b/tests/gdx-tests-jogl/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Mon Nov 01 18:55:55 CET 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/gdx-tests-desktop/data/arial.ttf b/tests/gdx-tests-jogl/data/arial.ttf
similarity index 100%
rename from tests/gdx-tests-desktop/data/arial.ttf
rename to tests/gdx-tests-jogl/data/arial.ttf
diff --git a/tests/gdx-tests-desktop/data/badlogic.jpg b/tests/gdx-tests-jogl/data/badlogic.jpg
similarity index 100%
rename from tests/gdx-tests-desktop/data/badlogic.jpg
rename to tests/gdx-tests-jogl/data/badlogic.jpg
diff --git a/tests/gdx-tests-desktop/data/badlogicsmall.jpg b/tests/gdx-tests-jogl/data/badlogicsmall.jpg
similarity index 100%
rename from tests/gdx-tests-desktop/data/badlogicsmall.jpg
rename to tests/gdx-tests-jogl/data/badlogicsmall.jpg
diff --git a/tests/gdx-tests-desktop/data/cloudconnected.ogg b/tests/gdx-tests-jogl/data/cloudconnected.ogg
similarity index 100%
rename from tests/gdx-tests-desktop/data/cloudconnected.ogg
rename to tests/gdx-tests-jogl/data/cloudconnected.ogg
diff --git a/tests/gdx-tests-desktop/data/cube.gdx3d b/tests/gdx-tests-jogl/data/cube.gdx3d
similarity index 100%
rename from tests/gdx-tests-desktop/data/cube.gdx3d
rename to tests/gdx-tests-jogl/data/cube.gdx3d
diff --git a/tests/gdx-tests-desktop/data/cube.obj b/tests/gdx-tests-jogl/data/cube.obj
similarity index 100%
rename from tests/gdx-tests-desktop/data/cube.obj
rename to tests/gdx-tests-jogl/data/cube.obj
diff --git a/tests/gdx-tests-desktop/data/debug.png b/tests/gdx-tests-jogl/data/debug.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/debug.png
rename to tests/gdx-tests-jogl/data/debug.png
diff --git a/tests/gdx-tests-desktop/data/font.fnt b/tests/gdx-tests-jogl/data/font.fnt
similarity index 100%
rename from tests/gdx-tests-desktop/data/font.fnt
rename to tests/gdx-tests-jogl/data/font.fnt
diff --git a/tests/gdx-tests-desktop/data/font.png b/tests/gdx-tests-jogl/data/font.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/font.png
rename to tests/gdx-tests-jogl/data/font.png
diff --git a/tests/gdx-tests-desktop/data/heavysphere.obj b/tests/gdx-tests-jogl/data/heavysphere.obj
similarity index 100%
rename from tests/gdx-tests-desktop/data/heavysphere.obj
rename to tests/gdx-tests-jogl/data/heavysphere.obj
diff --git a/tests/gdx-tests-desktop/data/particle-cloud.png b/tests/gdx-tests-jogl/data/particle-cloud.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/particle-cloud.png
rename to tests/gdx-tests-jogl/data/particle-cloud.png
diff --git a/tests/gdx-tests-desktop/data/particle-fire.png b/tests/gdx-tests-jogl/data/particle-fire.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/particle-fire.png
rename to tests/gdx-tests-jogl/data/particle-fire.png
diff --git a/tests/gdx-tests-desktop/data/particle-star.png b/tests/gdx-tests-jogl/data/particle-star.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/particle-star.png
rename to tests/gdx-tests-jogl/data/particle-star.png
diff --git a/tests/gdx-tests-desktop/data/particle.png b/tests/gdx-tests-jogl/data/particle.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/particle.png
rename to tests/gdx-tests-jogl/data/particle.png
diff --git a/tests/gdx-tests-desktop/data/scene.obj b/tests/gdx-tests-jogl/data/scene.obj
similarity index 100%
rename from tests/gdx-tests-desktop/data/scene.obj
rename to tests/gdx-tests-jogl/data/scene.obj
diff --git a/tests/gdx-tests-desktop/data/scene2.obj b/tests/gdx-tests-jogl/data/scene2.obj
similarity index 100%
rename from tests/gdx-tests-desktop/data/scene2.obj
rename to tests/gdx-tests-jogl/data/scene2.obj
diff --git a/tests/gdx-tests-desktop/data/shotgun.wav b/tests/gdx-tests-jogl/data/shotgun.wav
similarity index 100%
rename from tests/gdx-tests-desktop/data/shotgun.wav
rename to tests/gdx-tests-jogl/data/shotgun.wav
diff --git a/tests/gdx-tests-desktop/data/stones.jpg b/tests/gdx-tests-jogl/data/stones.jpg
similarity index 100%
rename from tests/gdx-tests-desktop/data/stones.jpg
rename to tests/gdx-tests-jogl/data/stones.jpg
diff --git a/tests/gdx-tests-desktop/data/test.p b/tests/gdx-tests-jogl/data/test.p
similarity index 100%
rename from tests/gdx-tests-desktop/data/test.p
rename to tests/gdx-tests-jogl/data/test.p
diff --git a/tests/gdx-tests-desktop/data/test.png b/tests/gdx-tests-jogl/data/test.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/test.png
rename to tests/gdx-tests-jogl/data/test.png
diff --git a/tests/gdx-tests-desktop/data/threeofaperfectpair.mp3 b/tests/gdx-tests-jogl/data/threeofaperfectpair.mp3
similarity index 100%
rename from tests/gdx-tests-desktop/data/threeofaperfectpair.mp3
rename to tests/gdx-tests-jogl/data/threeofaperfectpair.mp3
diff --git a/tests/gdx-tests-desktop/data/ui.png b/tests/gdx-tests-jogl/data/ui.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/ui.png
rename to tests/gdx-tests-jogl/data/ui.png
diff --git a/tests/gdx-tests-desktop/data/verdana39.fnt b/tests/gdx-tests-jogl/data/verdana39.fnt
similarity index 100%
rename from tests/gdx-tests-desktop/data/verdana39.fnt
rename to tests/gdx-tests-jogl/data/verdana39.fnt
diff --git a/tests/gdx-tests-desktop/data/verdana39.png b/tests/gdx-tests-jogl/data/verdana39.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/verdana39.png
rename to tests/gdx-tests-jogl/data/verdana39.png
diff --git a/tests/gdx-tests-desktop/data/villager.png b/tests/gdx-tests-jogl/data/villager.png
similarity index 100%
rename from tests/gdx-tests-desktop/data/villager.png
rename to tests/gdx-tests-jogl/data/villager.png
diff --git a/tests/gdx-tests-desktop/data/walk1.md5anim b/tests/gdx-tests-jogl/data/walk1.md5anim
similarity index 100%
rename from tests/gdx-tests-desktop/data/walk1.md5anim
rename to tests/gdx-tests-jogl/data/walk1.md5anim
diff --git a/tests/gdx-tests-desktop/data/zfat.md5mesh b/tests/gdx-tests-jogl/data/zfat.md5mesh
similarity index 100%
rename from tests/gdx-tests-desktop/data/zfat.md5mesh
rename to tests/gdx-tests-jogl/data/zfat.md5mesh
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
index 000000000..9a18a98a2
--- /dev/null
+++ b/tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglDebugStarter.java
@@ -0,0 +1,10 @@
+package com.badlogic.gdx.tests.jogl;
+
+import com.badlogic.gdx.backends.jogl.JoglApplication;
+
+public class JoglDebugStarter {
+
+ public static void main( String[] argv ) {
+ new JoglApplication( new com.badlogic.gdx.tests.VertexBufferObjectShaderTest(), "Debug Test", 480, 320, true );
+ }
+}
diff --git a/tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglTestStarter.java b/tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglTestStarter.java
similarity index 81%
rename from tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglTestStarter.java
rename to tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglTestStarter.java
index e7d6ab06d..512c50081 100644
--- a/tests/gdx-tests-desktop/src/com/badlogic/gdx/tests/desktop/JoglTestStarter.java
+++ b/tests/gdx-tests-jogl/src/com/badlogic/gdx/tests/jogl/JoglTestStarter.java
@@ -1,5 +1,5 @@
-package com.badlogic.gdx.tests.desktop;
+package com.badlogic.gdx.tests.jogl;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
@@ -14,10 +14,8 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import com.badlogic.gdx.backends.desktop.JoglApplication;
+import com.badlogic.gdx.backends.jogl.JoglApplication;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.tests.utils.GdxTests;
@@ -45,8 +43,7 @@ public class JoglTestStarter {
@Override public void actionPerformed (ActionEvent e) {
String testName = (String)list.getSelectedValue();
GdxTest test = GdxTests.newTest(testName);
- JoglApplication app = new JoglApplication(testName, 480, 320, test.needsGL20());
- app.getGraphics().setRenderListener(test);
+ new JoglApplication(test, testName, 480, 320, test.needsGL20());
}
});
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/AlphaTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/AlphaTest.java
index abbf20c5f..c09f898f7 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/AlphaTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/AlphaTest.java
@@ -2,25 +2,30 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
-import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.SpriteBatch;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class AlphaTest implements GdxTest {
+public class AlphaTest extends GdxTest {
SpriteBatch batch;
- Texture texture;
+ Texture texture;
- @Override public void dispose () {
+ @Override public void create () {
+ Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);
+ pixmap.setColor(0, 1, 0, 0.7f);
+ pixmap.fill();
+ texture = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
+ batch = new SpriteBatch();
}
-
+
@Override public void render () {
Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
@@ -29,21 +34,6 @@ public class AlphaTest implements GdxTest {
batch.end();
}
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceCreated () {
- Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);
- pixmap.setColor(0, 1, 0, 0.7f);
- pixmap.fill();
-
- texture = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
- TextureWrap.ClampToEdge);
- batch = new SpriteBatch();
- }
-
@Override public boolean needsGL20 () {
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioDeviceTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioDeviceTest.java
index aeae5dec2..132ee0678 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioDeviceTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioDeviceTest.java
@@ -14,35 +14,14 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.audio.AudioDevice;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class AudioDeviceTest implements GdxTest {
+public class AudioDeviceTest extends GdxTest {
Thread thread;
boolean stop = false;
- @Override public void dispose () {
- stop = true;
- try {
- thread.join();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Override public void render () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceCreated () {
+ @Override public void create () {
if (thread == null) {
final AudioDevice device = Gdx.app.getAudio().newAudioDevice(false);
thread = new Thread(new Runnable() {
@@ -68,6 +47,16 @@ public class AudioDeviceTest implements GdxTest {
thread.start();
}
}
+
+ @Override public void destroy () {
+ stop = true;
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
@Override public boolean needsGL20 () {
// TODO Auto-generated method stub
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioRecorderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioRecorderTest.java
index 2477ac7f8..ae3a580fa 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioRecorderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/AudioRecorderTest.java
@@ -21,34 +21,13 @@ import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.ImmediateModeRenderer;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class AudioRecorderTest implements GdxTest, ApplicationListener {
+public class AudioRecorderTest extends GdxTest {
short[] samples = new short[1024 * 4];
AudioDevice device;
AudioRecorder recorder;
ImmediateModeRenderer renderer;
- @Override public void dispose () {
-
- }
-
- @Override public void render () {
- GL10 gl = Gdx.graphics.getGL10();
- gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
-
-// float incX = 2.0f / samples.length;
-// float x = -1;
-// renderer.begin( GL10.GL_LINE_STRIP );
-// for( int i = 0; i < samples.length/100; i++, x+=incX )
-// renderer.vertex( x, samples[i] / (float)Short.MAX_VALUE, 0 );
-// renderer.end();
- }
-
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void surfaceCreated () {
+ @Override public void create () {
device = Gdx.audio.newAudioDevice(true);
recorder = Gdx.audio.newAudioRecoder(44100, true);
renderer = new ImmediateModeRenderer();
@@ -63,14 +42,20 @@ public class AudioRecorderTest implements GdxTest, ApplicationListener {
}
});
t.setDaemon(true);
- t.start();
-
- Gdx.app.setApplicationListener(this);
+ t.start();
}
+
+ @Override public void render () {
+ GL10 gl = Gdx.graphics.getGL10();
+ gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
- @Override public void destroy () {
- // TODO Auto-generated method stub
-
+// float incX = 2.0f / samples.length;
+// float x = -1;
+// renderer.begin( GL10.GL_LINE_STRIP );
+// for( int i = 0; i < samples.length/100; i++, x+=incX )
+// renderer.vertex( x, samples[i] / (float)Short.MAX_VALUE, 0 );
+// renderer.end();
}
@Override public void pause () {
@@ -84,7 +69,6 @@ public class AudioRecorderTest implements GdxTest, ApplicationListener {
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontFlipTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontFlipTest.java
index ef399a4d8..944636fdd 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontFlipTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontFlipTest.java
@@ -3,6 +3,7 @@ package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.BitmapFont;
import com.badlogic.gdx.graphics.BitmapFontCache;
@@ -16,7 +17,7 @@ import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class BitmapFontFlipTest implements GdxTest {
+public class BitmapFontFlipTest extends GdxTest {
private SpriteBatch spriteBatch;
private BitmapFont font;
private Sprite logoSprite;
@@ -24,8 +25,10 @@ public class BitmapFontFlipTest implements GdxTest {
private BitmapFontCache cache1, cache2, cache3, cache4, cache5;
int renderMode;
private float alpha;
+ private InputProcessor inputProcessor;
- public void surfaceCreated () {
+ @Override
+ public void create () {
if (spriteBatch != null) return;
spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
@@ -39,12 +42,12 @@ public class BitmapFontFlipTest implements GdxTest {
font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle(
"data/verdana39.png", FileType.Internal), true);
- Gdx.input.addInputListener(new InputAdapter() {
+ inputProcessor = new InputAdapter() {
public boolean touchDown (int x, int y, int pointer) {
renderMode = (renderMode + 1) % 2;
return false;
}
- });
+ };
cache1 = new BitmapFontCache(font);
cache2 = new BitmapFontCache(font);
@@ -67,9 +70,7 @@ public class BitmapFontFlipTest implements GdxTest {
cache5.setWrappedText(text, 0, 320 - 270, red, 480, HAlignment.CENTER);
}
- public void surfaceChanged (int width, int height) {
- }
-
+ @Override
public void render () {
alpha = (alpha + Gdx.graphics.getDeltaTime() * 0.1f) % 1;
@@ -86,6 +87,8 @@ public class BitmapFontFlipTest implements GdxTest {
break;
}
spriteBatch.end();
+
+ Gdx.input.processEvents(inputProcessor);
}
private void renderNormal () {
@@ -121,9 +124,6 @@ public class BitmapFontFlipTest implements GdxTest {
cache4.draw(spriteBatch);
}
- public void dispose () {
- }
-
public boolean needsGL20 () {
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontTest.java
index 0e7899c1f..cc27ce357 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/BitmapFontTest.java
@@ -3,6 +3,7 @@ package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.BitmapFont;
import com.badlogic.gdx.graphics.BitmapFontCache;
@@ -15,7 +16,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class BitmapFontTest implements GdxTest {
+public class BitmapFontTest extends GdxTest {
private SpriteBatch spriteBatch;
private BitmapFont font;
private Sprite logoSprite;
@@ -23,8 +24,10 @@ public class BitmapFontTest implements GdxTest {
private BitmapFontCache cache1, cache2, cache3, cache4, cache5;
int renderMode;
private float alpha;
+ InputProcessor inputProcessor;
- public void surfaceCreated () {
+ @Override
+ public void create () {
if (spriteBatch != null) return;
spriteBatch = new SpriteBatch();
@@ -35,12 +38,12 @@ public class BitmapFontTest implements GdxTest {
font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle(
"data/verdana39.png", FileType.Internal), false);
- Gdx.input.addInputListener(new InputAdapter() {
+ inputProcessor = new InputAdapter() {
public boolean touchDown (int x, int y, int pointer) {
renderMode = (renderMode + 1) % 2;
return false;
}
- });
+ };
cache1 = new BitmapFontCache(font);
cache2 = new BitmapFontCache(font);
@@ -63,9 +66,7 @@ public class BitmapFontTest implements GdxTest {
cache5.setWrappedText(text, 0, 270, red, 480, HAlignment.CENTER);
}
- public void surfaceChanged (int width, int height) {
- }
-
+ @Override
public void render () {
alpha = (alpha + Gdx.graphics.getDeltaTime() * 0.1f) % 1;
@@ -82,6 +83,8 @@ public class BitmapFontTest implements GdxTest {
break;
}
spriteBatch.end();
+
+ Gdx.input.processEvents(inputProcessor);
}
private void renderNormal () {
@@ -117,9 +120,6 @@ public class BitmapFontTest implements GdxTest {
cache4.draw(spriteBatch);
}
- public void dispose () {
- }
-
public boolean needsGL20 () {
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTest.java
index c965b8ce5..b22ad34fa 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTest.java
@@ -16,7 +16,7 @@ package com.badlogic.gdx.tests;
import java.util.ArrayList;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.BitmapFont;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
@@ -38,7 +38,7 @@ import com.badlogic.gdx.physics.box2d.joints.MouseJoint;
import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class Box2DTest implements GdxTest, InputListener {
+public class Box2DTest extends GdxTest implements InputProcessor {
/** the camera **/
private OrthographicCamera camera;
@@ -64,7 +64,7 @@ public class Box2DTest implements GdxTest, InputListener {
/** a hit body **/
private Body hitBody = null;
- @Override public void surfaceCreated () {
+ @Override public void create () {
// setup the camera. In Box2D we operate on a
// meter scale, pixels won't do it. So we use
// an orthographic camera with a viewport of
@@ -85,10 +85,6 @@ public class Box2DTest implements GdxTest, InputListener {
// next we create out physics world.
createPhysicsWorld();
-
- // finally we register ourselfs as an InputListener so we
- // can manipulate our world
- Gdx.input.addInputListener(this);
}
private void createPhysicsWorld () {
@@ -208,6 +204,9 @@ public class Box2DTest implements GdxTest, InputListener {
font.draw( batch, "fps: " + Gdx.graphics.getFramesPerSecond() + " update time: " + updateTime, 0,
20, Color.RED);
batch.end();
+
+ // process the input events
+ Gdx.input.processEvents(this);
}
private void renderBox (GL10 gl, Body body, float halfWidth, float halfHeight) {
@@ -310,17 +309,18 @@ public class Box2DTest implements GdxTest, InputListener {
return false;
}
+ @Override public void destroy () {
+ world.dispose();
+ }
+
+ @Override public boolean needsGL20 () {
+ return false;
+ }
+
// ---------------------------------------------------------------
// STUBS FOR UNIMPLEMENTED INTERFACE METHODS, NOTHING TO SEE HERE
// MOVE ALONG
// ---------------------------------------------------------------
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void dispose () {
- world.dispose();
- }
@Override public boolean keyDown (int keycode) {
return false;
@@ -333,9 +333,4 @@ public class Box2DTest implements GdxTest, InputListener {
@Override public boolean keyUp (int keycode) {
return false;
}
-
- @Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
- return false;
- }
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTestCollection.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTestCollection.java
index 905f0be3b..94a850000 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTestCollection.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Box2DTestCollection.java
@@ -15,7 +15,7 @@ package com.badlogic.gdx.tests;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.tests.box2d.ApplyForce;
import com.badlogic.gdx.tests.box2d.BodyTypes;
@@ -36,7 +36,7 @@ import com.badlogic.gdx.tests.box2d.VaryingRestitution;
import com.badlogic.gdx.tests.box2d.VerticalStack;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class Box2DTestCollection implements GdxTest, InputListener {
+public class Box2DTestCollection extends GdxTest implements InputProcessor {
private final Box2DTest[] tests = {new DebugRendererTest(), new CollisionFiltering(), new Chain(), new Bridge(),
new SphereStack(), new Cantilever(), new ApplyForce(), new ContinuousTest(), new Prismatic(), new CharacterCollision(),
new BodyTypes(), new SimpleTest(), new Pyramid(), new OneSidedPlatform(), new VerticalStack(), new VaryingRestitution()};
@@ -45,69 +45,64 @@ public class Box2DTestCollection implements GdxTest, InputListener {
private Application app = null;
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
@Override public void render () {
tests[testIndex].render();
+ Gdx.input.processEvents(this);
}
- @Override public void surfaceChanged (int width, int height) {
- }
-
- @Override public void surfaceCreated () {
+ @Override public void create () {
if (this.app == null) {
this.app = Gdx.app;
Box2DTest test = tests[testIndex];
- test.surfaceCreated();
- app.getInput().addInputListener(this);
+ test.create();
}
}
@Override public boolean keyDown (int keycode) {
if (keycode == Keys.KEYCODE_SPACE) {
app.log("TestCollection", "disposing test '" + tests[testIndex].getClass().getName());
- tests[testIndex].dispose();
+ tests[testIndex].destroy();
testIndex++;
if (testIndex >= tests.length) testIndex = 0;
Box2DTest test = tests[testIndex];
- test.surfaceCreated();
+ test.create();
app.log("TestCollection", "created test '" + tests[testIndex].getClass().getName());
}
+ else {
+ tests[testIndex].keyDown(keycode);
+ }
return false;
}
@Override public boolean keyTyped (char character) {
- // TODO Auto-generated method stub
+ tests[testIndex].keyTyped(character);
return false;
}
@Override public boolean keyUp (int keycode) {
- // TODO Auto-generated method stub
+ tests[testIndex].keyUp(keycode);
return false;
}
@Override public boolean touchDown (int x, int y, int pointer) {
- // TODO Auto-generated method stub
+ tests[testIndex].touchDown(x, y, pointer);
return false;
}
@Override public boolean touchDragged (int x, int y, int pointer) {
- // TODO Auto-generated method stub
+ tests[testIndex].touchDragged(x, y, pointer);
return false;
}
@Override public boolean touchUp (int x, int y, int pointer) {
- // TODO Auto-generated method stub
+ tests[testIndex].touchUp(x, y, pointer);
return false;
}
@Override
public boolean needsGL20() {
- // TODO Auto-generated method stub
return false;
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/FillrateTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/FillrateTest.java
index 68940e967..dfc01cbee 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/FillrateTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/FillrateTest.java
@@ -1,8 +1,7 @@
-
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
@@ -13,7 +12,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class FillrateTest implements GdxTest, InputListener {
+public class FillrateTest extends GdxTest implements InputProcessor {
Texture texture;
Mesh mesh;
int numFills = 1;
@@ -23,50 +22,48 @@ public class FillrateTest implements GdxTest, InputListener {
float mean = 0;
float frames = 0;
- @Override public void surfaceCreated () {
- if (texture == null) {
- Gdx.input.addInputListener(this);
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal),
- TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- mesh = new Mesh(true, 4, 6, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_pos"),
- new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords"));
-
- float[] vertices = new float[4 * 4];
-
- int idx = 0;
- vertices[idx++] = -1;
- vertices[idx++] = -1;
- vertices[idx++] = 0;
- vertices[idx++] = 0;
-
- vertices[idx++] = -1;
- vertices[idx++] = 1;
- vertices[idx++] = 0;
- vertices[idx++] = 1;
-
- vertices[idx++] = 1;
- vertices[idx++] = 1;
- vertices[idx++] = 1;
- vertices[idx++] = 1;
-
- vertices[idx++] = 1;
- vertices[idx++] = -1;
- vertices[idx++] = 1;
- vertices[idx++] = 0;
-
- short[] indices = {0, 1, 2, 2, 3, 0};
- mesh.setVertices(vertices);
- mesh.setIndices(indices);
- }
+ @Override
+ public void create() {
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/badlogicsmall.jpg", FileType.Internal),
+ TextureFilter.Linear, TextureFilter.Linear,
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+
+ mesh = new Mesh(true, 4, 6, new VertexAttribute(
+ VertexAttributes.Usage.Position, 2, "a_pos"),
+ new VertexAttribute(VertexAttributes.Usage.TextureCoordinates,
+ 2, "a_texCoords"));
+
+ float[] vertices = new float[4 * 4];
+
+ int idx = 0;
+ vertices[idx++] = -1;
+ vertices[idx++] = -1;
+ vertices[idx++] = 0;
+ vertices[idx++] = 0;
+
+ vertices[idx++] = -1;
+ vertices[idx++] = 1;
+ vertices[idx++] = 0;
+ vertices[idx++] = 1;
+
+ vertices[idx++] = 1;
+ vertices[idx++] = 1;
+ vertices[idx++] = 1;
+ vertices[idx++] = 1;
+
+ vertices[idx++] = 1;
+ vertices[idx++] = -1;
+ vertices[idx++] = 1;
+ vertices[idx++] = 0;
+
+ short[] indices = { 0, 1, 2, 2, 3, 0 };
+ mesh.setVertices(vertices);
+ mesh.setIndices(indices);
}
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void render () {
+ @Override
+ public void render() {
Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
if (mode == 3) {
@@ -76,7 +73,8 @@ public class FillrateTest implements GdxTest, InputListener {
if (mode == 2) {
Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);
- Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
+ Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA,
+ GL10.GL_ONE_MINUS_SRC_ALPHA);
}
if (mode >= 1) {
@@ -98,54 +96,63 @@ public class FillrateTest implements GdxTest, InputListener {
mean += numFills;
frames++;
- if (Gdx.graphics.getDeltaTime() < 1 / 60f) numFills++;
+ if (Gdx.graphics.getDeltaTime() < 1 / 60f)
+ numFills++;
if (System.nanoTime() - lastOut >= 1000000000) {
- Gdx.app.log("FillrateTest", "fills: " + mean / frames + ", fps: " + frames + ", mode" + mode);
+ Gdx.app.log("FillrateTest", "fills: " + mean / frames + ", fps: "
+ + frames + ", mode" + mode);
mean = 0;
frames = 0;
lastOut = System.nanoTime();
- if (Gdx.graphics.getFramesPerSecond() < 60) numFills--;
+ if (Gdx.graphics.getFramesPerSecond() < 60)
+ numFills--;
}
+
+ Gdx.input.processEvents(this);
}
- @Override public void dispose () {
-
- }
-
- @Override public boolean keyDown (int keycode) {
+ @Override
+ public boolean keyDown(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyUp (int keycode) {
+ @Override
+ public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyTyped (char character) {
+ @Override
+ public boolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean touchDown (int x, int y, int pointer) {
+ @Override
+ public boolean touchDown(int x, int y, int pointer) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean touchUp (int x, int y, int pointer) {
+ @Override
+ public boolean touchUp(int x, int y, int pointer) {
mode++;
- if (mode > 3) mode = 0;
+ if (mode > 3)
+ mode = 0;
numFills = 0;
return false;
}
- @Override public boolean touchDragged (int x, int y, int pointer) {
+ @Override
+ public boolean touchDragged(int x, int y, int pointer) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/FloatTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/FloatTest.java
index a3660e254..183a087e5 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/FloatTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/FloatTest.java
@@ -26,7 +26,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class FloatTest implements GdxTest {
+public class FloatTest extends GdxTest {
Texture tex;
Texture tex2;
@@ -35,7 +35,7 @@ public class FloatTest implements GdxTest {
float angle = 0;
float angleIncrement = 0.1f;
- @Override public void dispose () {
+ @Override public void destroy () {
tex.dispose();
tex2.dispose();
}
@@ -75,7 +75,7 @@ public class FloatTest implements GdxTest {
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
}
- @Override public void surfaceCreated () {
+ private void init() {
if (tex != null) {
tex.dispose();
tex2.dispose();
@@ -110,10 +110,13 @@ public class FloatTest implements GdxTest {
tex2 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
TextureWrap.ClampToEdge);
}
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
+
+ @Override public void create () {
+ init();
+ }
+
+ @Override public void resume() {
+ init();
}
@Override public boolean needsGL20 () {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/FrameBufferTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/FrameBufferTest.java
index e13654fae..2acf9d82e 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/FrameBufferTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/FrameBufferTest.java
@@ -30,17 +30,13 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class FrameBufferTest implements GdxTest {
+public class FrameBufferTest extends GdxTest {
FrameBuffer frameBuffer;
Mesh mesh;
ShaderProgram meshShader;
Texture texture;
SpriteBatch spriteBatch;
- @Override public void dispose () {
-
- }
-
@Override public void render () {
frameBuffer.begin();
Gdx.graphics.getGL20().glViewport(0, 0, frameBuffer.getWidth(), frameBuffer.getHeight());
@@ -64,29 +60,23 @@ public class FrameBufferTest implements GdxTest {
spriteBatch.end();
}
- @Override public void surfaceChanged (int width, int height) {
+ @Override public void create () {
+ mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(
+ Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
+ float c1 = Color.toFloatBits(255, 0, 0, 255);
+ float c2 = Color.toFloatBits(255, 0, 0, 255);
+ ;
+ float c3 = Color.toFloatBits(0, 0, 255, 255);
+ ;
- }
+ 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});
+
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- @Override public void surfaceCreated () {
- if (mesh == null) {
- mesh = new Mesh(true, 3, 0, new VertexAttribute(Usage.Position, 3, "a_Position"), new VertexAttribute(
- Usage.ColorPacked, 4, "a_Color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
- float c1 = Color.toFloatBits(255, 0, 0, 255);
- float c2 = Color.toFloatBits(255, 0, 0, 255);
- ;
- float c3 = Color.toFloatBits(0, 0, 255, 255);
- ;
-
- 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});
-
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- spriteBatch = new SpriteBatch();
- frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, true);
- createShader(Gdx.graphics);
- }
+ spriteBatch = new SpriteBatch();
+ frameBuffer = new FrameBuffer(Format.RGB565, 128, 128, true);
+ createShader(Gdx.graphics);
}
private void createShader (Graphics graphics) {
@@ -106,7 +96,6 @@ public class FrameBufferTest implements GdxTest {
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return true;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ImmediateModeRendererTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ImmediateModeRendererTest.java
index a83081d2f..a27f37205 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ImmediateModeRendererTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ImmediateModeRendererTest.java
@@ -13,9 +13,8 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.ImmediateModeRenderer;
import com.badlogic.gdx.graphics.Texture;
@@ -23,11 +22,11 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class ImmediateModeRendererTest implements GdxTest {
+public class ImmediateModeRendererTest extends GdxTest {
ImmediateModeRenderer renderer;
Texture texture;
- @Override public void dispose () {
+ @Override public void destroy () {
texture.dispose();
}
@@ -48,19 +47,13 @@ public class ImmediateModeRendererTest implements GdxTest {
renderer.end();
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void surfaceCreated () {
+ @Override public void create () {
renderer = new ImmediateModeRenderer();
-
texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectClassTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectClassTest.java
index a3ee9805d..a2dab6d24 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectClassTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectClassTest.java
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class IndexBufferObjectClassTest implements GdxTest {
+public class IndexBufferObjectClassTest extends GdxTest {
Texture texture;
VertexBufferObject vbo;
IndexBufferObject ibo;
@@ -26,7 +26,7 @@ public class IndexBufferObjectClassTest implements GdxTest {
}
@Override
- public void dispose() {
+ public void destroy() {
texture.dispose();
vbo.dispose();
ibo.dispose();
@@ -48,13 +48,7 @@ public class IndexBufferObjectClassTest implements GdxTest {
}
@Override
- public void surfaceChanged(int width, int height) {
-
- }
-
- @Override
- public void surfaceCreated() {
- if( texture == null ) {
+ public void create() {
vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),
new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),
new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));
@@ -68,9 +62,12 @@ public class IndexBufferObjectClassTest implements GdxTest {
texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),
TextureFilter.Linear, TextureFilter.Linear,
- TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- }
- else
- vbo.invalidate();
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ }
+
+ @Override
+ public void resume() {
+ vbo.invalidate();
+ ibo.invalidate();
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectShaderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectShaderTest.java
index b32976b39..d65f4a31d 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectShaderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/IndexBufferObjectShaderTest.java
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class IndexBufferObjectShaderTest implements GdxTest {
+public class IndexBufferObjectShaderTest extends GdxTest {
Texture texture;
ShaderProgram shader;
VertexBufferObject vbo;
@@ -27,7 +27,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
}
@Override
- public void dispose() {
+ public void destroy() {
texture.dispose();
shader.dispose();
ibo.dispose();
@@ -35,6 +35,8 @@ public class IndexBufferObjectShaderTest implements GdxTest {
@Override
public void render() {
+// System.out.println( "render");
+
GL20 gl = Gdx.gl20;
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
@@ -43,7 +45,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
shader.begin();
shader.setUniformi("u_texture", 0);
texture.bind();
- vbo.bind(shader);
+ vbo.bind(shader);
ibo.bind();
gl.glDrawElements(GL20.GL_TRIANGLES, 3, GL20.GL_UNSIGNED_SHORT, 0);
ibo.unbind();
@@ -52,13 +54,7 @@ public class IndexBufferObjectShaderTest implements GdxTest {
}
@Override
- public void surfaceChanged(int width, int height) {
-
- }
-
- @Override
- public void surfaceCreated() {
- if (texture == null) {
+ public void create() {
String vertexShader = "attribute vec4 a_position; \n"
+ "attribute vec4 a_color;\n"
+ "attribute vec2 a_texCoords;\n"
@@ -96,8 +92,16 @@ public class IndexBufferObjectShaderTest implements GdxTest {
"data/badlogic.jpg", FileType.Internal),
TextureFilter.Linear, TextureFilter.Linear,
TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- } else
- vbo.invalidate();
+
+// System.out.println( "create");
+ }
+
+ @Override
+ public void resume() {
+ vbo.invalidate();
+ ibo.invalidate();
+
+// System.out.println( "resume");
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/InputTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/InputTest.java
index 14fae306f..36a1dea12 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/InputTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/InputTest.java
@@ -14,28 +14,13 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class InputTest implements GdxTest, InputListener {
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
+public class InputTest extends GdxTest implements InputProcessor {
@Override public void render () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceCreated () {
- Gdx.input.addInputListener(this);
+ Gdx.input.processEvents(this);
}
@Override public boolean keyDown (int keycode) {
@@ -69,7 +54,6 @@ public class InputTest implements GdxTest, InputListener {
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/LifeCycleTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/LifeCycleTest.java
index 1a7d3d7a1..0459c4afc 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/LifeCycleTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/LifeCycleTest.java
@@ -13,19 +13,17 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.tests.utils.GdxTest;
/**
- * A simple test to demonstrate the life cycle of an application and a RenderListener.
+ * A simple test to demonstrate the life cycle of an application.
*
* @author mzechner
*
*/
-public class LifeCycleTest implements ApplicationListener, GdxTest {
+public class LifeCycleTest extends GdxTest {
@Override public void destroy () {
Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app destroyed");
@@ -39,27 +37,16 @@ public class LifeCycleTest implements ApplicationListener, GdxTest {
Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app resumed");
}
- @Override public void dispose () {
- Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer disposed");
- }
-
@Override public void render () {
Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
- }
-
- @Override public void surfaceChanged (int width, int height) {
- Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer surface changed: " + Gdx.graphics.getWidth()
- + "x" + Gdx.graphics.getHeight());
- }
+ }
- @Override public void surfaceCreated () {
- Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", renderer surface created: " + Gdx.graphics.getWidth()
- + "x" + Gdx.graphics.getHeight());
- System.out.println(Gdx.graphics.getGL10().glGetString(GL10.GL_VERSION));
+ @Override public void create () {
+ Gdx.app.log("Test", "Thread=" + Thread.currentThread().getId() + ", app created: " + Gdx.graphics.getWidth()
+ + "x" + Gdx.graphics.getHeight());
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/MD5Test.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/MD5Test.java
index fe735c21d..9386eccbd 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/MD5Test.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/MD5Test.java
@@ -1,8 +1,7 @@
-
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.BitmapFont;
import com.badlogic.gdx.graphics.Color;
@@ -17,7 +16,7 @@ import com.badlogic.gdx.graphics.loaders.md5.MD5Model;
import com.badlogic.gdx.graphics.loaders.md5.MD5Renderer;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class MD5Test implements GdxTest, InputListener {
+public class MD5Test extends GdxTest implements InputProcessor {
PerspectiveCamera camera;
MD5Model model;
MD5Animation anim;
@@ -27,44 +26,43 @@ public class MD5Test implements GdxTest, InputListener {
SpriteBatch batch;
BitmapFont font;
- @Override public void surfaceCreated () {
- if (model == null) {
-
- Gdx.app.log("MD5 Test", "created");
- model = MD5Loader.loadModel(Gdx.files.readFile("data/zfat.md5mesh", FileType.Internal));
- anim = MD5Loader.loadAnimation(Gdx.files.readFile("data/walk1.md5anim", FileType.Internal));
- skeleton = new MD5Joints();
- skeleton.joints = new float[anim.frames[0].joints.length];
- animInfo = new MD5AnimationInfo(anim.frames.length, anim.secondsPerFrame);
- renderer = new MD5Renderer(model, true);
- renderer.setSkeleton(model.baseSkeleton);
-
- // long start = System.nanoTime();
- // for( int i = 0; i < 100000; i++ )
- // renderer.setSkeleton( model.baseSkeleton );
- // app.log( "MD5 Test", "took: " + (System.nanoTime() - start ) / 1000000000.0 );
-
- camera = new PerspectiveCamera();
- camera.getPosition().set(0, 25, 100);
- camera.setFov(60);
- camera.setNear(1);
- camera.setFar(1000);
- camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
-
- batch = new SpriteBatch();
- font = new BitmapFont();
- Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- Gdx.input.addInputListener(this);
- }
- }
-
- @Override public void surfaceChanged (int width, int height) {
-
+ @Override
+ public void create() {
+ Gdx.app.log("MD5 Test", "created");
+ model = MD5Loader.loadModel(Gdx.files.readFile("data/zfat.md5mesh",
+ FileType.Internal));
+ anim = MD5Loader.loadAnimation(Gdx.files.readFile("data/walk1.md5anim",
+ FileType.Internal));
+ skeleton = new MD5Joints();
+ skeleton.joints = new float[anim.frames[0].joints.length];
+ animInfo = new MD5AnimationInfo(anim.frames.length,
+ anim.secondsPerFrame);
+ renderer = new MD5Renderer(model, true);
+ renderer.setSkeleton(model.baseSkeleton);
+
+ // long start = System.nanoTime();
+ // for( int i = 0; i < 100000; i++ )
+ // renderer.setSkeleton( model.baseSkeleton );
+ // app.log( "MD5 Test", "took: " + (System.nanoTime() - start ) /
+ // 1000000000.0 );
+
+ camera = new PerspectiveCamera();
+ camera.getPosition().set(0, 25, 100);
+ camera.setFov(60);
+ camera.setNear(1);
+ camera.setFar(1000);
+ camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+
+ batch = new SpriteBatch();
+ font = new BitmapFont();
+ Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(),
+ Gdx.graphics.getHeight());
}
float angle = 0;
- @Override @SuppressWarnings("unused") public void render () {
+ @Override
+ public void render() {
GL10 gl = Gdx.graphics.getGL10();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
@@ -73,7 +71,6 @@ public class MD5Test implements GdxTest, InputListener {
animInfo.update(Gdx.graphics.getDeltaTime());
gl.glEnable(GL10.GL_DEPTH_TEST);
-// gl.glPolygonMode( GL10.GL_FRONT_AND_BACK, GL10.GL_LINE );
long start = 0;
float renderTime = 0;
@@ -86,8 +83,9 @@ public class MD5Test implements GdxTest, InputListener {
gl.glRotatef(-90, 1, 0, 0);
start = System.nanoTime();
- MD5Animation.interpolate(anim.frames[animInfo.getCurrentFrame()], anim.frames[animInfo.getNextFrame()], skeleton,
- animInfo.getInterpolation());
+ MD5Animation.interpolate(anim.frames[animInfo.getCurrentFrame()],
+ anim.frames[animInfo.getNextFrame()], skeleton, animInfo
+ .getInterpolation());
renderer.setSkeleton(skeleton);
skinTime = (System.nanoTime() - start) / 1000000000.0f;
@@ -97,58 +95,67 @@ public class MD5Test implements GdxTest, InputListener {
}
gl.glDisable(GL10.GL_DEPTH_TEST);
-// gl.glPolygonMode( GL10.GL_FRONT_AND_BACK, GL10.GL_FILL );
+
batch.begin();
- font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond() + (renderer.isJniUsed() ? ", jni" : ", java"), 10, 20,
+ font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond()
+ + (renderer.isJniUsed() ? ", jni" : ", java"), 10, 20,
Color.WHITE);
batch.end();
+
+ Gdx.input.processEvents(this);
}
- @Override public void dispose () {
+ @Override
+ public void destroy() {
batch.dispose();
renderer.dispose();
-// font.dispose();
+ font.dispose();
batch = null;
renderer = null;
-// font = null;
+ font = null;
System.gc();
-
- Gdx.input.removeInputListener(this);
}
- @Override public boolean keyDown (int keycode) {
+ @Override
+ public boolean keyDown(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyTyped (char character) {
+ @Override
+ public boolean keyTyped(char character) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyUp (int keycode) {
+ @Override
+ public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean touchDown (int x, int y, int pointer) {
+ @Override
+ public boolean touchDown(int x, int y, int pointer) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean touchDragged (int x, int y, int pointer) {
+ @Override
+ public boolean touchDragged(int x, int y, int pointer) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean touchUp (int x, int y, int pointer) {
+ @Override
+ public boolean touchUp(int x, int y, int pointer) {
renderer.setUseJni(!renderer.isJniUsed());
return false;
}
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ManagedTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ManagedTest.java
index 687e0e3d1..f4c7dcdfa 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ManagedTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ManagedTest.java
@@ -13,32 +13,29 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
-import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class ManagedTest implements GdxTest {
+public class ManagedTest extends GdxTest {
Mesh mesh;
Texture texture;
- @Override public void surfaceCreated () {
- if (mesh == null) {
- mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(
- Usage.TextureCoordinates, 2, "a_texCoord"));
- 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});
- mesh.setIndices(new short[] {0, 1, 2, 3});
+ @Override public void create () {
+ mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(
+ Usage.TextureCoordinates, 2, "a_texCoord"));
+ 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});
+ mesh.setIndices(new short[] {0, 1, 2, 3});
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- }
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
}
@Override public void render () {
@@ -52,16 +49,7 @@ public class ManagedTest implements GdxTest {
mesh.render(GL10.GL_TRIANGLE_FAN);
}
- @Override public void dispose () {
-
- }
-
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
+ @Override public boolean needsGL20 () {
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ManualBindTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ManualBindTest.java
index b310ff224..e15efd3fd 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ManualBindTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ManualBindTest.java
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class ManualBindTest implements GdxTest {
+public class ManualBindTest extends GdxTest {
int vboHandle;
int iboHandle;
ShortBuffer indices;
@@ -28,11 +28,6 @@ public class ManualBindTest implements GdxTest {
}
@Override
- public void dispose() {
-
- }
-
- @Override
public void render() {
GL11 gl = Gdx.gl11;
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -43,8 +38,8 @@ public class ManualBindTest implements GdxTest {
gl.glEnableClientState(GL11.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL11.GL_FLOAT, 5 * 4, 0);
- gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 4, null, GL11.GL_DYNAMIC_DRAW);
- gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 4, indices, GL11.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 2, null, GL11.GL_DYNAMIC_DRAW);
+ gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, indices.limit() * 2, indices, GL11.GL_DYNAMIC_DRAW);
gl.glBufferData(GL11.GL_ARRAY_BUFFER, vertices1.limit() * 4, null, GL11.GL_DYNAMIC_DRAW);
gl.glBufferData(GL11.GL_ARRAY_BUFFER, vertices1.limit() * 4, vertices1, GL11.GL_DYNAMIC_DRAW);
gl.glDrawElements(GL11.GL_TRIANGLES, 12, GL11.GL_UNSIGNED_SHORT, 0);
@@ -58,13 +53,7 @@ public class ManualBindTest implements GdxTest {
}
@Override
- public void surfaceChanged(int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void surfaceCreated() {
+ public void create() {
GL11 gl = Gdx.graphics.getGL11();
IntBuffer handleBuf = BufferUtils.newIntBuffer(2);
gl.glGenBuffers(2, handleBuf);
@@ -93,5 +82,4 @@ public class ManualBindTest implements GdxTest {
-0.5f, 0, c, 1, 0 });
vertices2.flip();
}
-
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshMultitextureTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshMultitextureTest.java
index ff11cbf5f..4f0f61bfe 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshMultitextureTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshMultitextureTest.java
@@ -2,28 +2,22 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Pixmap;
-import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.Texture.TextureFilter;
-import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
+import com.badlogic.gdx.graphics.Pixmap.Format;
+import com.badlogic.gdx.graphics.Texture.TextureFilter;
+import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class MeshMultitextureTest implements GdxTest {
+public class MeshMultitextureTest extends GdxTest {
Texture tex1;
Texture tex2;
Mesh mesh;
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
-
@Override public void render () {
GL10 gl = Gdx.graphics.getGL10();
gl.glViewport( 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() );
@@ -36,11 +30,22 @@ public class MeshMultitextureTest implements GdxTest {
mesh.render(GL10.GL_TRIANGLES);
}
- @Override public void surfaceChanged (int width, int height) {
+ @Override public void create () {
+ mesh = new Mesh(true, 3, 0, new VertexAttribute(VertexAttributes.Usage.Color, 4, "a_Color"), new VertexAttribute(
+ VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords1"), new VertexAttribute(
+ VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords2"), new VertexAttribute(VertexAttributes.Usage.Position, 3,
+ "a_Position"));
- }
+ mesh.setVertices(new float[] {1, 0, 0, 1, 0, 1, 0, 1, -0.5f, -0.5f, 0,
- @Override public void surfaceCreated () {
+ 0, 1, 0, 1, 1, 1, 1, 1, 0.5f, -0.5f, 0,
+
+ 0, 0, 1, 1, 0.5f, 0, 0.5f, 0, 0, 0.5f, 0,});
+
+ initUnmanaged();
+ }
+
+ void initUnmanaged() {
Pixmap pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);
pixmap.setColor(1, 1, 1, 1);
pixmap.fill();
@@ -49,6 +54,7 @@ public class MeshMultitextureTest implements GdxTest {
pixmap.drawLine(256, 0, 0, 256);
tex1 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
TextureWrap.ClampToEdge);
+ pixmap.dispose();
pixmap = Gdx.graphics.newPixmap(256, 256, Format.RGBA8888);
pixmap.setColor(1, 1, 1, 1);
@@ -57,21 +63,14 @@ public class MeshMultitextureTest implements GdxTest {
pixmap.drawLine(128, 0, 128, 256);
tex2 = Gdx.graphics.newUnmanagedTexture(pixmap, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
TextureWrap.ClampToEdge);
-
- mesh = new Mesh(true, 3, 0, new VertexAttribute(VertexAttributes.Usage.Color, 4, "a_Color"), new VertexAttribute(
- VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords1"), new VertexAttribute(
- VertexAttributes.Usage.TextureCoordinates, 2, "a_texCoords2"), new VertexAttribute(VertexAttributes.Usage.Position, 3,
- "a_Position"));
-
- mesh.setVertices(new float[] {1, 0, 0, 1, 0, 1, 0, 1, -0.5f, -0.5f, 0,
-
- 0, 1, 0, 1, 1, 1, 1, 1, 0.5f, -0.5f, 0,
-
- 0, 0, 1, 1, 0.5f, 0, 0.5f, 0, 0, 0.5f, 0,});
+ pixmap.dispose();
+ }
+
+ public void resume() {
+ initUnmanaged();
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshShaderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshShaderTest.java
index d3f812b82..e61635f6e 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshShaderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshShaderTest.java
@@ -29,55 +29,68 @@ import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class MeshShaderTest implements GdxTest {
+public class MeshShaderTest extends GdxTest {
SpriteBatch spriteBatch;
-// Font font;
+ // Font font;
ShaderProgram shader;
Mesh mesh;
Texture texture;
Matrix4 matrix = new Matrix4();
- @Override public void surfaceCreated () {
- if (shader == null) {
- String vertexShader = "attribute vec4 a_position; \n" + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"
- + "uniform mat4 u_worldView;\n" + "varying vec4 v_color;" + "varying vec2 v_texCoords;"
- + "void main() \n" + "{ \n"
- + " v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n" + " v_texCoords = a_texCoords; \n"
- + " gl_Position = u_worldView * a_position; \n" + "} \n";
- String fragmentShader = "precision mediump float;\n" + "varying vec4 v_color;\n" + "varying vec2 v_texCoords;\n"
- + "uniform sampler2D u_texture;\n" + "void main() \n"
+ @Override
+ public void create() {
+ String vertexShader = "attribute vec4 a_position; \n"
+ + "attribute vec4 a_color;\n" + "attribute vec2 a_texCoords;\n"
+ + "uniform mat4 u_worldView;\n" + "varying vec4 v_color;"
+ + "varying vec2 v_texCoords;"
+ + "void main() \n"
+ + "{ \n"
+ + " v_color = vec4(a_color.x, a_color.y, a_color.z, 1); \n"
+ + " v_texCoords = a_texCoords; \n"
+ + " gl_Position = u_worldView * a_position; \n"
+ + "} \n";
+ String fragmentShader = "precision mediump float;\n"
+ + "varying vec4 v_color;\n"
+ + "varying vec2 v_texCoords;\n"
+ + "uniform sampler2D u_texture;\n"
+ + "void main() \n"
+ "{ \n"
- + " gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" + "}";
+ + " gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n"
+ + "}";
- shader = new ShaderProgram(vertexShader, fragmentShader);
- if (shader.isCompiled() == false) {
- Gdx.app.log("ShaderTest", shader.getLog());
- System.exit(0);
- }
+ shader = new ShaderProgram(vertexShader, fragmentShader);
+ if (shader.isCompiled() == false) {
+ Gdx.app.log("ShaderTest", shader.getLog());
+ System.exit(0);
+ }
- mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(
- Usage.Color, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
+ mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3,
+ "a_position"), new VertexAttribute(Usage.Color, 4, "a_color"),
+ new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
- 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,
- 1, 0.5f, 1});
- mesh.setIndices(new short[] {0, 1, 2});
+ 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, 1, 0.5f, 1 });
+ mesh.setIndices(new short[] { 0, 1, 2 });
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
- spriteBatch = new SpriteBatch();
-// font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
- }
+ spriteBatch = new SpriteBatch();
+ // font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
}
Vector3 axis = new Vector3(0, 0, 1);
float angle = 0;
- @Override public void render () {
+ @Override
+ public void render() {
angle += Gdx.graphics.getDeltaTime() * 45;
matrix.setToRotation(axis, angle);
- Gdx.graphics.getGL20().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ Gdx.graphics.getGL20().glViewport(0, 0, Gdx.graphics.getWidth(),
+ Gdx.graphics.getHeight());
Gdx.graphics.getGL20().glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);
@@ -89,20 +102,12 @@ public class MeshShaderTest implements GdxTest {
shader.end();
spriteBatch.begin();
-// spriteBatch.drawText(font, "This is a test", 100, 100, Color.RED);
+ // spriteBatch.drawText(font, "This is a test", 100, 100, Color.RED);
spriteBatch.end();
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void dispose () {
- Gdx.app.log("MeshShaderTEst", "disposed");
- }
-
- @Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
+ @Override
+ public boolean needsGL20() {
return true;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshTest.java
index 6d61e5b62..a6451a1fc 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/MeshTest.java
@@ -13,28 +13,22 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
-import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class MeshTest implements GdxTest {
+public class MeshTest extends GdxTest {
Mesh mesh;
Texture texture;
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
-
@Override public void render () {
Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.graphics.getGL10().glEnable(GL10.GL_TEXTURE_2D);
@@ -42,28 +36,19 @@ public class MeshTest implements GdxTest {
mesh.render(GL10.GL_TRIANGLES, 0, 3);
}
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
+ @Override public void create () {
+ mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(
+ Usage.ColorPacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
- @Override public void surfaceCreated () {
- if (mesh == null) {
- mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3, "a_position"), new VertexAttribute(
- Usage.ColorPacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));
+ mesh.setVertices(new float[] {-0.5f, -0.5f, 0, Color.toFloatBits(255, 0, 0, 255), 0, 0, 0.5f, -0.5f, 0,
+ Color.toFloatBits(0, 255, 0, 255), 1, 0, 0, 0.5f, 0, Color.toFloatBits(0, 0, 255, 255), 0.5f, 1});
+ mesh.setIndices(new short[] {0, 1, 2});
- mesh.setVertices(new float[] {-0.5f, -0.5f, 0, Color.toFloatBits(255, 0, 0, 255), 0, 0, 0.5f, -0.5f, 0,
- Color.toFloatBits(0, 255, 0, 255), 1, 0, 0, 0.5f, 0, Color.toFloatBits(0, 0, 255, 255), 0.5f, 1});
- mesh.setIndices(new short[] {0, 1, 2});
-
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- }
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
-
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Mpg123Test.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Mpg123Test.java
index 9f2cdcc52..c42855ef8 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Mpg123Test.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Mpg123Test.java
@@ -16,31 +16,17 @@ package com.badlogic.gdx.tests;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
-import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.audio.analysis.AudioTools;
import com.badlogic.gdx.audio.analysis.KissFFT;
import com.badlogic.gdx.audio.io.Mpg123Decoder;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class Mpg123Test implements GdxTest {
-
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void render () {
-
- }
+public class Mpg123Test extends GdxTest {
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
- @Override public void surfaceCreated () {
+ @Override public void create () {
// Thread thread = new Thread( new Runnable() {
//
// public void run( )
@@ -75,7 +61,6 @@ public class Mpg123Test implements GdxTest {
}
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/MultitouchTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/MultitouchTest.java
index 2a398889c..93a24cbc5 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/MultitouchTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/MultitouchTest.java
@@ -2,23 +2,19 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.ImmediateModeRenderer;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class MultitouchTest implements GdxTest, InputListener {
+public class MultitouchTest extends GdxTest implements InputProcessor {
ImmediateModeRenderer renderer;
OrthographicCamera camera;
Color[] colors = {Color.RED, Color.BLUE, Color.GREEN, Color.WHITE};
- @Override public void dispose () {
- }
-
@Override public void render () {
Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -40,21 +36,17 @@ public class MultitouchTest implements GdxTest, InputListener {
}
renderer.end();
+
+ Gdx.input.processEvents(this);
}
- @Override public void surfaceChanged (int width, int height) {
- }
-
- @Override public void surfaceCreated () {
- if (renderer == null) {
- Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.supportsMultitouch());
- Gdx.input.addInputListener(this); // only add this once...
- renderer = new ImmediateModeRenderer();
- camera = new OrthographicCamera();
- camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- camera.getPosition().set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);
- }
+ @Override public void create () {
+ Gdx.app.log("Multitouch", "multitouch supported: " + Gdx.input.supportsMultitouch());
+ renderer = new ImmediateModeRenderer();
+ camera = new OrthographicCamera();
+ camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ camera.getPosition().set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);
}
@Override public boolean keyDown (int keycode) {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ObjTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ObjTest.java
index 8f9d09945..787e6f6b3 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ObjTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ObjTest.java
@@ -13,10 +13,9 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.ModelLoader;
@@ -26,7 +25,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class ObjTest implements GdxTest, InputListener {
+public class ObjTest extends GdxTest implements InputProcessor {
PerspectiveCamera cam;
Mesh mesh;
Texture texture;
@@ -35,28 +34,16 @@ public class ObjTest implements GdxTest, InputListener {
float[] lightColor = {1, 1, 1, 0};
float[] lightPosition = {2, 5, 10, 0};
float touchStartX = 0;
- float touchStartY = 0;
-
- long frameStart;
- int frames = 0;
-
- @Override public void surfaceCreated () {
- if (mesh == null) {
- Gdx.input.addInputListener(this);
-
- mesh = ModelLoader.loadObj(Gdx.files.readFile("data/cube.obj", FileType.Internal));
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- cam = new PerspectiveCamera();
- cam.getPosition().set(2, 2, 2);
- cam.getDirection().set(-1, -1, -1);
- }
- frameStart = System.nanoTime();
- }
+ float touchStartY = 0;
- @Override public void surfaceChanged (int width, int height) {
+ @Override public void create () {
+ mesh = ModelLoader.loadObj(Gdx.files.readFile("data/cube.obj", FileType.Internal));
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ cam = new PerspectiveCamera();
+ cam.getPosition().set(2, 2, 2);
+ cam.getDirection().set(-1, -1, -1);
}
@Override public void render () {
@@ -79,18 +66,8 @@ public class ObjTest implements GdxTest, InputListener {
gl.glRotatef(angleX, 1, 0, 0);
texture.bind();
mesh.render(GL10.GL_TRIANGLES);
-
- if (System.nanoTime() - frameStart > 1000000000) {
- Gdx.app.log("Obj Test", "fps: " + frames);
- frames = 0;
- frameStart = System.nanoTime();
- }
-
- frames++;
- }
-
- @Override public void dispose () {
-
+
+ Gdx.input.processEvents(this);
}
@Override public boolean keyDown (int keycode) {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java
index 09e333938..d112476c0 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ParticleEmitterTest.java
@@ -7,7 +7,7 @@ import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.BitmapFont;
import com.badlogic.gdx.graphics.BitmapFont.HAlignment;
import com.badlogic.gdx.graphics.BitmapFontCache;
@@ -22,16 +22,17 @@ import com.badlogic.gdx.graphics.particles.ParticleEmitter;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class ParticleEmitterTest implements GdxTest {
+public class ParticleEmitterTest extends GdxTest {
private SpriteBatch spriteBatch;
ParticleEffect effect;
int emitterIndex;
ArrayList emitters;
int particleCount = 10;
float fpsCounter;
+ InputProcessor inputProcessor;
- public void surfaceCreated () {
- if (spriteBatch != null) return;
+ @Override
+ public void create () {
spriteBatch = new SpriteBatch();
effect = new ParticleEffect();
@@ -42,7 +43,7 @@ public class ParticleEmitterTest implements GdxTest {
effect.getEmitters().clear();
effect.getEmitters().add(emitters.get(0));
- Gdx.input.addInputListener(new InputListener() {
+ inputProcessor = new InputProcessor() {
public boolean touchUp (int x, int y, int pointer) {
return false;
}
@@ -84,14 +85,11 @@ public class ParticleEmitterTest implements GdxTest {
effect.getEmitters().add(emitter);
return false;
}
- });
- }
-
- public void surfaceChanged (int width, int height) {
- spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ };
}
public void render () {
+ spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
float delta = Gdx.graphics.getDeltaTime();
GL10 gl = Gdx.graphics.getGL10();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
@@ -104,9 +102,8 @@ public class ParticleEmitterTest implements GdxTest {
int activeCount = emitters.get(emitterIndex).getActiveCount();
System.out.println(activeCount + "/" + particleCount + " particles, FPS: " + Gdx.graphics.getFramesPerSecond());
}
- }
-
- public void dispose () {
+
+ Gdx.input.processEvents(inputProcessor);
}
public boolean needsGL20 () {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Pong.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Pong.java
index 28f98d5a4..d59177e91 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Pong.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Pong.java
@@ -14,7 +14,6 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
@@ -31,7 +30,7 @@ import com.badlogic.gdx.tests.utils.GdxTest;
* @author mzechner
*
*/
-public class Pong implements GdxTest {
+public class Pong extends GdxTest {
/** the camera **/
private OrthographicCamera camera;
/** the MeshRenderer for the paddles **/
@@ -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
* and a {@link Text} for rendering the score.
*/
- @Override public void surfaceCreated () {
- if (camera == null) {
- setupGraphics();
- setupGame();
- }
+ @Override public void create () {
+ setupGraphics();
+ setupGame();
}
/**
@@ -125,10 +122,6 @@ public class Pong implements GdxTest {
ballDirection.set(-1, 0);
}
- @Override public void dispose () {
-
- }
-
@Override public void render () {
// we update the game state so things move.
updateGame();
@@ -173,7 +166,7 @@ public class Pong implements GdxTest {
spriteBatch.begin();
// spriteBatch.drawText(font, score, Gdx.graphics.getWidth() / 2 - font.getStringWidth(score) / 2, Gdx.graphics.getHeight()
// - font.getLineHeight(), Color.WHITE);
- spriteBatch.end();
+ spriteBatch.end();
}
/**
@@ -275,12 +268,7 @@ public class Pong implements GdxTest {
}
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
@Override public boolean needsGL20 () {
- // TODO Auto-generated method stub
return false;
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SimpleTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SimpleTest.java
index 97ef2af93..a379a3ecf 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SimpleTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SimpleTest.java
@@ -13,19 +13,15 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class SimpleTest implements GdxTest, InputListener, ApplicationListener {
+public class SimpleTest extends GdxTest implements InputProcessor {
float r = 1, g = 0, b = 0;
- @Override public void surfaceCreated () {
- Gdx.input.addInputListener(this);
- Gdx.app.setApplicationListener(this);
+ @Override public void create () {
Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", surface created");
}
@@ -34,13 +30,11 @@ public class SimpleTest implements GdxTest, InputListener, ApplicationListener {
gl.glClearColor(r, g, b, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+ Gdx.input.processEvents(this);
}
- @Override public void dispose () {
- Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", render listener disposed");
- }
-
@Override public void destroy () {
Gdx.app.log("Simple Test", "Thread=" + Thread.currentThread().getId() + ", application destroyed");
}
@@ -87,11 +81,6 @@ public class SimpleTest implements GdxTest, InputListener, ApplicationListener {
}
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
@Override public boolean needsGL20 () {
// TODO Auto-generated method stub
return false;
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java
index 87224ae00..fb187ace1 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java
@@ -13,46 +13,30 @@
package com.badlogic.gdx.tests;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class SoundTest implements GdxTest, InputListener {
+public class SoundTest extends GdxTest implements InputProcessor {
Sound sound;
Music music;
float volume = 1.0f;
- @Override public void dispose () {
-
+ @Override public void render () {
+ Gdx.input.processEvents(this);
}
- @Override public void render () {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Override public void surfaceChanged (int width, int height) {
-
- }
- @Override public void surfaceCreated () {
- if (music == null) {
- Gdx.input.addInputListener(this);
+ @Override public void create () {
sound = Gdx.audio.newSound(Gdx.files.getFileHandle("data/shotgun.wav", FileType.Internal));
// music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/threeofaperfectpair.mp3", FileType.Internal));
music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/cloudconnected.ogg", FileType.Internal));
music.play();
music.setLooping(true);
- }
}
@Override public boolean keyDown (int keycode) {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchRotationTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchRotationTest.java
index a5d21dabe..a20536944 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchRotationTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchRotationTest.java
@@ -17,9 +17,8 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
-import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.SpriteBatch;
@@ -28,52 +27,59 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class SpriteBatchRotationTest implements GdxTest {
+public class SpriteBatchRotationTest extends GdxTest {
SpriteBatch spriteBatch;
Texture texture;
-// Font font;
+ // Font font;
float angle = 0;
float scale = 1;
float vScale = 1;
IntBuffer pixelBuffer;
- @Override public void dispose () {
-
- }
-
- @Override public void render () {
+ @Override
+ public void render() {
Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT);
spriteBatch.begin();
- spriteBatch.draw(texture, 16, 10, 16, 16, 32, 32, 1, 1, 0, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,
- false, false);
- spriteBatch.draw(texture, 64, 10, 32, 32, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE, false, false);
- spriteBatch.draw(texture, 112, 10, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE);
-
- spriteBatch.draw(texture, 16, 58, 16, 16, 32, 32, 1, 1, angle, 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,
- false, false);
- spriteBatch.draw(texture, 64, 58, 16, 16, 32, 32, scale, scale, 0, 0, 0, texture.getWidth(), texture.getHeight(),
- Color.WHITE, false, false);
- spriteBatch.draw(texture, 112, 58, 16, 16, 32, 32, scale, scale, angle, 0, 0, texture.getWidth(), texture.getHeight(),
- Color.WHITE, false, false);
- spriteBatch.draw(texture, 160, 58, 0, 0, 32, 32, scale, scale, angle, 0, 0, texture.getWidth(), texture.getHeight(),
- Color.WHITE, false, false);
-
-// spriteBatch.drawText(font, "Test", 208, 10, Color.WHITE);
+ spriteBatch.draw(texture, 16, 10, 16, 16, 32, 32, 1, 1, 0, 0, 0,
+ texture.getWidth(), texture.getHeight(), Color.WHITE, false,
+ false);
+ spriteBatch.draw(texture, 64, 10, 32, 32, 0, 0, texture.getWidth(),
+ texture.getHeight(), Color.WHITE, false, false);
+ spriteBatch.draw(texture, 112, 10, 0, 0, texture.getWidth(), texture
+ .getHeight(), Color.WHITE);
+
+ spriteBatch.draw(texture, 16, 58, 16, 16, 32, 32, 1, 1, angle, 0, 0,
+ texture.getWidth(), texture.getHeight(), Color.WHITE, false,
+ false);
+ spriteBatch.draw(texture, 64, 58, 16, 16, 32, 32, scale, scale, 0, 0,
+ 0, texture.getWidth(), texture.getHeight(), Color.WHITE, false,
+ false);
+ spriteBatch.draw(texture, 112, 58, 16, 16, 32, 32, scale, scale, angle,
+ 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,
+ false, false);
+ spriteBatch.draw(texture, 160, 58, 0, 0, 32, 32, scale, scale, angle,
+ 0, 0, texture.getWidth(), texture.getHeight(), Color.WHITE,
+ false, false);
+
+ // spriteBatch.drawText(font, "Test", 208, 10, Color.WHITE);
spriteBatch.end();
Gdx.graphics.getGL10().glFlush();
-// if( false )
-// {
-// Gdx.graphics.getGL10().glReadPixels( 16, 10, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );
-// if( pixelBuffer.get(0) != 0xff00ff00 )
-// throw new GdxRuntimeException( "not pixel perfect!" );
-// Gdx.graphics.getGL10().glReadPixels( 47, 10, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );
-// if( pixelBuffer.get(0) != 0xffff0000 )
-// throw new GdxRuntimeException( "not pixel perfect!" );
-// Gdx.graphics.getGL10().glReadPixels( 16, 41, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixelBuffer );
-// if( pixelBuffer.get(0) != 0xff0000ff )
-// throw new GdxRuntimeException( "not pixel perfect!" );
-// }
+ // if( false )
+ // {
+ // Gdx.graphics.getGL10().glReadPixels( 16, 10, 1, 1, GL10.GL_RGBA,
+ // GL10.GL_UNSIGNED_BYTE, pixelBuffer );
+ // if( pixelBuffer.get(0) != 0xff00ff00 )
+ // throw new GdxRuntimeException( "not pixel perfect!" );
+ // Gdx.graphics.getGL10().glReadPixels( 47, 10, 1, 1, GL10.GL_RGBA,
+ // GL10.GL_UNSIGNED_BYTE, pixelBuffer );
+ // if( pixelBuffer.get(0) != 0xffff0000 )
+ // throw new GdxRuntimeException( "not pixel perfect!" );
+ // Gdx.graphics.getGL10().glReadPixels( 16, 41, 1, 1, GL10.GL_RGBA,
+ // GL10.GL_UNSIGNED_BYTE, pixelBuffer );
+ // if( pixelBuffer.get(0) != 0xff0000ff )
+ // throw new GdxRuntimeException( "not pixel perfect!" );
+ // }
angle += 20 * Gdx.graphics.getDeltaTime();
scale += vScale * Gdx.graphics.getDeltaTime();
@@ -88,23 +94,22 @@ public class SpriteBatchRotationTest implements GdxTest {
}
- @Override public void surfaceChanged (int width, int height) {
+ @Override
+ public void create() {
+ spriteBatch = new SpriteBatch();
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/test.png", FileType.Internal), TextureFilter.Linear,
+ TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
+ // font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
+ ByteBuffer buffer = ByteBuffer.allocateDirect(4);
+ buffer.order(ByteOrder.nativeOrder());
+ pixelBuffer = buffer.asIntBuffer();
}
- @Override public void surfaceCreated () {
- if (spriteBatch == null) {
- spriteBatch = new SpriteBatch();
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/test.png", FileType.Internal), TextureFilter.Linear,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-// font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
- ByteBuffer buffer = ByteBuffer.allocateDirect(4);
- buffer.order(ByteOrder.nativeOrder());
- pixelBuffer = buffer.asIntBuffer();
- }
- }
-
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchShaderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchShaderTest.java
index b8e3df829..9f6afadd8 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchShaderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchShaderTest.java
@@ -26,7 +26,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class SpriteBatchShaderTest implements GdxTest {
+public class SpriteBatchShaderTest extends GdxTest {
int SPRITES = 400;
long startTime = System.nanoTime();
@@ -44,10 +44,6 @@ public class SpriteBatchShaderTest implements GdxTest {
Mesh mesh;
float vertices[] = new float[SPRITES * 6 * (2 + 2 + 4)];
- @Override public void dispose () {
-
- }
-
@Override public void render () {
GL20 gl = Gdx.graphics.getGL20();
gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
@@ -93,13 +89,8 @@ public class SpriteBatchShaderTest implements GdxTest {
frames++;
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void surfaceCreated () {
- if (spriteBatch == null) spriteBatch = new SpriteBatch();
-
+ @Override public void create () {
+ spriteBatch = new SpriteBatch();
Pixmap pixmap = Gdx.graphics.newPixmap(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal));
// pixmap.setColor( 0, 0, 0, 0 );
// pixmap.fillCircle( 16, 16, 4 );
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchTest.java
index d20a452d1..35835f62a 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchTest.java
@@ -14,7 +14,7 @@
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
@@ -27,7 +27,7 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class SpriteBatchTest implements GdxTest, InputListener {
+public class SpriteBatchTest extends GdxTest implements InputProcessor {
int SPRITES = 400 / 2;
long startTime = System.nanoTime();
@@ -46,14 +46,13 @@ public class SpriteBatchTest implements GdxTest, InputListener {
float SCALE_SPEED = -1;
int renderMethod = 0;
- @Override public void dispose () {
-
- }
@Override public void render () {
if (renderMethod == 0) renderNormal();
;
if (renderMethod == 1) renderSprites();
+
+ Gdx.input.processEvents(this);
}
private void renderNormal () {
@@ -176,12 +175,8 @@ public class SpriteBatchTest implements GdxTest, InputListener {
frames++;
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
- @Override public void surfaceCreated () {
- if (spriteBatch == null) spriteBatch = new SpriteBatch(1000);
+ @Override public void create () {
+ spriteBatch = new SpriteBatch(1000);
Pixmap pixmap = Gdx.graphics.newPixmap(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal));
texture = Gdx.graphics.newUnmanagedTexture(32, 32, Format.RGB565, TextureFilter.Linear, TextureFilter.Linear,
@@ -224,8 +219,7 @@ public class SpriteBatchTest implements GdxTest, InputListener {
sprites3[i].setPosition(x, y);
sprites3[i].setOrigin(16, 16);
}
-
- Gdx.input.addInputListener(this);
+
}
@Override public boolean keyDown (int keycode) {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/StageTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/StageTest.java
index 9cfc397ad..06bf8fb92 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/StageTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/StageTest.java
@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.ImmediateModeRenderer;
@@ -33,16 +33,16 @@ import com.badlogic.gdx.scenes.scene2d.actors.Image;
import com.badlogic.gdx.scenes.scene2d.actors.Label;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class StageTest implements GdxTest, InputListener {
+public class StageTest extends GdxTest implements InputProcessor {
private static final int NUM_GROUPS = 5;
- private static final int NUM_SPRITES = (int)Math.sqrt(400 / NUM_GROUPS);
+ private static final int NUM_SPRITES = (int) Math.sqrt(400 / NUM_GROUPS);
private static final float SPACING = 5;
ImmediateModeRenderer renderer;
Stage stage;
Stage ui;
Texture texture;
Texture uiTexture;
-// Font font;
+ // Font font;
boolean rotateSprites = false;
boolean scaleSprites = false;
@@ -52,53 +52,60 @@ public class StageTest implements GdxTest, InputListener {
float scale = 1;
float vScale = 1;
- @Override public void surfaceCreated () {
- if (stage == null) {
- Gdx.input.addInputListener(this);
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogicsmall.jpg", FileType.Internal),
- TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-// font = Gdx.graphics.newFont("DroidSans", 12, FontStyle.Plain);
-
- stage = new Stage(480, 320, true);
-
- float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
- for (int i = 0; i < NUM_GROUPS; i++) {
- Group group = new Group("group" + i);
- group.x = (float)Math.random() * (stage.width() - NUM_SPRITES * (32 + SPACING));
- group.y = (float)Math.random() * (stage.height() - NUM_SPRITES * (32 + SPACING));
- group.originX = loc;
- group.originY = loc;
-
- fillGroup(group, texture);
- stage.addActor(group);
- }
-
- uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/ui.png", FileType.Internal), TextureFilter.Linear,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- ui = new Stage(480, 320, false);
- Image blend = new Image("blend button", new TextureRegion(uiTexture, 0, 0, 64, 32));
- blend.y = ui.height() - 32;
- Image rotate = new Image("rotate button", new TextureRegion(uiTexture, 64, 0, 64, 32));
- rotate.y = blend.y;
- rotate.x = 64;
- Image scale = new Image("scale button", new TextureRegion(uiTexture, 64, 32, 64, 32));
- scale.y = blend.y;
- scale.x = 128;
-
- ui.addActor(blend);
- ui.addActor(rotate);
- ui.addActor(scale);
-
-// Label fps = new Label("fps", font, "fps: 0");
-// fps.color.set(0, 1, 0, 1);
-// ui.addActor(fps);
-
- Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
- renderer = new ImmediateModeRenderer();
+ @Override
+ public void create() {
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/badlogicsmall.jpg", FileType.Internal),
+ TextureFilter.Linear, TextureFilter.Linear,
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ // font = Gdx.graphics.newFont("DroidSans", 12, FontStyle.Plain);
+
+ stage = new Stage(480, 320, true);
+
+ float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
+ for (int i = 0; i < NUM_GROUPS; i++) {
+ Group group = new Group("group" + i);
+ group.x = (float) Math.random()
+ * (stage.width() - NUM_SPRITES * (32 + SPACING));
+ group.y = (float) Math.random()
+ * (stage.height() - NUM_SPRITES * (32 + SPACING));
+ group.originX = loc;
+ group.originY = loc;
+
+ fillGroup(group, texture);
+ stage.addActor(group);
}
+
+ uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/ui.png", FileType.Internal), TextureFilter.Linear,
+ TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
+ ui = new Stage(480, 320, false);
+ Image blend = new Image("blend button", new TextureRegion(uiTexture, 0,
+ 0, 64, 32));
+ blend.y = ui.height() - 32;
+ Image rotate = new Image("rotate button", new TextureRegion(uiTexture,
+ 64, 0, 64, 32));
+ rotate.y = blend.y;
+ rotate.x = 64;
+ Image scale = new Image("scale button", new TextureRegion(uiTexture,
+ 64, 32, 64, 32));
+ scale.y = blend.y;
+ scale.x = 128;
+
+ ui.addActor(blend);
+ ui.addActor(rotate);
+ ui.addActor(scale);
+
+ // Label fps = new Label("fps", font, "fps: 0");
+ // fps.color.set(0, 1, 0, 1);
+ // ui.addActor(fps);
+
+ Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
+ renderer = new ImmediateModeRenderer();
}
- private void fillGroup (Group group, Texture texture) {
+ private void fillGroup(Group group, Texture texture) {
float advance = 32 + SPACING;
for (int y = 0; y < NUM_SPRITES * advance; y += advance)
for (int x = 0; x < NUM_SPRITES * advance; x += advance) {
@@ -112,11 +119,8 @@ public class StageTest implements GdxTest, InputListener {
}
}
- @Override public void surfaceChanged (int width, int height) {
- ui.setViewport(480, 320, false);
- }
-
- @Override public void render () {
+ @Override
+ public void render() {
GL10 gl = Gdx.graphics.getGL10();
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
@@ -128,14 +132,16 @@ public class StageTest implements GdxTest, InputListener {
if (actor != null)
if (actor instanceof Image)
- ((Image)actor).color.set((float)Math.random(), (float)Math.random(), (float)Math.random(),
- 0.5f + 0.5f * (float)Math.random());
+ ((Image) actor).color.set((float) Math.random(),
+ (float) Math.random(), (float) Math.random(),
+ 0.5f + 0.5f * (float) Math.random());
}
int len = stage.getGroups().size();
for (int i = 0; i < len; i++)
if (rotateSprites)
- stage.getGroups().get(i).rotation += Gdx.graphics.getDeltaTime();
+ stage.getGroups().get(i).rotation += Gdx.graphics
+ .getDeltaTime();
else
stage.getGroups().get(i).rotation = 0;
@@ -174,57 +180,70 @@ public class StageTest implements GdxTest, InputListener {
for (int i = 0; i < len; i++) {
renderer.color(1, 0, 0, 1);
Group group = stage.getRoot().getGroups().get(i);
- renderer.vertex(group.x + group.originX, group.y + group.originY, 0);
+ renderer
+ .vertex(group.x + group.originX, group.y + group.originY, 0);
}
renderer.end();
Gdx.graphics.getGL10().glPointSize(4);
-// ((Label)ui.findActor("fps")).text = "fps: " + Gdx.graphics.getFramesPerSecond() + ", actors " + images.size() + ", groups "
-// + stage.getGroups().size();
+ // ((Label)ui.findActor("fps")).text = "fps: " +
+ // Gdx.graphics.getFramesPerSecond() + ", actors " + images.size() +
+ // ", groups "
+ // + stage.getGroups().size();
ui.render();
+
+ Gdx.input.processEvents(this);
}
- @Override public boolean touchDown (int x, int y, int pointer) {
+ @Override
+ public boolean touchDown(int x, int y, int pointer) {
boolean touched = ui.touchDown(x, y, pointer);
if (touched) {
Actor hitActor = ui.getLastTouchedChild();
- if (hitActor == null) return touched;
- if (hitActor.name.startsWith("blend")) if (stage.getSpriteBatch().isBlendingEnabled())
- stage.getSpriteBatch().disableBlending();
- else
- stage.getSpriteBatch().enableBlending();
- if (hitActor.name.startsWith("rotate")) rotateSprites = !rotateSprites;
- if (hitActor.name.startsWith("scale")) scaleSprites = !scaleSprites;
+ if (hitActor == null)
+ return touched;
+ if (hitActor.name.startsWith("blend"))
+ if (stage.getSpriteBatch().isBlendingEnabled())
+ stage.getSpriteBatch().disableBlending();
+ else
+ stage.getSpriteBatch().enableBlending();
+ if (hitActor.name.startsWith("rotate"))
+ rotateSprites = !rotateSprites;
+ if (hitActor.name.startsWith("scale"))
+ scaleSprites = !scaleSprites;
}
return touched;
}
- @Override public boolean touchUp (int x, int y, int pointer) {
+ @Override
+ public boolean touchUp(int x, int y, int pointer) {
return false;
}
- @Override public boolean touchDragged (int x, int y, int pointer) {
+ @Override
+ public boolean touchDragged(int x, int y, int pointer) {
return false;
}
- @Override public void dispose () {
-
- }
- @Override public boolean keyDown (int keycode) {
+ @Override
+ public boolean keyDown(int keycode) {
return false;
}
- @Override public boolean keyUp (int keycode) {
+ @Override
+ public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyTyped (char character) {
+ @Override
+ public boolean keyTyped(char character) {
return false;
}
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/TerrainTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/TerrainTest.java
index 6356c7e79..ff64243e8 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/TerrainTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/TerrainTest.java
@@ -1,4 +1,3 @@
-
package com.badlogic.gdx.tests;
import java.util.Random;
@@ -18,7 +17,7 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.Ray;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class TerrainTest implements GdxTest {
+public class TerrainTest extends GdxTest {
ImmediateModeRenderer renderer;
TerrainChunk chunk;
Mesh mesh;
@@ -27,39 +26,38 @@ public class TerrainTest implements GdxTest {
boolean intersected = false;
long lastTime = System.nanoTime();
- @Override public void surfaceCreated () {
- if (chunk == null) {
- renderer = new ImmediateModeRenderer();
-
- chunk = new TerrainChunk(32, 32, 4);
+ @Override
+ public void create() {
+ renderer = new ImmediateModeRenderer();
- Random rand = new Random();
- int len = chunk.vertices.length;
- for (int i = 3; i < len; i += 4)
- chunk.vertices[i] = Color.toFloatBits(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255), 255);
+ chunk = new TerrainChunk(32, 32, 4);
- mesh = new Mesh(true, chunk.vertices.length / 3, chunk.indices.length, new VertexAttribute(
- VertexAttributes.Usage.Position, 3, "a_position"), new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4,
- "a_color"));
+ Random rand = new Random();
+ int len = chunk.vertices.length;
+ for (int i = 3; i < len; i += 4)
+ chunk.vertices[i] = Color.toFloatBits(rand.nextInt(255), rand
+ .nextInt(255), rand.nextInt(255), 255);
- mesh.setVertices(chunk.vertices);
- mesh.setIndices(chunk.indices);
+ mesh = new Mesh(true, chunk.vertices.length / 3, chunk.indices.length,
+ new VertexAttribute(VertexAttributes.Usage.Position, 3,
+ "a_position"), new VertexAttribute(
+ VertexAttributes.Usage.ColorPacked, 4, "a_color"));
- camera = new PerspectiveCamera();
- camera.getPosition().set(0, 5, 5);
- camera.getDirection().set(0, 0, 0).sub(camera.getPosition()).nor();
- camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- camera.setNear(0.5f);
- camera.setFar(300);
- camera.setFov(67);
- }
- }
+ mesh.setVertices(chunk.vertices);
+ mesh.setIndices(chunk.indices);
- @Override public void surfaceChanged (int width, int height) {
+ camera = new PerspectiveCamera();
+ camera.getPosition().set(0, 5, 5);
+ camera.getDirection().set(0, 0, 0).sub(camera.getPosition()).nor();
+ camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ camera.setNear(0.5f);
+ camera.setFar(300);
+ camera.setFov(67);
}
- @Override public void render () {
+ @Override
+ public void render() {
GL10 gl = Gdx.graphics.getGL10();
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
gl.glEnable(GL10.GL_DEPTH_TEST);
@@ -80,29 +78,34 @@ public class TerrainTest implements GdxTest {
handleInput(Gdx.input, Gdx.graphics.getDeltaTime());
if (System.nanoTime() - lastTime > 1000000000) {
- Gdx.app.log("TerrainTest", "fps: " + Gdx.graphics.getFramesPerSecond());
+ Gdx.app.log("TerrainTest", "fps: "
+ + Gdx.graphics.getFramesPerSecond());
lastTime = System.nanoTime();
}
}
- private void handleInput (Input input, float delta) {
+ private void handleInput(Input input, float delta) {
if (input.isTouched()) {
Ray ray = camera.getPickRay(input.getX(), input.getY());
- if (Intersector.intersectRayTriangles(ray, chunk.vertices, chunk.indices, 4, intersection)) intersected = true;
+ if (Intersector.intersectRayTriangles(ray, chunk.vertices,
+ chunk.indices, 4, intersection))
+ intersected = true;
} else {
intersected = false;
}
- if (input.isKeyPressed(Keys.KEYCODE_W)) camera.getPosition().z -= delta;
- if (input.isKeyPressed(Keys.KEYCODE_S)) camera.getPosition().z += delta;
- if (input.isKeyPressed(Keys.KEYCODE_A)) camera.getPosition().x -= delta;
- if (input.isKeyPressed(Keys.KEYCODE_D)) camera.getPosition().x += delta;
- if (input.isKeyPressed(Keys.KEYCODE_Q)) camera.getPosition().y += delta;
- if (input.isKeyPressed(Keys.KEYCODE_E)) camera.getPosition().y -= delta;
- }
-
- @Override public void dispose () {
-
+ if (input.isKeyPressed(Keys.KEYCODE_W))
+ camera.getPosition().z -= delta;
+ if (input.isKeyPressed(Keys.KEYCODE_S))
+ camera.getPosition().z += delta;
+ if (input.isKeyPressed(Keys.KEYCODE_A))
+ camera.getPosition().x -= delta;
+ if (input.isKeyPressed(Keys.KEYCODE_D))
+ camera.getPosition().x += delta;
+ if (input.isKeyPressed(Keys.KEYCODE_Q))
+ camera.getPosition().y += delta;
+ if (input.isKeyPressed(Keys.KEYCODE_E))
+ camera.getPosition().y -= delta;
}
final static class TerrainChunk {
@@ -113,13 +116,14 @@ public class TerrainTest implements GdxTest {
public final short[] indices;
public final int vertexSize;
- public TerrainChunk (int width, int height, int vertexSize) {
+ public TerrainChunk(int width, int height, int vertexSize) {
if ((width + 1) * (height + 1) > Short.MAX_VALUE)
- throw new IllegalArgumentException("Chunk size too big, (width + 1)*(height+1) must be <= 32767");
+ throw new IllegalArgumentException(
+ "Chunk size too big, (width + 1)*(height+1) must be <= 32767");
this.heightMap = new byte[(width + 1) * (height + 1)];
- this.width = (short)width;
- this.height = (short)height;
+ this.width = (short) width;
+ this.height = (short) height;
this.vertices = new float[heightMap.length * vertexSize];
this.indices = new short[width * height * 6];
this.vertexSize = vertexSize;
@@ -128,7 +132,7 @@ public class TerrainTest implements GdxTest {
buildVertices();
}
- public void buildVertices () {
+ public void buildVertices() {
int heightPitch = height + 1;
int widthPitch = width + 1;
@@ -146,12 +150,12 @@ public class TerrainTest implements GdxTest {
}
}
- private void buildIndices () {
+ private void buildIndices() {
int idx = 0;
- short pitch = (short)(width + 1);
+ short pitch = (short) (width + 1);
short i1 = 0;
short i2 = 1;
- short i3 = (short)(1 + pitch);
+ short i3 = (short) (1 + pitch);
short i4 = pitch;
short row = 0;
@@ -174,14 +178,15 @@ public class TerrainTest implements GdxTest {
row += pitch;
i1 = row;
- i2 = (short)(row + 1);
- i3 = (short)(i2 + pitch);
- i4 = (short)(row + pitch);
+ i2 = (short) (row + 1);
+ i3 = (short) (i2 + pitch);
+ i4 = (short) (row + pitch);
}
}
}
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/TextureRenderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/TextureRenderTest.java
index 5b735e4e1..9e385a9ae 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/TextureRenderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/TextureRenderTest.java
@@ -17,7 +17,6 @@ import java.util.ArrayList;
import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
@@ -28,7 +27,7 @@ import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class TextureRenderTest implements GdxTest {
+public class TextureRenderTest extends GdxTest {
private OrthographicCamera camera;
private Mesh mesh;
@@ -37,7 +36,7 @@ public class TextureRenderTest implements GdxTest {
private ArrayList rects = new ArrayList();
Color color = new Color(Color.GREEN);
- @Override public void surfaceCreated () {
+ @Override public void create () {
camera = new OrthographicCamera();
camera.setViewport(480, 320);
camera.getPosition().set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
@@ -105,10 +104,6 @@ public class TextureRenderTest implements GdxTest {
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
@Override public void render () {
GL10 gl = Gdx.graphics.getGL10();
@@ -146,9 +141,6 @@ public class TextureRenderTest implements GdxTest {
}
- @Override public void dispose () {
-
- }
private ArrayList createRects () {
ArrayList l = new ArrayList();
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java
index af2bcb788..1b3d26cbc 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java
@@ -1,8 +1,7 @@
-
package com.badlogic.gdx.tests;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
@@ -32,138 +31,151 @@ import com.badlogic.gdx.scenes.scene2d.actors.Button.ClickListener;
import com.badlogic.gdx.scenes.scene2d.actors.LinearGroup.LinearGroupLayout;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class UITest implements GdxTest, InputListener {
+public class UITest extends GdxTest implements InputProcessor {
Texture uiTexture;
Texture badlogic;
TextureAtlas atlas;
Stage ui;
-// Font font;
-
- @Override public void surfaceCreated () {
- if (uiTexture == null) {
- Gdx.input.addInputListener(this);
- Gdx.input.setCatchBackKey( true );
-
-// font = Gdx.graphics.newFont( "Droid Sans", 20, FontStyle.Plain );
-
- uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/ui.png", FileType.Internal), TextureFilter.Linear,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- badlogic = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),
- TextureFilter.MipMap, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- ui = new Stage(480, 320, false);
- atlas = new TextureAtlas(uiTexture);
- atlas.addRegion("blend", 0, 0, 64, 32);
- atlas.addRegion("blendDown", -1, -1, 64, 32);
- atlas.addRegion("rotate", 64, 0, 64, 32);
- atlas.addRegion("rotateDown", 63, -1, 64, 32);
- atlas.addRegion("scale", 64, 32, 64, 32);
- atlas.addRegion("scaleDown", 63, 31, 64, 32);
- atlas.addRegion("button", 0, 64, 64, 32);
- atlas.addRegion("buttonDown", -1, 63, 64, 32);
-
- Image img1 = new Image("image1", new TextureRegion(badlogic, 0, 0, 256, 256));
- img1.width = img1.height = 64;
- img1.originX = img1.originY = 32;
- img1.action(Sequence.$(FadeOut.$(1),
- FadeIn.$(1),
- Delay.$(MoveTo.$(100, 100, 1), 2), ScaleTo.$(0.5f, 0.5f, 1),
- FadeOut.$(0.5f),
- Delay.$(Parallel.$(RotateTo.$(360, 1), FadeIn.$(1), ScaleTo.$(1, 1, 1)), 1)));
- ui.addActor(img1);
-
- Image img2 = new Image("image2", new TextureRegion(badlogic, 0, 0, 256, 256));
- img2.width = img2.height = 64;
- img2.originX = img2.originY = 32;
- img2.action(Repeat.$(Sequence.$(MoveBy.$(50, 0, 1),
- MoveBy.$(0, 50, 1),
- MoveBy.$(-50, 0, 1),
- MoveBy.$(0, -50, 1)), 3));
- ui.addActor(img2);
-
- Button button = new Button("button", atlas.getRegion("button"), atlas.getRegion("buttonDown"));
- button.action(Forever.$(RotateBy.$(360, 4)));
- button.clickListener = new ClickListener() {
-
- @Override public void clicked (Button button) {
- if( Gdx.input.supportsOnscreenKeyboard() )
- Gdx.input.setOnscreenKeyboardVisible( true );
- }
- };
- ui.addActor(button);
-
-// Label label = new Label( "label", font, "text input: " );
-// label.x = 10; label.y = Gdx.graphics.getHeight() - 20;
-// ui.addActor(label);
-
- LinearGroup linear = new LinearGroup("linear", 64, 32 * 3, LinearGroupLayout.Vertical);
- linear.x = 200;
- linear.y = 150;
- linear.scaleX = linear.scaleY = 0;
- linear.addActor(new Button("blend", atlas.getRegion("blend"), atlas.getRegion("blendDown")));
- linear.addActor(new Button("scale", atlas.getRegion("scale"), atlas.getRegion("scaleDown")));
- linear.addActor(new Button("rotate", atlas.getRegion("rotate"), atlas.getRegion("rotateDown")));
- linear.action(Parallel.$(ScaleTo.$(1, 1, 2), RotateTo.$(720, 2)));
- ui.addActor(linear);
-
- LinearGroup linearh = new LinearGroup("linearh", 64 * 3, 32, LinearGroupLayout.Horizontal);
- linearh.x = 500;
- linearh.y = 10;
- linearh.addActor(new Button("blendh", atlas.getRegion("blend"), atlas.getRegion("blendDown")));
- linearh.addActor(new Button("scaleh", atlas.getRegion("scale"), atlas.getRegion("scaleDown")));
- linearh.addActor(new Button("rotateh", atlas.getRegion("rotate"), atlas.getRegion("rotateDown")));
- linearh.action(MoveTo.$(100, 10, 1.5f));
- ui.addActor(linearh);
-
-// Group.enableDebugging( "data/debug.png" );
- }
- }
- @Override public void surfaceChanged (int width, int height) {
+ // Font font;
+
+ @Override
+ public void create() {
+// Gdx.input.setCatchBackKey(true);
+
+ // font = Gdx.graphics.newFont( "Droid Sans", 20, FontStyle.Plain );
+
+ uiTexture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/ui.png", FileType.Internal), TextureFilter.Linear,
+ TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
+
+ badlogic = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
+ "data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,
+ TextureFilter.Linear, TextureWrap.ClampToEdge,
+ TextureWrap.ClampToEdge);
+
+ ui = new Stage(480, 320, false);
+ atlas = new TextureAtlas(uiTexture);
+ atlas.addRegion("blend", 0, 0, 64, 32);
+ atlas.addRegion("blendDown", -1, -1, 64, 32);
+ atlas.addRegion("rotate", 64, 0, 64, 32);
+ atlas.addRegion("rotateDown", 63, -1, 64, 32);
+ atlas.addRegion("scale", 64, 32, 64, 32);
+ atlas.addRegion("scaleDown", 63, 31, 64, 32);
+ atlas.addRegion("button", 0, 64, 64, 32);
+ atlas.addRegion("buttonDown", -1, 63, 64, 32);
+
+ Image img1 = new Image("image1", new TextureRegion(badlogic, 0, 0, 256,
+ 256));
+ img1.width = img1.height = 64;
+ img1.originX = img1.originY = 32;
+ img1.action(Sequence.$(FadeOut.$(1), FadeIn.$(1), Delay.$(MoveTo.$(100,
+ 100, 1), 2), ScaleTo.$(0.5f, 0.5f, 1), FadeOut.$(0.5f), Delay
+ .$(Parallel.$(RotateTo.$(360, 1), FadeIn.$(1), ScaleTo.$(1, 1,
+ 1)), 1)));
+ ui.addActor(img1);
+
+ Image img2 = new Image("image2", new TextureRegion(badlogic, 0, 0, 256,
+ 256));
+ img2.width = img2.height = 64;
+ img2.originX = img2.originY = 32;
+ img2.action(Repeat.$(Sequence.$(MoveBy.$(50, 0, 1), MoveBy.$(0, 50, 1),
+ MoveBy.$(-50, 0, 1), MoveBy.$(0, -50, 1)), 3));
+ ui.addActor(img2);
+
+ Button button = new Button("button", atlas.getRegion("button"), atlas
+ .getRegion("buttonDown"));
+ button.action(Forever.$(RotateBy.$(360, 4)));
+ button.clickListener = new ClickListener() {
+
+ @Override
+ public void clicked(Button button) {
+ if (Gdx.input.supportsOnscreenKeyboard())
+ Gdx.input.setOnscreenKeyboardVisible(true);
+ }
+ };
+ ui.addActor(button);
+
+ // Label label = new Label( "label", font, "text input: " );
+ // label.x = 10; label.y = Gdx.graphics.getHeight() - 20;
+ // ui.addActor(label);
+
+ LinearGroup linear = new LinearGroup("linear", 64, 32 * 3,
+ LinearGroupLayout.Vertical);
+ linear.x = 200;
+ linear.y = 150;
+ linear.scaleX = linear.scaleY = 0;
+ linear.addActor(new Button("blend", atlas.getRegion("blend"), atlas
+ .getRegion("blendDown")));
+ linear.addActor(new Button("scale", atlas.getRegion("scale"), atlas
+ .getRegion("scaleDown")));
+ linear.addActor(new Button("rotate", atlas.getRegion("rotate"), atlas
+ .getRegion("rotateDown")));
+ linear.action(Parallel.$(ScaleTo.$(1, 1, 2), RotateTo.$(720, 2)));
+ ui.addActor(linear);
+
+ LinearGroup linearh = new LinearGroup("linearh", 64 * 3, 32,
+ LinearGroupLayout.Horizontal);
+ linearh.x = 500;
+ linearh.y = 10;
+ linearh.addActor(new Button("blendh", atlas.getRegion("blend"), atlas
+ .getRegion("blendDown")));
+ linearh.addActor(new Button("scaleh", atlas.getRegion("scale"), atlas
+ .getRegion("scaleDown")));
+ linearh.addActor(new Button("rotateh", atlas.getRegion("rotate"), atlas
+ .getRegion("rotateDown")));
+ linearh.action(MoveTo.$(100, 10, 1.5f));
+ ui.addActor(linearh);
+
+ // Group.enableDebugging( "data/debug.png" );
}
- @Override public void render () {
+ @Override
+ public void render() {
GL10 gl = Gdx.graphics.getGL10();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
ui.act(Gdx.graphics.getDeltaTime());
ui.render();
- }
-
- @Override public void dispose () {
+ Gdx.input.processEvents(this);
}
- @Override public boolean keyDown (int keycode) {
+ @Override
+ public boolean keyDown(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyUp (int keycode) {
+ @Override
+ public boolean keyUp(int keycode) {
// TODO Auto-generated method stub
return false;
}
- @Override public boolean keyTyped (char character) {
-// Label label = ((Label)ui.findActor( "label" ));
-// if( character == '\b' ) {
-// if( label.text.length() > "text input: ".length() )
-// label.text = label.text.substring( 0, label.text.length()-1 );
-// } else {
-// label.text += character;
-// }
+ @Override
+ public boolean keyTyped(char character) {
+ // Label label = ((Label)ui.findActor( "label" ));
+ // if( character == '\b' ) {
+ // if( label.text.length() > "text input: ".length() )
+ // label.text = label.text.substring( 0, label.text.length()-1 );
+ // } else {
+ // label.text += character;
+ // }
return false;
}
- @Override public boolean touchDown (int x, int y, int pointer) {
+ @Override
+ public boolean touchDown(int x, int y, int pointer) {
ui.touchDown(x, y, pointer);
return false;
}
Vector2 point = new Vector2();
- @Override public boolean touchUp (int x, int y, int pointer) {
+ @Override
+ public boolean touchUp(int x, int y, int pointer) {
if (!ui.touchUp(x, y, pointer)) {
Actor actor = ui.findActor("image1");
if (actor != null) {
@@ -180,12 +192,14 @@ public class UITest implements GdxTest, InputListener {
return false;
}
- @Override public boolean touchDragged (int x, int y, int pointer) {
+ @Override
+ public boolean touchDragged(int x, int y, int pointer) {
ui.touchDragged(x, y, pointer);
return false;
}
- @Override public boolean needsGL20 () {
+ @Override
+ public boolean needsGL20() {
// TODO Auto-generated method stub
return false;
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayClassTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayClassTest.java
index 807579c0d..b882d9f07 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayClassTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayClassTest.java
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexArray;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class VertexArrayClassTest implements GdxTest {
+public class VertexArrayClassTest extends GdxTest {
Texture texture;
VertexArray va;
ShortBuffer indices;
@@ -26,7 +26,7 @@ public class VertexArrayClassTest implements GdxTest {
}
@Override
- public void dispose() {
+ public void destroy() {
texture.dispose();
va.dispose();
}
@@ -50,13 +50,9 @@ public class VertexArrayClassTest implements GdxTest {
va.unbind();
}
- @Override
- public void surfaceChanged(int width, int height) {
-
- }
@Override
- public void surfaceCreated() {
+ public void create() {
va = new VertexArray(3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),
new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),
new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));
@@ -67,11 +63,9 @@ public class VertexArrayClassTest implements GdxTest {
indices = BufferUtils.newShortBuffer(3);
indices.put( new short[] { 0, 1, 2 } );
indices.flip();
-
- if( texture == null ) {
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),
- TextureFilter.Linear, TextureFilter.Linear,
- TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- }
+
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),
+ TextureFilter.Linear, TextureFilter.Linear,
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayTest.java
index ae9fbfd64..2b8ab8f61 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexArrayTest.java
@@ -19,19 +19,14 @@ import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class VertexArrayTest implements GdxTest {
+public class VertexArrayTest extends GdxTest {
FloatBuffer vertices;
ShortBuffer indices;
final int BYTES_PER_VERTEX = (3 + 4) * 4;
- @Override public void dispose () {
-
- }
-
@Override public void render () {
GL10 gl = Gdx.graphics.getGL10();
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -49,7 +44,7 @@ public class VertexArrayTest implements GdxTest {
gl.glDrawElements(GL10.GL_TRIANGLES, 3, GL10.GL_UNSIGNED_SHORT, indices);
}
- @Override public void surfaceCreated () {
+ @Override public void create () {
ByteBuffer buffer = ByteBuffer.allocateDirect(BYTES_PER_VERTEX * 3);
buffer.order(ByteOrder.nativeOrder());
vertices = buffer.asFloatBuffer();
@@ -69,11 +64,6 @@ public class VertexArrayTest implements GdxTest {
indices.flip();
}
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
-
@Override public boolean needsGL20 () {
// TODO Auto-generated method stub
return false;
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectClassTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectClassTest.java
index dd1ac8f25..7aabcb5e5 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectClassTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectClassTest.java
@@ -15,7 +15,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class VertexBufferObjectClassTest implements GdxTest {
+public class VertexBufferObjectClassTest extends GdxTest {
Texture texture;
VertexBufferObject vbo;
ShortBuffer indices;
@@ -26,7 +26,7 @@ public class VertexBufferObjectClassTest implements GdxTest {
}
@Override
- public void dispose() {
+ public void destroy() {
texture.dispose();
vbo.dispose();
}
@@ -51,13 +51,7 @@ public class VertexBufferObjectClassTest implements GdxTest {
}
@Override
- public void surfaceChanged(int width, int height) {
-
- }
-
- @Override
- public void surfaceCreated() {
- if( texture == null ) {
+ public void create() {
vbo = new VertexBufferObject(true, 3, new VertexAttribute(VertexAttributes.Usage.Position, 2, "a_Position"),
new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, "a_TexCoords"),
new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, "a_Color" ));
@@ -70,10 +64,12 @@ public class VertexBufferObjectClassTest implements GdxTest {
indices.flip();
texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal),
- TextureFilter.Linear, TextureFilter.Linear,
- TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- }
- else
- vbo.invalidate();
+ TextureFilter.Linear, TextureFilter.Linear,
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ }
+
+ @Override
+ public void resume() {
+ vbo.invalidate();
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectShaderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectShaderTest.java
index 8207e6b18..d7b17bba2 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectShaderTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectShaderTest.java
@@ -16,7 +16,7 @@ import com.badlogic.gdx.graphics.glutils.VertexBufferObject;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class VertexBufferObjectShaderTest implements GdxTest {
+public class VertexBufferObjectShaderTest extends GdxTest {
Texture texture;
ShaderProgram shader;
VertexBufferObject vbo;
@@ -28,7 +28,7 @@ public class VertexBufferObjectShaderTest implements GdxTest {
}
@Override
- public void dispose() {
+ public void destroy() {
texture.dispose();
vbo.dispose();
shader.dispose();
@@ -51,13 +51,7 @@ public class VertexBufferObjectShaderTest implements GdxTest {
}
@Override
- public void surfaceChanged(int width, int height) {
-
- }
-
- @Override
- public void surfaceCreated() {
- if (texture == null) {
+ public void create() {
String vertexShader = "attribute vec4 a_position; \n"
+ "attribute vec4 a_color;\n"
+ "attribute vec2 a_texCoords;\n"
@@ -94,9 +88,12 @@ public class VertexBufferObjectShaderTest implements GdxTest {
texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle(
"data/badlogic.jpg", FileType.Internal),
TextureFilter.Linear, TextureFilter.Linear,
- TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
- } else
- vbo.invalidate();
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+ }
+
+ @Override
+ public void resume() {
+ vbo.invalidate();
}
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectTest.java
index 50e79eeda..9ce70d623 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VertexBufferObjectTest.java
@@ -17,19 +17,14 @@ import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
import com.badlogic.gdx.graphics.GL11;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.BufferUtils;
-public class VertexBufferObjectTest implements GdxTest {
+public class VertexBufferObjectTest extends GdxTest {
int vboHandle;
int vboIndexHandle;
- @Override public void dispose () {
-
- }
-
@Override public void render () {
GL11 gl = Gdx.graphics.getGL11();
@@ -48,7 +43,7 @@ public class VertexBufferObjectTest implements GdxTest {
gl.glDrawElements(GL11.GL_TRIANGLES, 3, GL11.GL_UNSIGNED_SHORT, 0);
}
- @Override public void surfaceCreated () {
+ @Override public void create () {
FloatBuffer vertices = BufferUtils.newFloatBuffer(3 * 7);
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});
@@ -71,10 +66,28 @@ public class VertexBufferObjectTest implements GdxTest {
gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, 3 * 2, indices, GL11.GL_STATIC_DRAW);
gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
}
+
+ public void resume() {
+ FloatBuffer vertices = BufferUtils.newFloatBuffer(3 * 7);
+ 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});
+ vertices.flip();
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
+ GL11 gl = Gdx.graphics.getGL11();
+ int[] handle = new int[1];
+ gl.glGenBuffers(1, handle, 0);
+ vboHandle = handle[0];
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, vboHandle);
+ gl.glBufferData(GL11.GL_ARRAY_BUFFER, 3 * 7 * 4, vertices, GL11.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
+ ShortBuffer indices = BufferUtils.newShortBuffer(3);
+ indices.put(new short[] {0, 1, 2});
+ indices.flip();
+ gl.glGenBuffers(1, handle, 0);
+ vboIndexHandle = handle[0];
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, vboIndexHandle);
+ gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, 3 * 2, indices, GL11.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
}
@Override public boolean needsGL20 () {
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/VorbisTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/VorbisTest.java
index c41eb4fff..87827fde3 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/VorbisTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/VorbisTest.java
@@ -15,31 +15,15 @@ package com.badlogic.gdx.tests;
import java.nio.ShortBuffer;
-import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.audio.analysis.AudioTools;
import com.badlogic.gdx.audio.io.VorbisDecoder;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class VorbisTest implements GdxTest {
-
- @Override public void dispose () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void render () {
- // TODO Auto-generated method stub
-
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
- }
+public class VorbisTest extends GdxTest {
- @Override public void surfaceCreated () {
+ @Override public void create () {
VorbisDecoder decoder = null;
if (Gdx.app.getType() == ApplicationType.Android)
decoder = new VorbisDecoder("/sdcard/audio/schism.ogg");
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/WaterRipples.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/WaterRipples.java
index 48d12e42c..8c377e6ea 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/WaterRipples.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/WaterRipples.java
@@ -4,7 +4,7 @@ package com.badlogic.gdx.tests;
import java.util.Random;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
@@ -21,7 +21,7 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.collision.Ray;
import com.badlogic.gdx.tests.utils.GdxTest;
-public class WaterRipples implements GdxTest, InputListener {
+public class WaterRipples extends GdxTest implements InputProcessor {
static final short WIDTH = 50;
static final short HEIGHT = 50;
static final float INV_WIDTH = 1.0f / WIDTH;
@@ -45,34 +45,30 @@ public class WaterRipples implements GdxTest, InputListener {
float[][] intp;
float[] vertices;
- @Override public void surfaceCreated () {
-
- if (!initialized) {
- camera = new PerspectiveCamera();
- camera.getPosition().set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);
- camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth());
- camera.setFov(90);
- camera.setNear(0.1f);
- camera.setFar(1000);
- last = new float[WIDTH + 1][HEIGHT + 1];
- curr = new float[WIDTH + 1][HEIGHT + 1];
- intp = new float[WIDTH + 1][HEIGHT + 1];
- vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];
- mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6, new VertexAttribute(
- VertexAttributes.Usage.Position, 3, "a_Position"), new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2,
- "a_texCoords"));
- texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/stones.jpg", FileType.Internal), TextureFilter.Linear,
- TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
-
- createIndices();
- updateVertices(curr);
- initialized = true;
-
- batch = new SpriteBatch();
+ @Override public void create () {
+
+ camera = new PerspectiveCamera();
+ camera.getPosition().set((WIDTH) / 2.0f, (HEIGHT) / 2.0f, WIDTH / 2.0f);
+ camera.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getWidth());
+ camera.setFov(90);
+ camera.setNear(0.1f);
+ camera.setFar(1000);
+ last = new float[WIDTH + 1][HEIGHT + 1];
+ curr = new float[WIDTH + 1][HEIGHT + 1];
+ intp = new float[WIDTH + 1][HEIGHT + 1];
+ vertices = new float[(WIDTH + 1) * (HEIGHT + 1) * 5];
+ mesh = new Mesh(false, (WIDTH + 1) * (HEIGHT + 1), WIDTH * HEIGHT * 6, new VertexAttribute(
+ VertexAttributes.Usage.Position, 3, "a_Position"), new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2,
+ "a_texCoords"));
+ texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/stones.jpg", FileType.Internal), TextureFilter.Linear,
+ TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
+
+ createIndices();
+ updateVertices(curr);
+ initialized = true;
+
+ batch = new SpriteBatch();
// font = Gdx.graphics.newFont("Arial", 12, FontStyle.Plain);
-
- Gdx.input.addInputListener(this);
- }
}
private void createIndices () {
@@ -195,10 +191,8 @@ public class WaterRipples implements GdxTest, InputListener {
batch.begin();
// batch.drawText(font, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20, Color.WHITE);
batch.end();
- }
-
- @Override public void dispose () {
-
+
+ Gdx.input.processEvents(this);
}
@Override public boolean keyDown (int keycode) {
@@ -235,10 +229,6 @@ public class WaterRipples implements GdxTest, InputListener {
return false;
}
- @Override public void surfaceChanged (int width, int height) {
-
- }
-
@Override public boolean needsGL20 () {
// TODO Auto-generated method stub
return false;
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/box2d/Box2DTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/box2d/Box2DTest.java
index 443aeae30..5961a9447 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/box2d/Box2DTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/box2d/Box2DTest.java
@@ -13,19 +13,19 @@
package com.badlogic.gdx.tests.box2d;
+import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.InputListener;
-import com.badlogic.gdx.RenderListener;
+import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
-import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.QueryCallback;
import com.badlogic.gdx.physics.box2d.World;
+import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.joints.MouseJoint;
import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;
@@ -35,7 +35,7 @@ import com.badlogic.gdx.physics.box2d.joints.MouseJointDef;
* @author badlogicgames@gmail.com
*
*/
-public abstract class Box2DTest implements RenderListener, InputListener {
+public abstract class Box2DTest implements ApplicationListener, InputProcessor {
/** the camera **/
protected OrthographicCamera camera;
@@ -69,15 +69,10 @@ public abstract class Box2DTest implements RenderListener, InputListener {
camera.setMatrices();
// render the world using the debug renderer
- renderer.render(world);
- }
-
- @Override public void surfaceChanged (int width, int height) {
- // TODO Auto-generated method stub
-
+ renderer.render(world);
}
- @Override public void surfaceCreated () {
+ @Override public void create () {
// setup the camera. In Box2D we operate on a
// meter scale, pixels won't do it. So we use
// an orthographic camera with a viewport of
@@ -100,17 +95,11 @@ public abstract class Box2DTest implements RenderListener, InputListener {
BodyDef bodyDef = new BodyDef();
groundBody = world.createBody(bodyDef);
- // finally we register ourself as an InputListener so we
- // can manipulate our world
- Gdx.input.addInputListener(this);
-
// call abstract method to populate the world
createWorld(world);
}
- @Override public void dispose () {
- Gdx.input.removeInputListener(this);
-
+ @Override public void destroy () {
renderer.dispose();
world.dispose();
@@ -201,4 +190,12 @@ public abstract class Box2DTest implements RenderListener, InputListener {
}
return false;
}
+
+ public void pause() {
+
+ }
+
+ public void resume() {
+
+ }
}
diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTest.java
index 27384ea04..76c66856d 100644
--- a/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTest.java
+++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTest.java
@@ -1,9 +1,13 @@
package com.badlogic.gdx.tests.utils;
-import com.badlogic.gdx.RenderListener;
-import com.badlogic.gdx.utils.GdxRuntimeException;
+import com.badlogic.gdx.ApplicationListener;
-public interface GdxTest extends RenderListener
+public abstract class GdxTest implements ApplicationListener
{
- public boolean needsGL20( );
+ public abstract boolean needsGL20( );
+ public void create( ) { };
+ public void resume( ) { };
+ public void render( ) { };
+ public void pause( ) { };
+ public void destroy( ) { };
}