add DebugShader which DebugGeometryRenderer now uses

rendering larger points not implemented yet, need to do a second-pass
render over the points generated in end(), but ImmediateModeRenderer
doesn't allow for this, short of using it to generate the list of
vertices twice
This commit is contained in:
Gered 2013-10-27 17:35:07 -04:00
parent 9174cae000
commit 1f4d42ab4c
2 changed files with 38 additions and 1 deletions

View file

@ -12,6 +12,7 @@ import com.badlogic.gdx.math.collision.BoundingBox;
import com.badlogic.gdx.math.collision.Ray;
import com.badlogic.gdx.math.collision.Segment;
import com.badlogic.gdx.math.collision.Sphere;
import com.blarg.gdx.graphics.shaders.DebugShader;
/**
* Similar idea to {@link com.badlogic.gdx.graphics.glutils.ShapeRenderer}, but provides more convenient methods to
@ -34,7 +35,7 @@ public class DebugGeometryRenderer {
public DebugGeometryRenderer() {
if (Gdx.graphics.isGL20Available())
renderer = new ImmediateModeRenderer20(false, true, 0);
renderer = new ImmediateModeRenderer20(5000, false, true, 0, new DebugShader());
else
renderer = new ImmediateModeRenderer10();
}

View file

@ -0,0 +1,36 @@
package com.blarg.gdx.graphics.shaders;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
public class DebugShader extends ShaderProgram {
public static final String VERTEX_SHADER =
"attribute vec4 a_position;\n" +
"attribute vec4 a_color;\n" +
"uniform mat4 u_projModelView;\n" +
"varying vec4 v_color;\n" +
"\n" +
"void main()\n" +
"{\n" +
" v_color = a_color;\n" +
" gl_PointSize = 4.0;\n" +
" gl_Position = u_projModelView * a_position;\n" +
"}";
public static final String FRAGMENT_SHADER =
"#ifdef GL_ES\n" +
" #define LOWP lowp\n" +
" precision mediump float;\n" +
"#else\n" +
" #define LOWP\n" +
"#endif\n" +
"varying LOWP vec4 v_color;\n" +
"\n" +
"void main()\n" +
"{\n" +
" gl_FragColor = v_color;\n" +
"}\n";
public DebugShader() {
super(VERTEX_SHADER, FRAGMENT_SHADER);
}
}