private void setStaticProjectionAndCamera(Graphics graphics, Application app, GL10 gl) {
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    // x=left-right, y=up-down, z=back-forward
    camera.far = 1000000;
    camera.position.set(0, 7f + 0, 9f + 0);
    // camera.direction.set(0, 0, -4f).sub(camera.position).nor();
    camera.fieldOfView = 67;
    float orbitRadius = (new Vector3(0, 0, 0).dst(camera.position));
    camera.position.set(new Vector3(0, 0, 0));

    camera.rotate(Splash.cameraHorizAngle, 0, 1, 0);
    Vector3 orbitReturnVector = new Vector3(0, 0, 0);
    orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius));
    camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z);
    camera.update();
    camera.apply(gl);

    orbitRadius = (new Vector3(0, 0, 0)).dst(camera.position);
    camera.position.set(new Vector3(0, 0, 0));
    camera.rotate(Splash.cameraVertAngle, 1, 0, 0);
    orbitReturnVector = new Vector3(0, 0, 0);
    orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius));
    camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z);
    camera.update();
    camera.apply(gl);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    Splash.cameraHorizAngle = 0;
    Splash.cameraVertAngle = 0;
  }
示例#2
0
  @Override
  public void render() {
    GL10 gl = Gdx.graphics.getGL10();
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glRotatef(angle, 0, 0, 1);
    angle += angleIncrement;
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    vertices.position(0);
    gl.glColorPointer(4, GL10.GL_FLOAT, BYTES_PER_VERTEX, vertices);

    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glClientActiveTexture(GL10.GL_TEXTURE0);
    gl.glActiveTexture(GL10.GL_TEXTURE0);
    tex.bind();
    vertices.position(4);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, BYTES_PER_VERTEX, vertices);

    gl.glClientActiveTexture(GL10.GL_TEXTURE1);
    gl.glActiveTexture(GL10.GL_TEXTURE1);
    tex2.bind();
    vertices.position(6);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, BYTES_PER_VERTEX, vertices);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    vertices.position(8);
    gl.glVertexPointer(3, GL10.GL_FLOAT, BYTES_PER_VERTEX, vertices);

    gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
  }
示例#3
0
 private void setupMatrices() {
   if (!Gdx.graphics.isGL20Available()) {
     GL10 gl = Gdx.gl10;
     gl.glMatrixMode(GL10.GL_PROJECTION);
     gl.glLoadMatrixf(projectionMatrix.val, 0);
     gl.glMatrixMode(GL10.GL_MODELVIEW);
     gl.glLoadMatrixf(transformMatrix.val, 0);
   } else {
     combinedMatrix.set(projectionMatrix).mul(transformMatrix);
     if (customShader != null) {
       customShader.setUniformMatrix("u_proj", projectionMatrix);
       customShader.setUniformMatrix("u_trans", transformMatrix);
       customShader.setUniformMatrix("u_projTrans", combinedMatrix);
       customShader.setUniformi("u_texture", 0);
     } else {
       shader.setUniformMatrix("u_projectionViewMatrix", combinedMatrix);
       shader.setUniformi("u_texture", 0);
     }
   }
 }