Exemple #1
0
  public void desenhar(GL gl, GLUT glut) {
    gl.glShadeModel(GL.GL_FLAT);
    gl.glNormal3f(0.0f, 0.0f, 1.0f);
    gl.glColor3f(1f, 1f, 1f);

    float corWhite[] = {1.0f, 1.0f, 1.0f, 1.0f};

    // base
    setTexture(Util.loadImage("texture/textureBrick.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, corWhite, 0);
    gl.glEnable(GL.GL_LIGHTING);
    gl.glPushMatrix();
    gl.glTranslatef(0f, -dif, 0f);
    gl.glScalef(getxEscala(), getyEscala(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();

    // esquerda
    setTexture(Util.loadImage("texture/tijolos/medio2.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(-(getxEscala() / 2), (getAltura() / 2) - dif, 0f);
    gl.glScalef(0.1f, getAltura(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);

    // direita
    setTexture(Util.loadImage("texture/tijolos/medio2.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(getxEscala() / 2, (getAltura() / 2) - dif, 0f);
    gl.glScalef(0.1f, getAltura(), getzEscala());
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);

    // fundo
    setTexture(Util.loadImage("texture/tijolos/fraco.png"));
    getTexture().enable();
    getTexture().bind();
    gl.glPushMatrix();
    gl.glTranslatef(0f, (getAltura() / 2) - dif, -(getzEscala() / 2));
    gl.glScalef(getxEscala(), getAltura(), 0.1f);
    glut.glutSolidCube(1f);
    gl.glPopMatrix();
    gl.glDisable(GL.GL_LIGHTING);
  }
Exemple #2
0
 public void render(GL gl) {
   // gl.glLoadIdentity();
   gl.glRasterPos2f(-0.25f + 0.10f * ((float) (Math.cos(0.1))), 0.35f * ((float) (Math.sin(0.1))));
   //	Take a string and make it a bitmap, put it in the 'gl' passed over and pick
   // the GLUT font, then provide the string to show
   glut.glutBitmapString(
       GLUT.BITMAP_HELVETICA_18, "Active OpenGL, in JoGL, Text With NeHe - " + 0.1);
 }
Exemple #3
0
  public void display(GLAutoDrawable glDrawable) {
    GL gl = glDrawable.getGL();

    // Store old matrices
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();

    gl.glViewport(0, 0, glDrawable.getWidth(), glDrawable.getHeight());

    // Store enabled state and disable lighting, texture mapping and the depth buffer
    gl.glPushAttrib(GL.GL_ENABLE_BIT);
    gl.glDisable(GL.GL_BLEND);
    gl.glDisable(GL.GL_LIGHTING);
    gl.glDisable(GL.GL_TEXTURE_2D);
    gl.glDisable(GL.GL_DEPTH_TEST);

    // Retrieve the current viewport and switch to orthographic mode
    IntBuffer viewPort = BufferUtil.newIntBuffer(4);
    gl.glGetIntegerv(GL.GL_VIEWPORT, viewPort);
    glu.gluOrtho2D(0, viewPort.get(2), viewPort.get(3), 0);

    // Render the text
    gl.glColor3f(1, 1, 1);

    int x = OFFSET;
    int maxx = 0;
    int y = OFFSET + CHAR_HEIGHT;

    if (keyboardEntries.size() > 0) {
      gl.glRasterPos2i(x, y);
      glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, KEYBOARD_CONTROLS);
      maxx =
          Math.max(
              maxx, OFFSET + glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, KEYBOARD_CONTROLS));

      y += OFFSET;
      x += INDENT;
      for (int i = 0; i < keyboardEntries.size(); i++) {
        gl.glRasterPos2f(x, y);
        String text = (String) keyboardEntries.get(i);
        glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, text);
        maxx = Math.max(maxx, OFFSET + glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, text));
        y += OFFSET;
      }
    }

    if (mouseEntries.size() > 0) {
      x = maxx + OFFSET;
      y = OFFSET + CHAR_HEIGHT;
      gl.glRasterPos2i(x, y);
      glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, MOUSE_CONTROLS);

      y += OFFSET;
      x += INDENT;
      for (int i = 0; i < mouseEntries.size(); i++) {
        gl.glRasterPos2f(x, y);
        glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, (String) mouseEntries.get(i));
        y += OFFSET;
      }
    }

    // Restore enabled state
    gl.glPopAttrib();

    // Restore old matrices
    gl.glPopMatrix();
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glPopMatrix();
  }