예제 #1
0
  private void renderCursor(float x, float y, Context c) {
    if (blinkTime < blinkPeriod / 2) {
      GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
      GL14.glBlendFuncSeparate(
          GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_ZERO);
      GL20.glBlendEquationSeparate(GL14.GL_FUNC_ADD, GL14.GL_FUNC_ADD);

      c.resetColor();
      c.pushTransform();
      c.appendTransform(Matrix.translation(x, y, 0));
      font.getSprite(getCursorChar()).render(c);
      c.popTransform();

      GL11.glPopAttrib();
    }
  }
예제 #2
0
파일: GdxGL20.java 프로젝트: hanchao/vtm
 public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
   GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
 }
예제 #3
0
  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();
  }