• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.badlogic.gdx.tests;
2 
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.graphics.GL20;
5 import com.badlogic.gdx.graphics.Texture;
6 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
7 import com.badlogic.gdx.graphics.glutils.ShaderProgram;
8 import com.badlogic.gdx.tests.utils.GdxTest;
9 
10 
11 public class GLES30Test extends GdxTest {
12 
13     SpriteBatch batch;
14     Texture texture;
15     ShaderProgram shaderProgram;
16 
17     @Override
create()18     public void create() {
19         Gdx.app.log("GLES30Test", "GL_VERSION = " + Gdx.gl.glGetString(GL20.GL_VERSION));
20         batch = new SpriteBatch();
21         texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
22         shaderProgram = new ShaderProgram(Gdx.files.internal("data/shaders/gles30sprite.vert"), Gdx.files.internal("data/shaders/gles30sprite.frag"));
23         Gdx.app.log("GLES30Test", shaderProgram.getLog());
24         if (shaderProgram.isCompiled()) {
25             Gdx.app.log("GLES30Test", "Shader compiled");
26             batch.setShader(shaderProgram);
27         }
28     }
29 
30     @Override
render()31     public void render() {
32         Gdx.gl.glClearColor(0, 0, 0, 1f);
33         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
34 
35         batch.begin();
36         batch.draw(texture, 0, 0, Gdx.graphics.getWidth()/2f, Gdx.graphics.getHeight()/2f);
37         batch.end();
38     }
39 
40     @Override
dispose()41     public void dispose() {
42         texture.dispose();
43         batch.dispose();
44         shaderProgram.dispose();
45     }
46 }
47