public class JoglDebugStarter {\r
\r
public static void main( String[] argv ) {\r
- new JoglApplication( new com.badlogic.gdx.tests.IsometricTileTest(), "Debug Test", 960, 640, false ); \r
+ new JoglApplication( new com.badlogic.gdx.tests.OrthoCamTest(), "Debug Test", 600, 320, false ); \r
}\r
}\r
--- /dev/null
+\r
+package com.badlogic.gdx.tests;\r
+\r
+import java.util.Random;\r
+\r
+import com.badlogic.gdx.Game;\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.graphics.GL10;\r
+import com.badlogic.gdx.graphics.Mesh;\r
+import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.VertexAttribute;\r
+import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
+import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
+import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
+import com.badlogic.gdx.tests.utils.GdxTest;\r
+\r
+public class BobTest extends GdxTest {\r
+\r
+ @Override public boolean needsGL20 () {\r
+ return false;\r
+ }\r
+\r
+ static final int NUM_BOBS = 100;\r
+ Texture bobTexture;\r
+ Mesh bobModel;\r
+ Bob[] bobs;\r
+\r
+ public void create() { \r
+ bobTexture = Gdx.graphics.newTexture(Gdx.files.internal("data/bobargb8888-32x32.png"),\r
+ TextureFilter.Nearest, TextureFilter.Nearest, \r
+ TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
+\r
+ bobModel = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 2, "a_pos"), new VertexAttribute(\r
+ Usage.TextureCoordinates, 2, "a_tex"));\r
+ bobModel.setVertices(new float[] {-16, -16, 0, 1, 16, -16, 1, 1, 16, 16, 1, 0, -16, 16, 0, 0,}, 0, 16);\r
+ bobModel.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6);\r
+ bobModel.setAutoBind(false);\r
+\r
+ bobs = new Bob[100];\r
+ for (int i = 0; i < 100; i++) {\r
+ bobs[i] = new Bob();\r
+ }\r
+ }\r
+\r
+\r
+ @Override public void render () {\r
+ float deltaTime = Math.min(Gdx.graphics.getDeltaTime(), 0.1f);\r
+ for (int i = 0; i < NUM_BOBS; i++) {\r
+ bobs[i].update(deltaTime);\r
+ }\r
+ \r
+ GL10 gl = Gdx.gl10; \r
+ gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
+ gl.glClearColor(1, 0, 0, 1);\r
+ gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
+ gl.glMatrixMode(GL10.GL_PROJECTION);\r
+ gl.glLoadIdentity();\r
+ gl.glOrthof(0, 320, 0, 480, 1, -1);\r
+\r
+ gl.glMatrixMode(GL10.GL_MODELVIEW);\r
+ \r
+ gl.glEnable(GL10.GL_BLEND);\r
+ gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);\r
+ \r
+ gl.glEnable(GL10.GL_TEXTURE_2D);\r
+ bobTexture.bind(); \r
+\r
+ bobModel.bind();\r
+ for (int i = 0; i < NUM_BOBS; i++) {\r
+ gl.glLoadIdentity();\r
+ gl.glTranslatef(Math.round(bobs[i].x), Math.round(bobs[i].y), 0);\r
+ System.out.println(Math.round(bobs[i].x) + ", " + (int)bobs[i].x);\r
+ bobModel.render(GL10.GL_TRIANGLES, 0, 6);\r
+ }\r
+ bobModel.unbind();\r
+ }\r
+\r
+ static class Bob {\r
+ static final Random rand = new Random();\r
+ public float x, y;\r
+ float dirX, dirY;\r
+\r
+ public Bob () {\r
+ x = rand.nextFloat() * 320;\r
+ y = rand.nextFloat() * 480;\r
+ dirX = 10;\r
+ dirY = 10;\r
+ }\r
+\r
+ public void update (float deltaTime) {\r
+ x = x + dirX * deltaTime;\r
+ y = y + dirY * deltaTime;\r
+\r
+ if (x < 0) {\r
+ dirX = -dirX;\r
+ x = 0;\r
+ }\r
+\r
+ if (x > 320) {\r
+ dirX = -dirX;\r
+ x = 320;\r
+ }\r
+\r
+ if (y < 0) {\r
+ dirY = -dirY;\r
+ y = 0;\r
+ }\r
+\r
+ if (y > 480) {\r
+ dirY = -dirY;\r
+ y = 480;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package com.badlogic.gdx.tests;\r
+\r
+import com.badlogic.gdx.Gdx;\r
+import com.badlogic.gdx.graphics.GL10;\r
+import com.badlogic.gdx.graphics.Mesh;\r
+import com.badlogic.gdx.graphics.OrthographicCamera;\r
+import com.badlogic.gdx.graphics.VertexAttribute;\r
+import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
+import com.badlogic.gdx.math.Rectangle;\r
+import com.badlogic.gdx.tests.utils.GdxTest;\r
+\r
+public class OrthoCamTest extends GdxTest {\r
+\r
+ @Override public boolean needsGL20 () {\r
+ return false;\r
+ }\r
+\r
+ static final int WIDTH = 320;\r
+ static final int HEIGHT = 480; \r
+ OrthographicCamera cam;\r
+ Rectangle viewport;\r
+ Mesh mesh;\r
+ \r
+ public void create() {\r
+ mesh = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 2, "a_pos"),\r
+ new VertexAttribute(Usage.Color, 4, "a_col"));\r
+ mesh.setVertices( new float[] {0, 0, 1, 0, 0, 1,\r
+ WIDTH, 0, 0, 1, 0, 1,\r
+ WIDTH, HEIGHT, 0, 0, 1, 1,\r
+ 0, HEIGHT, 1, 0, 1, 1 });\r
+ mesh.setIndices( new short[] { 0, 1, 2, 2, 3, 0 } );\r
+ \r
+ cam = new OrthographicCamera();\r
+ cam.setViewport(WIDTH, HEIGHT);\r
+ cam.getPosition().set(WIDTH / 2, HEIGHT / 2, 0);\r
+ \r
+ calculateViewport();\r
+ }\r
+ \r
+ private void calculateViewport() {\r
+ viewport = new Rectangle();\r
+ if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()) {\r
+ float aspect = (float)Gdx.graphics.getHeight() / HEIGHT;\r
+ viewport.width = WIDTH * aspect;\r
+ viewport.height = Gdx.graphics.getHeight();\r
+ viewport.x = Gdx.graphics.getWidth() / 2 - viewport.width / 2;\r
+ viewport.y = 0; \r
+ } else {\r
+ float aspect = (float)Gdx.graphics.getWidth() / WIDTH;\r
+ viewport.width = Gdx.graphics.getWidth();\r
+ viewport.height = HEIGHT * aspect;\r
+ viewport.x = 0;\r
+ viewport.y = Gdx.graphics.getHeight() / 2 - viewport.height / 2; \r
+ } \r
+ } \r
+ \r
+ public void resize(int width, int height) {\r
+ calculateViewport();\r
+ }\r
+ \r
+ public void render() {\r
+ GL10 gl = Gdx.gl10;\r
+ gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
+ gl.glViewport((int)viewport.x, (int)viewport.y, (int)viewport.width, (int)viewport.height);\r
+ \r
+ cam.setMatrices();\r
+ mesh.render(GL10.GL_TRIANGLES);\r
+ }\r
+}\r
import com.badlogic.gdx.tests.BitmapFontAlignmentTest;\r
import com.badlogic.gdx.tests.BitmapFontFlipTest;\r
import com.badlogic.gdx.tests.BitmapFontTest;\r
+import com.badlogic.gdx.tests.BobTest;\r
import com.badlogic.gdx.tests.Box2DTest;\r
import com.badlogic.gdx.tests.Box2DTestCollection;\r
import com.badlogic.gdx.tests.FilesTest;\r
import com.badlogic.gdx.tests.MultitouchTest;\r
import com.badlogic.gdx.tests.MyFirstTriangle;\r
import com.badlogic.gdx.tests.ObjTest;\r
+import com.badlogic.gdx.tests.OrthoCamTest;\r
import com.badlogic.gdx.tests.ParticleEmitterTest;\r
import com.badlogic.gdx.tests.PixelsPerInchTest;\r
import com.badlogic.gdx.tests.PixmapBlendingTest;\r
BitmapFontAlignmentTest.class,\r
BitmapFontFlipTest.class,\r
BitmapFontTest.class,\r
+ BobTest.class,\r
Box2DTest.class,\r
Box2DTestCollection.class,\r
FilesTest.class,\r
MultitouchTest.class,\r
MyFirstTriangle.class,\r
ObjTest.class,\r
+ OrthoCamTest.class,\r
ParticleEmitterTest.class,\r
PixelsPerInchTest.class,\r
PixmapBlendingTest.class,\r