Exemplo n.º 1
0
    @Override
    public void present(float deltaTime) {
      gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      camera.setViewportAndMatrices();

      gl.glColor4f(0, 1, 0, 1);
      targetVertices.bind();
      int len = targets.size();
      for (int i = 0; i < len; i++) {
        GameObject target = targets.get(i);
        gl.glLoadIdentity();
        gl.glTranslatef(target.position.x, target.position.y, 0);
        targetVertices.draw(GL10.GL_TRIANGLES, 0, 6);
      }
      targetVertices.unbind();

      gl.glLoadIdentity();
      gl.glTranslatef(ball.position.x, ball.position.y, 0);
      gl.glColor4f(1, 0, 0, 1);
      ballVertices.bind();
      ballVertices.draw(GL10.GL_TRIANGLES, 0, 6);
      ballVertices.unbind();

      gl.glLoadIdentity();
      gl.glTranslatef(cannon.position.x, cannon.position.y, 0);
      gl.glRotatef(cannon.angle, 0, 0, 1);
      gl.glColor4f(1, 1, 1, 1);
      cannonVertices.bind();
      cannonVertices.draw(GL10.GL_TRIANGLES, 0, 3);
      cannonVertices.unbind();
    }
Exemplo n.º 2
0
    @Override
    public void present(float deltaTime) {
      GL10 gl = glGraphics.getGL();
      gl.glClearColor(1, 0, 0, 1);
      gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      gl.glMatrixMode(GL10.GL_PROJECTION);
      gl.glLoadIdentity();
      gl.glOrthof(0, 320, 0, 480, 1, -1);

      gl.glEnable(GL10.GL_TEXTURE_2D);
      bobTexture.bind();

      gl.glMatrixMode(GL10.GL_MODELVIEW);
      for (int i = 0; i < NUM_BOBS; i++) {
        gl.glLoadIdentity();
        gl.glTranslatef(bobs[i].x, bobs[i].y, 0);
        gl.glRotatef(45, 0, 0, 1);
        gl.glScalef(2, 0.5f, 0);
        bobModel.draw(GL10.GL_TRIANGLES, 0, 6);
      }

      fpsCounter.logFrame();
    }