got a grid, but its too small

This commit is contained in:
Josh Holtrop 2012-11-29 23:08:27 -05:00
parent a0bf1f8e4d
commit c7e0b9696d

View File

@ -95,9 +95,9 @@ public class MyRenderer implements GLSurfaceView.Renderer
{
final float attribs[] = {
1, 1,
-1, 1,
-1, -1,
1, -1
0, 1,
0, 0,
1, 0
};
checkGLError("onSurfaceCreated");
ByteBuffer bb = ByteBuffer.allocateDirect(attribs.length * 4);
@ -150,21 +150,34 @@ public class MyRenderer implements GLSurfaceView.Renderer
{
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
Matrix.setIdentityM(m_modelview, 0);
Matrix.translateM(m_modelview, 0, 0, 0, 0);
GLES20.glUniformMatrix4fv(
GLES20.glGetUniformLocation(m_program, "modelview"),
1, false, m_modelview, 0);
int attr_pos = GLES20.glGetAttribLocation(m_program, "pos");
checkGLError("glGetAttribLocation");
GLES20.glEnableVertexAttribArray(attr_pos);
checkGLError("glEnableVertexAttribArray");
m_quad_attrib_buffer.position(0);
GLES20.glVertexAttribPointer(attr_pos, 2, GLES20.GL_FLOAT, false,
2 * 4, m_quad_attrib_buffer);
checkGLError("glVertexAttribPointer");
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 4);
checkGLError("glDrawArrays");
for (int y = 0; y < GRID_HEIGHT; y++)
{
for (int x = 0; x < GRID_WIDTH; x++)
{
Matrix.setIdentityM(m_modelview, 0);
Matrix.translateM(m_modelview, 0,
x - GRID_WIDTH / 2.0f, y - GRID_HEIGHT / 2.0f, 0);
Matrix.scaleM(m_modelview, 0, 0.9f, 0.9f, 0.9f);
GLES20.glUniformMatrix4fv(
GLES20.glGetUniformLocation(m_program, "modelview"),
1, false, m_modelview, 0);
m_quad_attrib_buffer.position(0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 4);
checkGLError("glDrawArrays");
}
}
GLES20.glDisableVertexAttribArray(attr_pos);
checkGLError("glDisableVertexAttribArray");
}