I guess this thread should be moved to debugging.
ok. Got any ideas why this doesn’t display anything?
public class IsoMap {
private ShaderProgram isoShader;
private int vertexHandle = 0;
public IsoMap() {
}
public void create() {
isoShader = new ShaderProgram(Gdx.files.internal("shaders/VertexIso.txt"), Gdx.files.internal("shaders/FragmentIso.txt"));
createBuffers();
float x = 100, y = 100, width = 100, height = 100;
float z = 0;
int size = 3 * 3;
FloatBuffer buffer = BufferUtils.newFloatBuffer(size);
buffer.put(x).put(y).put(z);
buffer.put(x).put(y + height).put(z);
buffer.put(x + width).put(y).put(z);
buffer.flip();
bind(vertexHandle);
Gdx.gl20.glBufferData(GL20.GL_ARRAY_BUFFER, size, buffer, GL20.GL_STATIC_DRAW);
bind(0);
String log = isoShader.getLog();
if (log.length() > 0) System.out.println(log);
}
private void createBuffers() {
IntBuffer intBuffer = BufferUtils.newIntBuffer(1);
Gdx.gl20.glGenBuffers(1, intBuffer);
vertexHandle = intBuffer.get(0);
}
public void draw() {
isoShader.begin();
Matrix4 projectionMatrix = new Matrix4().setToOrtho(Gdx.graphics.getWidth(), 0, Gdx.graphics.getHeight(), 0, -1, 1);
isoShader.setUniformMatrix(isoShader.getUniformLocation("u_projTrans"), projectionMatrix, false);
isoShader.enableVertexAttribute("a_position");
bind(vertexHandle);
Gdx.gl20.glVertexAttribPointer(isoShader.getAttributeLocation("a_position"), 3, GL20.GL_FLOAT, false, 0, 0);
bind(0);
Gdx.gl20.glDrawArrays(GL20.GL_TRIANGLES, 0, 3);
isoShader.disableVertexAttribute("a_position");
isoShader.end();
}
private static final void bind(int buffer) {
Gdx.gl20.glBindBuffer(GL20.GL_ARRAY_BUFFER, buffer);
}
}
attribute vec3 a_position;
uniform mat4 u_projTrans;
void main() {
gl_Position = vec4(a_position, 1) * u_projTrans;
}
#ifdef GL_ES
precision mediump float;
#endif
void main() {
gl_FragColor = vec4(1.0,1.0,1.0,1.0);
}