Ejemplo n.º 1
0
  public void setBlendMode(int mode) {
    oldBlendMode = blendMode;
    blendMode = mode;

    GL14.glBlendEquation(GL14.GL_FUNC_ADD);
    if (mode < 100) {
      g.setDrawMode(mode);
      return;
    }

    try {
      Reflection.invokePrivateMethod(mPredraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
    gl.glEnable(SGL.GL_BLEND);
    gl.glColorMask(true, true, true, true);

    if (mode == BM_ADD || mode == BM_SUBTRACT) {
      gl.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
      if (mode == BM_SUBTRACT) {
        GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT);
        GL14.glBlendEquation(GL14.GL_FUNC_REVERSE_SUBTRACT);
      }
    }

    try {
      Reflection.invokePrivateMethod(mPostdraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
  }
Ejemplo n.º 2
0
 static {
   try {
     mPredraw = Reflection.getPrivateMethod(Graphics.class, "predraw");
     mPostdraw = Reflection.getPrivateMethod(Graphics.class, "postdraw");
   } catch (Exception e) {
     App.getApp().handle(e);
   }
 }
Ejemplo n.º 3
0
 protected void getPrivates() {
   if (gl != null) return;
   try {
     gl = Reflection.getPrivateValue(Graphics.class, "GL", null);
   } catch (Exception e) {
     App.getApp().handle(e);
   }
 }
Ejemplo n.º 4
0
 public static void setGraphics(Graphics g) {
   try {
     oldG = Reflection.getPrivateValue(Graphics.class, "currentGraphics", null);
   } catch (Exception e) {
     App.getApp().handle(e);
   }
   Graphics.setCurrent(g);
 }
Ejemplo n.º 5
0
 public static Graphics getGraphics() {
   try {
     return Reflection.getPrivateValue(Graphics.class, "currentGraphics", null);
   } catch (Exception e) {
     App.getApp().handle(e);
   }
   return null;
 }
Ejemplo n.º 6
0
  public void drawRectangleGradient(
      Vector2f p1,
      Vector2f p2,
      Color topLeft,
      Color topRight,
      Color bottomLeft,
      Color bottomRight) {
    getPrivates();

    try {
      Reflection.invokePrivateMethod(mPredraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
    TextureImpl.bindNone();
    Color.white.bind();
    GL11.glBegin(GL11.GL_POLYGON);
    Color c;
    c = topLeft;
    gl.glColor4f(c.r, c.g, c.b, c.a);
    gl.glVertex2f(p1.x, p1.y);
    c = topRight;
    gl.glColor4f(c.r, c.g, c.b, c.a);
    gl.glVertex2f(p2.x, p1.y);
    c = bottomRight;
    gl.glColor4f(c.r, c.g, c.b, c.a);
    gl.glVertex2f(p2.x, p2.y);
    c = bottomLeft;
    gl.glColor4f(c.r, c.g, c.b, c.a);
    gl.glVertex2f(p1.x, p2.y);
    gl.glEnd();
    try {
      Reflection.invokePrivateMethod(mPostdraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
  }
Ejemplo n.º 7
0
  public void drawTriangle(Vector2f p1, Vector2f p2, Vector2f p3, Color c1, Color c2, Color c3) {
    getPrivates();

    try {
      Reflection.invokePrivateMethod(mPredraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
    TextureImpl.bindNone();
    Color.white.bind();
    gl.glBegin(SGL.GL_TRIANGLES);
    gl.glColor4f(c1.r, c1.g, c1.b, c1.a);
    gl.glVertex2f(p1.x, p1.y);
    gl.glColor4f(c2.r, c2.g, c2.b, c2.a);
    gl.glVertex2f(p2.x, p2.y);
    gl.glColor4f(c3.r, c3.g, c3.b, c3.a);
    gl.glVertex2f(p3.x, p3.y);
    gl.glEnd();
    try {
      Reflection.invokePrivateMethod(mPostdraw, g);
    } catch (Exception e) {
      App.getApp().handle(e);
    }
  }