public void UnLoad() {
    super.UnLoad();

    mShadowMaskObject.Delete();
    mShadowMask.Delete();

    Light.UnLoad();
    ComplexPolygon.UnLoad();
  }
示例#2
0
  public static void iterate() {
    // Dealing with the user input

    UserInterface.iterate();
    UserInterface soul = new UserInterface();
    soul.update(getPlayerEntity());

    // Dealing with the Camera
    WorldShapes.setCamera(mainCamera);
    mainCamera.setZoom(mainCamera.getZoom() * Math.pow(1.001, Mouse.getDWheel()));
    mainCamera.followParticle(mainCamera.world.Entity_HashMap.get("player").getParticle());
    mainCamera.iterate();
    mainCamera.entityDrag(); // Deals with dragging points

    // Update the physics
    updateWorld(worldOne);

    // Rendering and stuff
    Render.testResize();

    FrameBufferObject.setFrameBuffer(
        extra_frame.getFrameBufferIdentifier()); // applies the extra framebuffer
    mainCamera.render();
    FrameBufferObject.setFrameBuffer(0); // applies the normal screen

    // Drawing the framebuffer
    HUDShapes.drawTexturedQuad(
        0,
        0,
        Display.getWidth(),
        Display.getHeight(),
        extra_frame.getTexture(),
        Display.getWidth(),
        Display.getHeight());
    Display.update();
  }
  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();
  }