v0.7.4b: Initial LibGDX commit! more details below:

Large sections of game logic are now working through libgdx instead of
android libraries. There is still work to do but this is the first
major step. Big changes include:
- Graphics code is now through LibGDX (except for text rendering)
- Initialization and screen-handling logic is now mostly through LibGDX
- Audio is now through LibGDX
- Input handling is now through LibGDX
- Most misc functions are now through LibGDX
This commit is contained in:
Evan Debenham
2019-07-30 16:50:40 -04:00
parent f10be84a10
commit 2a523f2ea2
42 changed files with 828 additions and 972 deletions

View File

@@ -21,8 +21,7 @@
package com.watabou.noosa;
import android.opengl.GLES20;
import com.badlogic.gdx.Gdx;
import com.watabou.glscripts.Script;
import com.watabou.glwrap.Attribute;
import com.watabou.glwrap.Quad;
@@ -81,7 +80,7 @@ public class NoosaScript extends Script {
aUV.vertexPointer( 2, 4, vertices );
Quad.releaseIndices();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, size, GLES20.GL_UNSIGNED_SHORT, indices );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, size, Gdx.gl20.GL_UNSIGNED_SHORT, indices );
Quad.bindIndices();
}
@@ -92,8 +91,8 @@ public class NoosaScript extends Script {
vertices.position( 2 );
aUV.vertexPointer( 2, 4, vertices );
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuad( Vertexbuffer buffer ) {
@@ -106,8 +105,8 @@ public class NoosaScript extends Script {
aUV.vertexBuffer( 2, 4, 2 );
buffer.release();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuadSet( FloatBuffer vertices, int size ) {
@@ -121,8 +120,8 @@ public class NoosaScript extends Script {
vertices.position( 2 );
aUV.vertexPointer( 2, 4, vertices );
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE * size, Gdx.gl20.GL_UNSIGNED_SHORT, 0 );
}
public void drawQuadSet( Vertexbuffer buffer, int length, int offset ){
@@ -139,8 +138,8 @@ public class NoosaScript extends Script {
aUV.vertexBuffer( 2, 4, 2 );
buffer.release();
GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset );
Gdx.gl20.glDrawElements( Gdx.gl20.GL_TRIANGLES, Quad.SIZE * length, Gdx.gl20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset );
}
public void lighting( float rm, float gm, float bm, float am, float ra, float ga, float ba, float aa ) {
@@ -161,14 +160,14 @@ public class NoosaScript extends Script {
uCamera.valueM4( camera.matrix );
if (!camera.fullScreen) {
GLES20.glEnable( GLES20.GL_SCISSOR_TEST );
GLES20.glScissor(
Gdx.gl20.glEnable( Gdx.gl20.GL_SCISSOR_TEST );
Gdx.gl20.glScissor(
camera.x,
Game.height - camera.screenHeight - camera.y,
camera.screenWidth,
camera.screenHeight);
} else {
GLES20.glDisable( GLES20.GL_SCISSOR_TEST );
Gdx.gl20.glDisable( Gdx.gl20.GL_SCISSOR_TEST );
}
}
}
@@ -184,23 +183,34 @@ public class NoosaScript extends Script {
private static final String SHADER =
"uniform mat4 uCamera;" +
"uniform mat4 uModel;" +
"attribute vec4 aXYZW;" +
"attribute vec2 aUV;" +
"varying vec2 vUV;" +
"void main() {" +
" gl_Position = uCamera * uModel * aXYZW;" +
" vUV = aUV;" +
"}" +
//vertex shader
"uniform mat4 uCamera;\n" +
"uniform mat4 uModel;\n" +
"attribute vec4 aXYZW;\n" +
"attribute vec2 aUV;\n" +
"varying vec2 vUV;\n" +
"void main() {\n" +
" gl_Position = uCamera * uModel * aXYZW;\n" +
" vUV = aUV;\n" +
"}\n" +
//this symbol separates the vertex and fragment shaders (see Script.compile)
"//\n" +
"varying mediump vec2 vUV;" +
"uniform lowp sampler2D uTex;" +
"uniform lowp vec4 uColorM;" +
"uniform lowp vec4 uColorA;" +
"void main() {" +
" gl_FragColor = texture2D( uTex, vUV ) * uColorM + uColorA;" +
"}";
//fragment shader
//preprocessor directives let us define precision on GLES platforms, and ignore it elsewhere
"#ifdef GL_ES\n" +
" #define LOW lowp\n" +
" #define MED mediump\n" +
"#else\n" +
" #define LOW\n" +
" #define MED\n" +
"#endif\n" +
"varying MED vec2 vUV;\n" +
"uniform LOW sampler2D uTex;\n" +
"uniform LOW vec4 uColorM;\n" +
"uniform LOW vec4 uColorA;\n" +
"void main() {\n" +
" gl_FragColor = texture2D( uTex, vUV ) * uColorM + uColorA;\n" +
"}\n";
}