コード例 #1
0
  @Override
  protected void onDraw(Canvas canvas) {
    GL11 gl = (GL11) context.getGL();
    int w = getWidth();
    int h = getHeight();

    context.waitNative(canvas, this);

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glViewport(0, 0, w, h);
    GLU.gluPerspective(gl, 45.0f, ((float) w) / h, 1f, 100f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    GLU.gluLookAt(gl, 0, 0, 5, 0, 0, 0, 0, 1, 0);
    gl.glTranslatef(0, 0, -10);
    gl.glRotatef(30.0f, 1, 0, 0);
    // gl.glRotatef(40.0f, 0, 1, 0);

    gl.glVertexPointer(3, GL10.GL_FIXED, 0, vertices[frame_ix]);
    gl.glNormalPointer(GL10.GL_FIXED, 0, normals);
    gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, texCoords);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    // gl.glColor4f(1,0,0,1);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
    // gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
    gl.glDrawElements(GL10.GL_TRIANGLES, verts, GL10.GL_UNSIGNED_SHORT, indices);

    frame_ix = (frame_ix + 1) % m.getFrameCount();
    context.waitGL();
  }
コード例 #2
0
 public void clearBuffer() {
   mGL.glClear(GL10.GL_COLOR_BUFFER_BIT);
 }