draw both sides of tile as its rotating
This commit is contained in:
parent
20953f9141
commit
13ee04baea
@ -169,6 +169,7 @@ public class MyRenderer implements GLSurfaceView.Renderer
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLES20.glClearColor(1.0f, 0.6f, 0.1f, 1.0f);
|
GLES20.glClearColor(1.0f, 0.6f, 0.1f, 1.0f);
|
||||||
|
GLES20.glEnable(GLES20.GL_CULL_FACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update_tiles(long elapsed)
|
private void update_tiles(long elapsed)
|
||||||
@ -219,6 +220,11 @@ public class MyRenderer implements GLSurfaceView.Renderer
|
|||||||
for (int x = 0; x < GRID_WIDTH; x++)
|
for (int x = 0; x < GRID_WIDTH; x++)
|
||||||
{
|
{
|
||||||
Tile t = m_tiles[x][y];
|
Tile t = m_tiles[x][y];
|
||||||
|
for (int side = 0; side < 2; side++)
|
||||||
|
{
|
||||||
|
int t_side = t.side ? 1 : 0;
|
||||||
|
if (!t.flipping && (side == 1))
|
||||||
|
continue;
|
||||||
Matrix.setIdentityM(m_modelview, 0);
|
Matrix.setIdentityM(m_modelview, 0);
|
||||||
Matrix.translateM(m_modelview, 0,
|
Matrix.translateM(m_modelview, 0,
|
||||||
x + 0.5f - GRID_WIDTH / 2.0f,
|
x + 0.5f - GRID_WIDTH / 2.0f,
|
||||||
@ -227,7 +233,7 @@ public class MyRenderer implements GLSurfaceView.Renderer
|
|||||||
if (t.flipping)
|
if (t.flipping)
|
||||||
{
|
{
|
||||||
Matrix.rotateM(m_modelview, 0,
|
Matrix.rotateM(m_modelview, 0,
|
||||||
t.rotation,
|
t.rotation + side * 180.0f,
|
||||||
AXES[t.axis][0], AXES[t.axis][1], AXES[t.axis][2]);
|
AXES[t.axis][0], AXES[t.axis][1], AXES[t.axis][2]);
|
||||||
}
|
}
|
||||||
GLES20.glUniformMatrix4fv(
|
GLES20.glUniformMatrix4fv(
|
||||||
@ -235,12 +241,13 @@ public class MyRenderer implements GLSurfaceView.Renderer
|
|||||||
1, false, m_modelview, 0);
|
1, false, m_modelview, 0);
|
||||||
GLES20.glUniform1i(
|
GLES20.glUniform1i(
|
||||||
GLES20.glGetUniformLocation(m_program, "side"),
|
GLES20.glGetUniformLocation(m_program, "side"),
|
||||||
t.side ? 1 : 0);
|
t_side ^ side);
|
||||||
|
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 4);
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 4);
|
||||||
checkGLError("glDrawArrays");
|
checkGLError("glDrawArrays");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GLES20.glDisableVertexAttribArray(attr_pos);
|
GLES20.glDisableVertexAttribArray(attr_pos);
|
||||||
GLES20.glDisableVertexAttribArray(attr_color);
|
GLES20.glDisableVertexAttribArray(attr_color);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user