Esempio n. 1
0
 public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
   GL2 gl = drawable.getGL().getGL2();
   //
   gl.glViewport(0, 0, w, h);
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   if (w <= (h * 3))
     gl.glOrtho(
         -6.0,
         6.0,
         -2.0 * ((float) h * 3) / (float) w,
         2.0 * ((float) h * 3) / (float) w,
         0.0,
         10.0);
   else
     gl.glOrtho(
         -6.0 * (float) w / ((float) h * 3), //
         6.0 * (float) w / ((float) h * 3),
         -2.0,
         2.0,
         0.0,
         10.0);
   gl.glMatrixMode(GL2.GL_MODELVIEW);
   gl.glLoadIdentity();
 }
  @Override
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    GL2 gl = drawable.getGL().getGL2();
    gl.glMatrixMode(GL_PROJECTION);
    gl.glLoadIdentity();
    glu.gluPerspective(30.0, (double) width / (double) height, 1.0, 300.0);

    // 視点位置と視線方向
    // glu.gluLookAt(3.0f, 4.0f, 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);//コメントアウト

    gl.glMatrixMode(GL_MODELVIEW);
  }
Esempio n. 3
0
  @Override
  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
    final GL2 gl = drawable.getGL().getGL2();
    if (height <= 0) height = 1;

    final float h = (float) width / (float) height;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL2.GL_PROJECTION);
    gl.glLoadIdentity();

    glu.gluPerspective(FOV, h, 1.0, 4000.0);
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
Esempio n. 4
0
  @Override
  public void reshape(
      final GLAutoDrawable gLDrawable, final int x, final int y, final int w, final int h) {
    final GL2 gl = gLDrawable.getGL().getGL2();

    gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
    gl.glLoadIdentity();
    if (w <= h) {
      gl.glOrtho(-3.5, 3.5, -3.5 * h / w, 3.5 * h / w, -3.5, 3.5);
    } else {
      gl.glOrtho(-3.5 * w / h, 3.5 * w / h, -3.5, 3.5, -3.5, 3.5);
    }
    gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    gl.glLoadIdentity();
  }
Esempio n. 5
0
 public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
   GL2 gl = drawable.getGL().getGL2();
   //
   gl.glViewport(0, 0, w, h);
   gl.glMatrixMode(GL2.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluOrtho2D(0.0, (double) w, 0.0, (double) h);
 }
Esempio n. 6
0
  /* (non-Javadoc)
   * @see com.jogamp.opengl.GLEventListener#init(com.jogamp.opengl.GLAutoDrawable)
   */
  @Override
  public void init(GLAutoDrawable glDrawable) {
    // get the OpenGL context
    GL2 gl = glDrawable.getGL().getGL2();

    // set the matrix mode to projection
    gl.glMatrixMode(GL2.GL_PROJECTION);
    // initialize the matrix
    gl.glLoadIdentity();
    // set the view to a 2D view
    gl.glOrtho(-400, 400, -300, 300, 0, 1);

    // switch to the model view matrix
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    // initialize the matrix
    gl.glLoadIdentity();

    // set the clear color to white
    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    // set the swap interval to as fast as possible
    gl.setSwapInterval(0);
  }
Esempio n. 7
0
  /* (non-Javadoc)
   * @see com.jogamp.opengl.GLEventListener#display(com.jogamp.opengl.GLAutoDrawable)
   */
  @Override
  public void display(GLAutoDrawable glDrawable) {
    // get the OpenGL context
    GL2 gl = glDrawable.getGL().getGL2();

    // clear the screen
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    // switch to the model view matrix
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    // initialize the matrix (0,0) is in the center of the window
    gl.glLoadIdentity();

    // render the scene
    this.render(gl);

    // perform other operations at the end (it really
    // doesn't matter if its done at the start or end)
    this.update();
  }
  @Override
  public void display(GLAutoDrawable pDrawable) {

    if (error) {
      return;
    }

    countFps();

    simpleMoveAnimator.updateState();

    GL2 gl = pDrawable.getGL().getGL2();
    // System.err.println("INIT GL IS: " + gl.getClass().getName());

    GLU glu = new GLU();

    lightRender.draw(gl);

    // _direction_
    // gl.glLightfv(GLLightingFunc.GL_LIGHT0, GLLightingFunc.GL_POSITION,
    // this.lightPos, 0);

    // // Clear the drawing area
    // gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    //
    //
    //
    //
    // // Reset the current matrix to the "identity"
    // gl.glLoadIdentity();
    //
    // gl.glMatrixMode(GL2.GL_MODELVIEW);
    // gl.glLoadIdentity();

    // clear color and depth buffers
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    // gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
    gl.glLoadIdentity();

    setCamera(gl, glu, simpleMoveAnimator);

    gl.glEnable(GL.GL_MULTISAMPLE);

    skyBox.draw(gl, simpleMoveAnimator.getPoint());

    ground.draw(gl, simpleMoveAnimator.getPoint());

    if (modelRender.isDebugging()) {

      axisLabels.draw(gl);

      floor.draw(gl);

      // drawTextInfo(gl, simpleMoveAnimator.info());
    }

    renderJosm.draw(gl, simpleMoveAnimator);

    // selectionDrawUtil.draw(gl, objectSelectionListener,
    // simpleMoveAnimator);

    drawCompass(gl);

    // Flush all drawing operations to the graphics card
    gl.glFlush();
  }
