示例#1
0
  public void display(final GLAutoDrawable drawable) {
    final GL2ES2 gl = drawable.getGL().getGL2ES2();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    final RegionRenderer regionRenderer = getRenderer();
    final PMVMatrix pmv = regionRenderer.getMatrix();
    pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmv.glLoadIdentity();
    pmv.glTranslatef(getXTran(), getYTran(), getZTran());
    pmv.glRotatef(getAngle(), 0, 1, 0);
    if (weight != regionRenderer.getRenderState().getWeight()) {
      regionRenderer.getRenderState().setWeight(weight);
    }
    region.draw(gl, regionRenderer, getSampleCount());
  }
示例#2
0
  public void display(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    mats.glMatrixMode(GL2.GL_MODELVIEW);
    mats.glLoadIdentity();
    mats.glTranslatef(0f, 0f, -2.0f);
    // t = t+0.5f;
    t = 40f;
    mats.glRotatef(t, 0f, 1f, 0f);
    mats.glMatrixMode(GL2.GL_PROJECTION);
    mats.glLoadIdentity();
    mats.glFrustumf(-1f, 1f, -1f, 1f, 1f, 100f);
    mats.update();
    gl.glUseProgram(shader.getID());
    gl.glUniformMatrix4fv(uniformMat, 3, false, mats.glGetPMvMviMatrixf());

    obj.display(gl, mats);
    gl.glFlush();
    gl.glUseProgram(0);
  }
示例#3
0
  @Override
  public void display(final GLAutoDrawable glad) {
    final long t1 = System.currentTimeMillis();

    final GL2ES2 gl = glad.getGL().getGL2ES2();
    if (clearBuffers) {
      if (null != tileRendererInUse) {
        gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
      } else {
        gl.glClearColor(0, 0, 0, 0);
      }
      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    }
    if (!gl.hasGLSL()) {
      return;
    }
    st.useProgram(gl, true);
    // One rotation every four seconds
    pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.glTranslatef(0, 0, -10);
    if (doRotate) {
      final float ang = ((t1 - t0) * 360.0F) / 4000.0F;
      pmvMatrix.glRotatef(ang, 0, 0, 1);
      pmvMatrix.glRotatef(ang, 0, 1, 0);
    }
    st.uniform(gl, pmvMatrixUniform);

    // Draw a square
    vertices.enableBuffer(gl, true);
    colors.enableBuffer(gl, true);
    gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
    vertices.enableBuffer(gl, false);
    colors.enableBuffer(gl, false);
    st.useProgram(gl, false);
  }