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:
parent
9174cae000
commit
1f4d42ab4c
|
@ -12,6 +12,7 @@ import com.badlogic.gdx.math.collision.BoundingBox;
|
||||||
import com.badlogic.gdx.math.collision.Ray;
|
import com.badlogic.gdx.math.collision.Ray;
|
||||||
import com.badlogic.gdx.math.collision.Segment;
|
import com.badlogic.gdx.math.collision.Segment;
|
||||||
import com.badlogic.gdx.math.collision.Sphere;
|
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
|
* 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() {
|
public DebugGeometryRenderer() {
|
||||||
if (Gdx.graphics.isGL20Available())
|
if (Gdx.graphics.isGL20Available())
|
||||||
renderer = new ImmediateModeRenderer20(false, true, 0);
|
renderer = new ImmediateModeRenderer20(5000, false, true, 0, new DebugShader());
|
||||||
else
|
else
|
||||||
renderer = new ImmediateModeRenderer10();
|
renderer = new ImmediateModeRenderer10();
|
||||||
}
|
}
|
||||||
|
|
36
src/com/blarg/gdx/graphics/shaders/DebugShader.java
Normal file
36
src/com/blarg/gdx/graphics/shaders/DebugShader.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue