/** Creates a triangle batch with the supplied custom shader program. */ public TriangleBatch (GL20 gl, Source source) { super(gl); delayedBinding = "Intel".equals(gl.glGetString(GL20.GL_VENDOR)); program = new GLProgram(gl, source.vertex(), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); aMatrix = program.getAttribLocation("a_Matrix"); aTranslation = program.getAttribLocation("a_Translation"); aColor = program.getAttribLocation("a_Color"); aPosition = program.getAttribLocation("a_Position"); aTexCoord = program.getAttribLocation("a_TexCoord"); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = new float[START_VERTS*vertexSize()]; elements = new short[START_ELEMS]; // create our GL buffers int[] ids = new int[2]; gl.glGenBuffers(2, ids, 0); verticesId = ids[0]; elementsId = ids[1]; gl.checkError("TriangleBatch end ctor"); }
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); gl.glUniform1f(uAngle, angle); }
public RotateYBatch (GL20 gl, final float eyeX, final float eyeY, final float zScale) { super(gl, new Source() { @Override public String vertex () { return RotateYBatch.vertex(eyeX, eyeY, zScale); }}); uAngle = program.getUniformLocation("u_Angle"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("TriangleBatch close"); }
gl.checkError("glCreateProgram"); vertexShader = compileShader(GL20.GL_VERTEX_SHADER, vertexSource); gl.glAttachShader(id, vertexShader); gl.checkError("glAttachShader / vertex"); fragmentShader = compileShader(GL20.GL_FRAGMENT_SHADER, fragmentSource); gl.glAttachShader(id, fragmentShader); gl.checkError("glAttachShader / fragment");
public RotYBatch (GL20 gl) { super(gl, new Source()); uAngle = program.getUniformLocation("u_Angle"); uEye = program.getUniformLocation("u_Eye"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
gl.checkError("glCreateProgram"); vertexShader = compileShader(GL20.GL_VERTEX_SHADER, vertexSource); gl.glAttachShader(id, vertexShader); gl.checkError("glAttachShader / vertex"); fragmentShader = compileShader(GL20.GL_FRAGMENT_SHADER, fragmentSource); gl.glAttachShader(id, fragmentShader); gl.checkError("glAttachShader / fragment");
/** Creates a triangle batch with the supplied custom shader program. */ public TriangleBatch (GL20 gl, Source source) { super(gl); delayedBinding = "Intel".equals(gl.glGetString(GL20.GL_VENDOR)); program = new GLProgram(gl, source.vertex(), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); aMatrix = program.getAttribLocation("a_Matrix"); aTranslation = program.getAttribLocation("a_Translation"); aColor = program.getAttribLocation("a_Color"); aPosition = program.getAttribLocation("a_Position"); aTexCoord = program.getAttribLocation("a_TexCoord"); // create our vertex and index buffers stableAttrs = new float[stableAttrsSize()]; vertices = new float[START_VERTS*vertexSize()]; elements = new short[START_ELEMS]; // create our GL buffers int[] ids = new int[2]; gl.glGenBuffers(2, ids, 0); verticesId = ids[0]; elementsId = ids[1]; gl.checkError("TriangleBatch end ctor"); }
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); // certain graphics cards (I'm looking at you, Intel) exhibit broken behavior if we bind our // attributes once during activation, so for those cards we bind every time in flush() if (!delayedBinding) bindAttribsBufs(); gl.checkError("TriangleBatch begin"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("UniformQuadBatch close"); }
maxQuads = maxVecs / vec4sPerQuad(); program = new GLProgram(gl, source.vertex(this), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); uData = program.getUniformLocation("u_Data"); aVertex = program.getAttribLocation("a_Vertex");
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); // certain graphics cards (I'm looking at you, Intel) exhibit broken behavior if we bind our // attributes once during activation, so for those cards we bind every time in flush() if (!delayedBinding) bindAttribsBufs(); gl.checkError("TriangleBatch begin"); }
@Override public void close () { super.close(); program.close(); gl.glDeleteBuffers(2, new int[] { verticesId, elementsId }, 0); gl.checkError("TriangleBatch close"); }
maxQuads = maxVecs / vec4sPerQuad(); program = new GLProgram(gl, source.vertex(this), source.fragment()); uTexture = program.getUniformLocation("u_Texture"); uHScreenSize = program.getUniformLocation("u_HScreenSize"); uFlip = program.getUniformLocation("u_Flip"); uData = program.getUniformLocation("u_Data"); aVertex = program.getAttribLocation("a_Vertex");
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); // TODO: apparently we can avoid glUniform calls because they're part of the program state; so // we can cache the last set values for all these glUniform calls and only set them anew if // they differ... gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); gl.glBindBuffer(GL_ARRAY_BUFFER, verticesId); gl.glEnableVertexAttribArray(aVertex); gl.glVertexAttribPointer(aVertex, VERTEX_SIZE, GL_SHORT, false, 0, 0); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsId); gl.glActiveTexture(GL_TEXTURE0); gl.glUniform1i(uTexture, 0); gl.checkError("UniformQuadBatch begin"); }
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); // TODO: apparently we can avoid glUniform calls because they're part of the program state; so // we can cache the last set values for all these glUniform calls and only set them anew if // they differ... gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); gl.glBindBuffer(GL_ARRAY_BUFFER, verticesId); gl.glEnableVertexAttribArray(aVertex); gl.glVertexAttribPointer(aVertex, VERTEX_SIZE, GL_SHORT, false, 0, 0); gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementsId); gl.glActiveTexture(GL_TEXTURE0); gl.glUniform1i(uTexture, 0); gl.checkError("UniformQuadBatch begin"); }