Last active
August 29, 2015 14:23
-
-
Save defHLT/b8676351330962186a2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyGdxGame extends ApplicationAdapter { | |
private ShaderProgram shaderProgram; | |
private Mesh mesh; | |
@Override | |
public void create () { | |
texture = new Texture(Gdx.files.internal("texture_default.jpg")); | |
batch = new SpriteBatch(); | |
sprite = new Sprite(texture); | |
FileHandle f = Gdx.files.internal("f_shader.glsl"); | |
FileHandle v = Gdx.files.internal("v_shader.glsl"); | |
shaderProgram = new ShaderProgram(v, f); | |
ShaderProgram.pedantic = false; | |
mesh = new Mesh(true, 4, 6, VertexAttribute.Position());//, VertexAttribute.TexCoords(0)); | |
mesh.setVertices(new float[] | |
{-0.5f, -0.5f, 0, | |
0.5f, -0.5f, 0, | |
0.5f, 0.5f, 0, | |
-0.5f, 0.5f, 0, }); | |
mesh.setIndices(new short[]{0, 1, 2, 2, 3, 0}); | |
if(!shaderProgram.isCompiled()) { | |
String log = shaderProgram.getLog(); | |
Gdx.app.log("Log", log); | |
} | |
} | |
@Override | |
public void render () { | |
Matrix4 o = new Matrix4(); | |
o.setToOrtho2D(0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); | |
shaderProgram.begin(); | |
shaderProgram.setUniformMatrix("u_projViewTrans", cam.combined); | |
shaderProgram.end(); | |
mesh.bind(shaderProgram); | |
mesh.render(shaderProgram, GL20.GL_TRIANGLES); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment