private static void checkInput() {
   camera.processMouse(1, 80, -80);
   camera.processKeyboard(16, 1, 1, 1);
   glLight(GL_LIGHT0, GL_POSITION, BufferTools.asFlippedFloatBuffer(lightPosition));
   if (Keyboard.isKeyDown(Keyboard.KEY_G)) {
     lightPosition = new float[] {camera.x(), camera.y(), camera.z(), 1};
   }
   if (Mouse.isButtonDown(0)) Mouse.setGrabbed(true);
   else if (Mouse.isButtonDown(1)) Mouse.setGrabbed(false);
 }
 private static void setUpCamera() {
   camera =
       new EulerCamera.Builder()
           .setAspectRatio((float) Display.getWidth() / Display.getHeight())
           .setPosition(-2.19f, 1.36f, 11.45f)
           .setFieldOfView(70)
           .build();
   camera.applyOptimalStates();
   camera.applyPerspectiveMatrix();
 }
示例#3
0
  protected void update(float elapsedTime) {

    checkSystemInput();

    if (!isPaused()) {
      checkGameInput();
      camera.update();
    }
  }
  public void Draw() {
    mCamera.Set();

    /*mShadowMaskObject.Begin();
    {
    	glPushAttrib(GL_COLOR_BUFFER_BIT);
    	{
    		mShadowMaskObject.Clear();

    		glPushMatrix();
    		{
    			glLoadIdentity();

    			glColor3f(0, 0, 0);
    			glBegin(GL_QUADS);
    			{
    				glVertex2f(0, 0);
    				glVertex2f(mGameWindow.Width(), 0);
    				glVertex2f(mGameWindow.Width(), mGameWindow.Height());
    				glVertex2f(0, mGameWindow.Height());
    			}
    			glEnd();
    		}
    		glPopMatrix();
    	}
    	glPopAttrib();
    }
    mShadowMaskObject.End();*/

    CalculateLighting();

    DrawScene();

    // draw mask over scene to occlude shadows
    glPushMatrix();
    {
      glLoadIdentity();

      glColor4f(1, 1, 1, 1);
      Texture.Begin();
      {
        mShadowMask.BindTexture();
        mShadowMask.Draw(0, 0, 1, -1);
      }
      Texture.End();
    }
    glPopMatrix();
  }
  public void Load() {
    mCamera = new Camera(GetGameWindow());

    Light.Load(mGameWindow.Width(), mGameWindow.Height());
    ComplexPolygon.Load(mGameWindow.Width(), mGameWindow.Height());

    mShadowMask = new Texture(mGameWindow.Width(), mGameWindow.Height());

    try {
      mShadowMaskObject = new FrameBufferObject(mShadowMask);
    } catch (Exception e) {
      e.printStackTrace();
    }

    mCamera.ForceScaleFocus((mGameWindow.Width() / 1600.0f + mGameWindow.Height() / 900.0f) / 2);

    mAmbientLighting = 0.0f;
  }
  @Override
  public void onUpdate() {
    cur = now;
    now = getTimeSinceStartMillis();
    TIME_DELTA = (now - cur) / 100.0f;
    if (current_world != null && !isPaused()) {
      if (!dontUpdate) {
        Iterator<UpdatableDrawable> updates = current_world.getUpdatables();
        while (updates.hasNext()) {
          UpdatableDrawable s = updates.next();
          if (s == null) continue;
          try {
            s.update();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glClearColor(0f, 0f, 0f, 1f);
      // ROBO //todo get this crap changed into proper ogl
      glMatrixMode(GL_MODELVIEW);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
      glLoadIdentity();
      glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

      // ROBO //todo change this crap into proper postprocess and per material shaders
      ShaderFactory.executePreRender();

      if (isFading) {
        long time = getTime() - startTime;
        curAlpha = Camera.ease(startAlpha, newAlpha, speed, time);
        if (curAlpha == newAlpha) {
          isFading = false;
        }
      }
      if (isFadingBox) {
        long time = getTime() - startTime;
        float alpha = Camera.ease(0f, 1f, speed, time);
        if (alpha == 1f) {
          isFadingBox = false;
        }
        glColor4f(1f, 1f, 1f, alpha);
        renderBox();
      }

      glTranslatef(-Camera.getX(), -Camera.getY(), 0f);

      glColor4f(1f, 1f, 1f, curAlpha);
      // ROBO //todo get all these into proper batches

      if (curAlpha > 0f) {
        Iterator<Drawable> usprites = current_world.getUnsortedDrawables();
        while (usprites.hasNext()) {
          Drawable s = usprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        Iterator<Drawable> sprites = current_world.getSortedDrawables();
        while (sprites.hasNext()) {
          Drawable s = sprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }

      ShaderFactory.executePostRender();

      glLoadIdentity();
      glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

      if (show_ui) {
        for (UI e : current_world.getElements()) {
          if (e == null) return;
          try {
            e.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }
      }

      if (next_world != null) {
        long time = getTime() - fadeStartTime;
        float percent;
        if (time > fadeDuration) {
          percent = 1;
        } else {
          percent = time / fadeDuration;
        }
        float emu = curAlpha;
        curAlpha =
            percent; // Some drawables require the curAlpha to be set, so we save what it use to be
        // and set it
        glColor4f(1f, 1f, 1f, curAlpha);

        Iterator<Drawable> next_sprites = next_world.getSortedDrawables();
        while (next_sprites.hasNext()) {
          Drawable s = next_sprites.next();
          if (s == null) continue;
          try {
            if (!s.neverClip()
                && (!(s instanceof TileObject) || !((TileObject) s).isParallaxLayer())
                && Camera.isOffScreen(s.getX(), s.getY(), s.getWidth() / 2, s.getHeight() / 2))
              continue;
            s.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        glLoadIdentity();
        glScalef(ZOOM_SCALE, ZOOM_SCALE, 1f);

        for (UI e : next_world.getElements()) {
          if (e == null) return;
          try {
            e.render();
          } catch (Throwable t) {
            t.printStackTrace();
          }
        }

        curAlpha = emu;

        if (percent == 1) {
          current_world.onUnload();
          current_world = next_world;
          current_world.onDisplay();
          next_world = null;
        }
      }

      try {
        AnimationFactory.executeTick(); // Execute any animation
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      }

      Camera.executeAnimation(); // Execute any interlop
      // exitOnGLError("RenderService.renderSprites");

      Display.update();

      fpsTime += TIME_DELTA;
      fpsCount++;
      if (fpsCount == 100) {
        fpsCount = 0;
        FPS = (1000f / fpsTime);
        Display.setTitle("FPS: " + FPS);
        fpsTime = 0;
      }
      if (Display.isCloseRequested()) {
        kill();
      }

      if (GameSettings.Graphics.FPSLimit != -1) {
        Display.sync(GameSettings.Graphics.FPSLimit);
      }
    } else {
      try {
        Thread.sleep(15); // Keep the thread busy
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  public void CalculateLighting() {
    mShadowMaskObject.Begin();
    {
      glPushAttrib(GL_COLOR_BUFFER_BIT);
      {
        mShadowMaskObject.Clear();

        // additive blending
        glBlendFunc(GL_ONE, GL_ONE);

        // Draw lights:

        // ambient lighting
        glPushMatrix();
        {
          glLoadIdentity();

          glColor4f(1, 1, 1, mAmbientLighting);
          glBegin(GL_QUADS);
          {
            glVertex2f(0, 0);
            glVertex2f(mGameWindow.Width(), 0);
            glVertex2f(mGameWindow.Width(), mGameWindow.Height());
            glVertex2f(0, mGameWindow.Height());
          }
          glEnd();
        }
        glPopMatrix();

        Vector2 middleScreen =
            mCamera.ScreenToWorld(
                new Vector2(mGameWindow.Width(), mGameWindow.Height()).DividedBy(2));

        Vector2 topLeft = mCamera.ScreenToWorld(new Vector2(0, 0));
        Vector2 topRight = mCamera.ScreenToWorld(new Vector2(mGameWindow.Width(), 0));
        Vector2 bottomRight =
            mCamera.ScreenToWorld(new Vector2(mGameWindow.Width(), mGameWindow.Height()));
        Vector2 bottomLeft = mCamera.ScreenToWorld(new Vector2(0, mGameWindow.Height()));

        SimplePolygon screen = new SimplePolygon(this, middleScreen);
        screen.AddVertexAbsolute(topLeft);
        screen.AddVertexAbsolute(topRight);
        screen.AddVertexAbsolute(bottomRight);
        screen.AddVertexAbsolute(bottomLeft);

        mLevel.DrawLights(screen);

        // blend lights with shadow:
        glPushMatrix();
        {
          glLoadIdentity();

          glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE_MINUS_DST_ALPHA, GL_ZERO);

          glColor3f(0, 0, 0);
          glBegin(GL_QUADS);
          {
            glVertex2f(0, 0);
            glVertex2f(mGameWindow.Width(), 0);
            glVertex2f(mGameWindow.Width(), mGameWindow.Height());
            glVertex2f(0, mGameWindow.Height());
          }
          glEnd();
        }
        glPopMatrix();
      }
      glPopAttrib();
    }
    mShadowMaskObject.End();
  }
 public void Update(GameTime gameTime) {
   mCamera.Update(gameTime);
 }
 private static void render() {
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();
   camera.applyTranslations();
   glCallList(bunnyDisplayList);
 }
示例#10
0
  protected void render() {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

    glLoadIdentity();

    camera.look();

    // Each frame we calculate the new frustum.  In reality you only need to
    // calculate the frustum when we move the camera.
    GameCore.gFrustum.calculateFrustum();

    // Initialize the total node count that is being draw per frame
    Octree.totalNodesDrawn = 0;

    glPushMatrix();
    // Here we draw the octree, starting with the root node and recursing down each node.
    // This time, we pass in the root node and just the original world model.  You could
    // just store the world in the root node and not have to keep the original data around.
    // This is up to you.  I like this way better because it's easy, though it could be
    // more error prone.
    octree.drawOctree(octree, g_World);
    glPopMatrix();

    // Render the cubed nodes to visualize the octree (in wire frame mode)
    if (g_bDisplayNodes) Octree.debug.drawBoundingBox();

    glPushMatrix();
    // If there was a collision, make the Orange ball Red.
    if (octree.isObjectColliding()) {
      glColor3f(1.0f, 0.0f, 0.0f);
    } else {
      glColor3f(1.0f, 0.5f, 0.0f); // Disable Lighting.
    }
    // Move the Ball into place.
    glTranslatef(g_BallEntity.x, g_BallEntity.y, g_BallEntity.z);

    glDisable(GL_LIGHTING);
    // Draw the Ground Intersection Line.
    glBegin(GL_LINES);
    glColor3f(1, 1, 1);
    glVertex3f(g_vGroundISector[0].x, g_vGroundISector[0].y, g_vGroundISector[0].z);
    glVertex3f(g_vGroundISector[1].x, g_vGroundISector[1].y, g_vGroundISector[1].z);
    glEnd();

    // Draw the Forward Intersection Line.
    glBegin(GL_LINES);
    glColor3f(1, 1, 0);
    glVertex3f(
        g_vForwardISector[0].x * 10.0f, g_vForwardISector[0].y, g_vForwardISector[0].z * 10.0f);
    glVertex3f(
        g_vForwardISector[1].x * 10.0f, g_vForwardISector[1].y, g_vForwardISector[1].z * 10.0f);
    glEnd();

    // Re-enable lighting.
    glEnable(GL_LIGHTING);

    // System.out.println("x " + g_BallEntity.x + " y " + g_BallEntity.y);
    // Draw it!
    pObj.draw(g_BallEntity.fRadius, 20, 20);

    glPopMatrix();

    screen.setTitle(
        "Triangles: "
            + Octree.maxTriangles
            + "  -Total Draw: "
            + Octree.totalNodesDrawn
            + "  -Subdivisions: "
            + Octree.maxSubdivisions
            + "  -FPS: "
            + FPSCounter.get()
            + "  -Node Collisions: "
            + Octree.numNodesCollided
            + "  -Object Colliding? "
            + octree.isObjectColliding());
  }
示例#11
0
  public void checkGameInput() {

    if (drawMode.isPressed()) {
      octree.setRenderMode(!octree.isRenderMode());
      octree.setObjectColliding(false);
      if (octree.isRenderMode()) {
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // Render the triangles in fill mode
      } else {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Render the triangles in wire frame mode
      }
      octree.createDisplayList(octree, g_World, octree.getDisplayListID());
    }

    if (fullScreen.isPressed()) {
      setFullScreen(!isFullScreen());
    }

    if (enter.isPressed()) {
      Octree.octreeCollisionDetection = !Octree.octreeCollisionDetection;
    }

    if (left.isPressed()) {
      camera.strafe(-SPEED / 10 * elapsedTime);
    }

    if (right.isPressed()) {

      camera.strafe(SPEED / 10 * elapsedTime);
    }

    if (zoomIn.isPressed()) {
      camera.move(+SPEED / 10 * elapsedTime);
    }
    if (zoomOut.isPressed()) {

      camera.move(-SPEED / 10 * elapsedTime);
    }

    if (moveLeft.isPressed()) {
      g_BallEntity.fAngle += (float) AR_DegToRad(g_BallEntity.fTurnRate) * elapsedTime;
    }

    if (moveRight.isPressed()) {

      // Rotate the Ball Angle Counter Clockwise.
      g_BallEntity.fAngle -= (float) AR_DegToRad(g_BallEntity.fTurnRate) * elapsedTime;
    }

    // Clamp values above 2 * PI or 360 Deg's.
    if (g_BallEntity.fAngle >= AR_2PI) g_BallEntity.fAngle = g_BallEntity.fAngle - AR_2PI;

    // Clamp values below 0.
    if (g_BallEntity.fAngle < 0.0f) g_BallEntity.fAngle = AR_2PI + g_BallEntity.fAngle;

    if (debug.isPressed()) {
      g_bDisplayNodes = !g_bDisplayNodes;
    }

    if (moveUp.isPressed()) {
      if (g_BallEntity.fVelX + (g_BallEntity.fAccel * elapsedTime) < g_BallEntity.fMaxVel) {
        g_BallEntity.fVelX += g_BallEntity.fAccel * elapsedTime;
        g_BallEntity.fVelZ += g_BallEntity.fAccel * elapsedTime;
      }
    }
    if (moveDown.isPressed()) {

      // Move the Ball Backwards.
      if (g_BallEntity.fVelX - (g_BallEntity.fAccel * elapsedTime) > g_BallEntity.fMinVel) {
        g_BallEntity.fVelX -= g_BallEntity.fAccel * elapsedTime;
        g_BallEntity.fVelZ -= g_BallEntity.fAccel * elapsedTime;
      }
    }

    // Apply Gravity to this Entity (using time based motion) if he's not colliding with anything.
    if (!octree.isObjectColliding()) g_BallEntity.fVelY += (GRAVITY * elapsedTime);

    // Apply (spherical based) motion.

    g_BallEntity.x +=
        (g_fSinTable[(int) AR_RadToDeg(g_BallEntity.fAngle)] * g_BallEntity.fVelX) * elapsedTime;
    g_BallEntity.y += g_BallEntity.fVelY * elapsedTime;
    g_BallEntity.z +=
        (g_fCosTable[(int) AR_RadToDeg(g_BallEntity.fAngle)] * g_BallEntity.fVelZ) * elapsedTime;

    // Adjust the Forward I-Sectors Endpoint.
    g_vForwardISector[1].x =
        g_fSinTable[(int) AR_RadToDeg(g_BallEntity.fAngle)] * g_BallEntity.fRadius * 0.2f;
    g_vForwardISector[1].y = 0.0f;
    g_vForwardISector[1].z =
        g_fCosTable[(int) AR_RadToDeg(g_BallEntity.fAngle)] * g_BallEntity.fRadius * 0.2f;

    // Slow this guy down (friction).
    if (g_BallEntity.fVelX > g_fFriction * elapsedTime) {
      g_BallEntity.fVelX -= g_fFriction * elapsedTime;
    }

    if (g_BallEntity.fVelZ > g_fFriction * elapsedTime) {
      g_BallEntity.fVelZ -= g_fFriction * elapsedTime;
    }

    if (g_BallEntity.fVelX < g_fFriction * elapsedTime) {
      g_BallEntity.fVelX += g_fFriction * elapsedTime;
    }

    if (g_BallEntity.fVelZ < g_fFriction * elapsedTime) {
      g_BallEntity.fVelZ += g_fFriction * elapsedTime;
    }

    // If this Ball falls outside the world, drop back from the top.
    if (g_BallEntity.y < -30) {
      g_BallEntity.x = g_BallEntity.z = 0.0f;
      g_BallEntity.y = 5.0f;
      g_BallEntity.fVelX = g_BallEntity.fVelY = g_BallEntity.fVelZ = 0.0f;
    }

    Vector3f[] vGroundLine = {new Vector3f(), new Vector3f()};
    Vector3f[] vForwardLine = {new Vector3f(), new Vector3f()};

    // Prepare a Temporary line transformed to the Balls exact world position.
    vGroundLine[0].x = g_BallEntity.x + g_vGroundISector[0].x;
    vGroundLine[0].y = g_BallEntity.y + g_vGroundISector[0].y;
    vGroundLine[0].z = g_BallEntity.z + g_vGroundISector[0].z;

    vGroundLine[1].x = g_BallEntity.x + g_vGroundISector[1].x;
    vGroundLine[1].y = g_BallEntity.y + g_vGroundISector[1].y;
    vGroundLine[1].z = g_BallEntity.z + g_vGroundISector[1].z;

    // Prepare a Temporary line transformed to the Balls exact world position.
    vForwardLine[0].x = g_BallEntity.x + g_vForwardISector[0].x;
    vForwardLine[0].y = g_BallEntity.y + g_vForwardISector[0].y;
    vForwardLine[0].z = g_BallEntity.z + g_vForwardISector[0].z;

    vForwardLine[1].x = g_BallEntity.x + g_vForwardISector[1].x;
    vForwardLine[1].y = g_BallEntity.y + g_vForwardISector[1].y;
    vForwardLine[1].z = g_BallEntity.z + g_vForwardISector[1].z;

    // A temporary Vector holding the Intersection Point of our Intersection Check.
    vIntersectionPt = new Vector3f();

    // Reset the Status of the Object (wheter it is colliding or not).
    octree.setObjectColliding(false);

    // Reset the Nodes collided to zero so we can start with a fresh count.
    Octree.numNodesCollided = 0;

    // Test the line for an intersection with the Octree Geometry.
    if (octree.intersectLineWithOctree(octree, g_World, vGroundLine, vIntersectionPt)) {
      // Move the Ball up from the point at which it collided with the ground. This is what
      // ground clamping is!
      g_BallEntity.x = vIntersectionPt.x;
      // NOTE: Make sure it is above the surface, AND half it's height (so it isn't half
      // underground).
      // This would only apply if you placed entity's by their exact center.
      g_BallEntity.y = vIntersectionPt.y + g_BallEntity.fRadius;
      g_BallEntity.z = vIntersectionPt.z;

      // Stop your up-down velocity.
      g_BallEntity.fVelY = 0.0f;
    }

    // Test the line for an intersection with the Octree Geometry.
    if (octree.intersectLineWithOctree(octree, g_World, vForwardLine, vIntersectionPt)) {
      // Move the Ball up from the point at which it collided with the ground. This is what
      // ground clamping is!
      g_BallEntity.x = vIntersectionPt.x;
      // NOTE: Make sure it is above the surface, AND half it's height (so it isn't half
      // underground).
      // This would only apply if you placed entity's by their exact center.
      g_BallEntity.y = vIntersectionPt.y + g_BallEntity.fRadius;
      g_BallEntity.z = vIntersectionPt.z;

      // Stop your up-down velocity.
      g_BallEntity.fVelY = 0.0f;
    }
  }
示例#12
0
  @Override
  public void init() throws IOException {

    super.init();
    camera = new Camera(true);
    camera.setPosition(-17f, 20f, 17f, 0, 0, 0, 0, 1, 0);
    float df = 100.0f;

    // Precalculate the Sine and Cosine Lookup Tables.
    // Basically, loop through 360 Degrees and assign the Radian
    // value to each array index (which represents the Degree).
    for (int i = 0; i < 360; i++) {
      g_fSinTable[i] = (float) Math.sin(AR_DegToRad(i));
      g_fCosTable[i] = (float) Math.cos(AR_DegToRad(i));
    }

    pObj = new Sphere();
    pObj.setOrientation(GLU_OUTSIDE);

    Octree.debug = new BoundingBox();
    // Turn lighting on initially
    Octree.turnLighting = true;

    // The current amount of end nodes in our tree (The nodes with vertices stored in them)
    Octree.totalNodesCount = 0;

    // This stores the amount of nodes that are in the frustum
    Octree.totalNodesDrawn = 0;

    // The maximum amount of triangles per node.  If a node has equal or less
    // than this, stop subdividing and store the face indices in that node
    Octree.maxTriangles = 800;

    // The maximum amount of subdivisions allowed (Levels of subdivision)
    Octree.maxSubdivisions = 5;

    // The number of Nodes we've checked for collision.
    Octree.numNodesCollided = 0;

    // Wheter the Object is Colliding with anything in the World or not.
    octree.setObjectColliding(false);

    // Wheter we test the whole world for collision or just the nodes we are in.
    Octree.octreeCollisionDetection = true;

    LoadWorld();

    // for(int i=0; i < g_World.getNumOfMaterials(); i++)
    // {
    //	System.out.println(g_World.getMaterials(i).getName() + " indice " + i);

    // }

    // for(int i=0; i < g_World.getNumOfObjects(); i++)
    // {
    //	System.out.println(g_World.getObject(i).getName());
    //	System.out.println(g_World.getObject(i).getMaterialID());
    // System.out.println(g_World.getPObject(i).getMaterialID());
    // }

    // System.out.println(g_World.getPMaterials(12).getColor()[0] + " " +
    // g_World.getPMaterials(12).getColor()[1]
    //                    + " " + g_World.getPMaterials(12).getColor()[2]);
    // System.out.println(g_World.getPMaterials(g_World.getPObject(6).getMaterialID()));

    inputManager = new InputManager();

    createGameActions();

    posLuz1F = Conversion.allocFloats(posLuz1);

    // Define a cor de fundo da janela de visualização como preto
    glClearColor(0, 0, 0, 1);

    // Ajusta iluminação
    glLight(GL_LIGHT0, GL_AMBIENT, Conversion.allocFloats(luzAmb1));
    glLight(GL_LIGHT0, GL_DIFFUSE, Conversion.allocFloats(luzDif1));
    glLight(GL_LIGHT0, GL_SPECULAR, Conversion.allocFloats(luzEsp1));

    // Habilita todas as fontes de luz
    glEnable(GL_LIGHT0);

    glEnable(GL_LIGHTING);
    // Agora posiciona demais fontes de luz
    glLight(GL_LIGHT0, GL_POSITION, posLuz1F);

    // Habilita Z-Buffer
    glEnable(GL_DEPTH_TEST);

    // Seleciona o modo de GL_COLOR_MATERIAL
    // glColorMaterial(GL_FRONT, GL_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
    glMaterial(GL_FRONT, GL_SPECULAR, Conversion.allocFloats(spec));
    glMaterialf(GL_FRONT, GL_SHININESS, df);
  }