@Override public void render() { Gdx.gl20.glViewport( 0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); shader.begin(); shader.setUniform2fv( "u_resolution", new float[] {(float) Gdx.graphics.getWidth(), (float) Gdx.graphics.getHeight()}, 0, 2); shader.setUniformf("u_time", TimeUtils.timeSinceMillis(startTime) / 1000f); shader.setUniform2fv( "u_mousePos", new float[] {Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()}, 0, 2); mesh.render(shader, GL20.GL_TRIANGLES); shader.end(); }
// float[], vec2[], vec3[], vec4[] protected T setParamv(Parameter param, float[] values, int offset, int length) { program.begin(); switch (param.arrayElementSize()) { case 4: program.setUniform4fv(param.mnemonic(), values, offset, length); break; case 3: program.setUniform3fv(param.mnemonic(), values, offset, length); break; case 2: program.setUniform2fv(param.mnemonic(), values, offset, length); break; default: case 1: program.setUniform1fv(param.mnemonic(), values, offset, length); break; } program.end(); return (T) this; }