65 if(!sp.link(
gl, System.err)) {
66 throw GLException(
"Couldn't link program: "+sp);
68 sp.useProgram(
gl,
true);
71 pmvMatrix =
new PMVMatrix4f();
72 pmvMatrix.loadPIdentity();
73 pmvMatrix.loadMvIdentity();
74 pmvMatrixUniform =
new GLUniformData(
"mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
75 if( pmvMatrixUniform.setLocation(
gl, sp.program()) < 0 ) {
76 throw GLException(
"Couldn't locate "+pmvMatrixUniform+
" in shader: "+sp);
78 gl.glUniform(pmvMatrixUniform);
80 activeTexUniform =
new GLUniformData(
"mgl_Texture0", textureUnit);
81 if( activeTexUniform.setLocation(
gl, sp.program()) < 0 ) {
82 throw GLException(
"Couldn't locate "+activeTexUniform+
" in shader: "+sp);
84 gl.glUniform(activeTexUniform);
86 final float[] s_quadTexCoords;
87 if( textureVertFlipped ) {
88 s_quadTexCoords = s_quadTexCoords01;
90 s_quadTexCoords = s_quadTexCoords00;
95 final GLArrayData vArrayData = interleavedVBO.addGLSLSubArray(
"mgl_Vertex", 3,
GL.GL_ARRAY_BUFFER);
97 throw GLException(
"Couldn't locate "+vArrayData+
" in shader: "+sp);
99 final GLArrayData tArrayData = interleavedVBO.addGLSLSubArray(
"mgl_MultiTexCoord", 2,
GL.GL_ARRAY_BUFFER);
101 throw GLException(
"Couldn't locate "+tArrayData+
" in shader: "+sp);
103 final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
104 for(
int i=0; i<4; i++) {
105 ib.put(s_quadVertices, i*3, 3);
106 ib.put(s_quadTexCoords, i*2, 2);
109 interleavedVBO.seal(
gl,
true);
110 interleavedVBO.enableBuffer(
gl,
false);
112 sp.useProgram(
gl,
false);
115 public void reshape(
final GL2ES2
gl,
final int x,
final int y,
final int width,
final int height) {
117 pmvMatrix.loadPIdentity();
118 pmvMatrix.orthoP(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f);
120 pmvMatrix.loadMvIdentity();
122 sp.useProgram(
gl,
true);
123 gl.glUniform(pmvMatrixUniform);
124 sp.useProgram(
gl,
false);