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); } }
static { try { mPredraw = Reflection.getPrivateMethod(Graphics.class, "predraw"); mPostdraw = Reflection.getPrivateMethod(Graphics.class, "postdraw"); } catch (Exception e) { App.getApp().handle(e); } }
protected void getPrivates() { if (gl != null) return; try { gl = Reflection.getPrivateValue(Graphics.class, "GL", null); } catch (Exception e) { App.getApp().handle(e); } }
public static void setGraphics(Graphics g) { try { oldG = Reflection.getPrivateValue(Graphics.class, "currentGraphics", null); } catch (Exception e) { App.getApp().handle(e); } Graphics.setCurrent(g); }
public static Graphics getGraphics() { try { return Reflection.getPrivateValue(Graphics.class, "currentGraphics", null); } catch (Exception e) { App.getApp().handle(e); } return null; }
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); } }
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); } }