Esempio n. 9
0
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl2 = drawable.getGL().getGL2();
    GLU glu = GLU.createGLU();

    gl2.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl2.glEnable(GL2.GL_DEPTH_TEST);
    gl2.glDisable(GL2.GL_CULL_FACE);

    gl2.glMatrixMode(GL2.GL_PROJECTION);
    gl2.glLoadIdentity();
    glu.gluPerspective(60, drawable.getSurfaceWidth() / drawable.getSurfaceHeight(), 0.1f, 100);

    gl2.glMatrixMode(GL2.GL_MODELVIEW);
    gl2.glLoadIdentity();

    camera_.apply(gl2, glu);
    light_.apply(gl2, glu);

    terrain_.draw(gl2, glu);

    Runnable triangle =
        () -> {
          gl2.glBegin(GL2.GL_TRIANGLES);
          {
            gl2.glColor3f(1, 1, 1);
            gl2.glNormal3f(0, 0, 1);
            gl2.glVertex3f(0, 1, 0);
            gl2.glColor3f(1, 0, 0);
            gl2.glNormal3f(0, 0, 1);
            gl2.glVertex3f(-0.87f, -0.5f, 0);
            gl2.glColor3f(0, 0, 1);
            gl2.glNormal3f(0, 0, 1);
            gl2.glVertex3f(0.87f, -0.5f, 0);

            gl2.glColor3f(1, 1, 1);
            gl2.glNormal3f(0.71898836f, 0.4170133f, -0.5560177f);
            gl2.glVertex3f(0, 1, 0);
            gl2.glColor3f(0, 0, 1);
            gl2.glNormal3f(0.71898836f, 0.4170133f, -0.5560177f);
            gl2.glVertex3f(0.87f, -0.5f, 0);
            gl2.glColor3f(0, 1, 0);
            gl2.glNormal3f(0.71898836f, 0.4170133f, -0.5560177f);
            gl2.glVertex3f(0, 0, -0.75f);

            gl2.glColor3f(1, 0, 0);
            gl2.glNormal3f(-0.7189883f, 0.41701326f, -0.5560177f);
            gl2.glVertex3f(-0.87f, -0.5f, 0);
            gl2.glColor3f(1, 1, 1);
            gl2.glNormal3f(-0.7189883f, 0.41701326f, -0.5560177f);
            gl2.glVertex3f(0, 1, 0);
            gl2.glColor3f(0, 1, 0);
            gl2.glNormal3f(-0.7189883f, 0.41701326f, -0.5560177f);
            gl2.glVertex3f(0, 0, -0.75f);

            gl2.glColor3f(0, 0, 1);
            gl2.glNormal3f(0, -1.305f, -0.87f);
            gl2.glVertex3f(0.87f, -0.5f, 0);
            gl2.glColor3f(1, 0, 0);
            gl2.glNormal3f(0, -1.305f, -0.87f);
            gl2.glVertex3f(-0.87f, -0.5f, 0);
            gl2.glColor3f(0, 1, 0);
            gl2.glNormal3f(0, -1.305f, -0.87f);
            gl2.glVertex3f(0, 0, -0.75f);
          }
          gl2.glEnd();
        };

    gl2.glPushMatrix();
    {
      gl2.glPushMatrix();
      gl2.glTranslatef(0, 0, 0);
      gl2.glRotatef(angle__, 0, 1, 0);
      triangle.run();
      gl2.glPopMatrix();

      gl2.glPushMatrix();
      gl2.glTranslatef(0, 3.2f, 0);
      gl2.glRotatef(angle__ + 30, 0, 1, 0);
      triangle.run();
      gl2.glPopMatrix();

      gl2.glPushMatrix();
      gl2.glTranslatef(3.2f, 0, 0);
      gl2.glRotatef(angle__ + 60, 0, 1, 0);
      triangle.run();
      gl2.glPopMatrix();
    }
    gl2.glPopMatrix();
    angle__ += 1;

    gl2.glPushMatrix();
    gl2.glTranslatef(0.05f, -1.5f, 5);
    gl2.glScalef(0.05f, 0.05f, 0.05f);
    for (Face face : glock3__.faces) {
      gl2.glBegin(GL2.GL_POLYGON);
      for (FaceVertex vertex : face.vertices) {
        gl2.glColor3f(1, 1, 1);
        gl2.glNormal3f(vertex.n.x, vertex.n.y, vertex.n.z);
        gl2.glVertex3f(vertex.v.x, vertex.v.y, vertex.v.z);
      }
      gl2.glEnd();
    }
    gl2.glPopMatrix();
  }