List of usage examples for org.lwjgl.opengl GL11 glColor4d
public static native void glColor4d(@NativeType("GLdouble") double red, @NativeType("GLdouble") double green, @NativeType("GLdouble") double blue, @NativeType("GLdouble") double alpha);
From source file:cn.academy.ability.client.ui.BackgroundMask.java
License:GNU General Public License
@Override public void draw(ScaledResolution sr) { long time = GameTimer.getTime(); EntityPlayer player = Minecraft.getMinecraft().thePlayer; AbilityData aData = AbilityData.get(player); CPData cpData = CPData.get(player);/*from w w w. j a v a 2s .c o m*/ double cr, cg, cb, ca; Color color = null; if (cpData.isOverloaded()) { color = CRL_OVERRIDE; } else if (cpData.isActivated()) { color = aData.getCategory().getColorStyle(); } if (color == null) { cr = r; cg = g; cb = b; ca = 0; } else { cr = color.r; cg = color.g; cb = color.b; ca = color.a; } if (ca != 0 || a != 0) { long dt = lastFrame == 0 ? 0 : time - lastFrame; r = balanceTo(r, cr, dt); g = balanceTo(g, cg, dt); b = balanceTo(b, cb, dt); a = balanceTo(a, ca, dt); GL11.glColor4d(r, g, b, a); GL11.glDisable(GL11.GL_ALPHA_TEST); RenderUtils.loadTexture(MASK); HudUtils.rect(0, 0, sr.getScaledWidth_double(), sr.getScaledHeight_double()); GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_ALPHA_TEST); } else { r = cr; g = cg; b = cb; } lastFrame = time; }
From source file:cn.academy.ability.client.ui.CPBar.java
License:GNU General Public License
private void initEvents() { listen(FrameEvent.class, (w, e) -> { EntityPlayer player = Minecraft.getMinecraft().thePlayer; CPData cpData = CPData.get(player); AbilityData aData = AbilityData.get(player); if (!aData.hasCategory()) return; Category c = aData.getCategory(); overlayTexture = c.getOverlayIcon(); boolean active = cpData.isActivated(); // Calculate alpha long time = GameTimer.getTime(); if (!lastFrameActive && active) { showTime = time;/*from w ww . j ava 2 s . co m*/ } // Takes account of interference long deltaTime = Math.min(100L, time - lastDrawTime); final long BLENDIN_TIME = 200L; mAlpha = (time - showTime < BLENDIN_TIME) ? (float) (time - showTime) / BLENDIN_TIME : (active ? 1.0f : Math.max(0.0f, 1 - (time - lastDrawTime) / 200.0f)); boolean interf = cpData.isInterfering(); boolean overloadRecovering = cpData.isOverloadRecovering(); if (interf) { OffsetKeyframe frame = int_get(); GL11.glTranslated(frame.direction.x, frame.direction.y, 0); long timeInput = GameTimer.getAbsTime() % maxtime; timeInput = (timeInput / 10) * 10; // Lower the precision to produce 'jagged' effect mAlpha *= alphaCurve.valueAt(timeInput); } GL11.glPushMatrix(); // PUSH 1 float poverload = mAlpha > 0 ? cpData.getOverload() / cpData.getMaxOverload() : 0; bufferedOverload = balance(bufferedOverload, poverload, deltaTime * 1E-3f * O_BALANCE_SPEED); float pcp = mAlpha > 0 ? cpData.getCP() / cpData.getMaxCP() : 0; bufferedCP = balance(bufferedCP, pcp, deltaTime * 1E-3f * CP_BALANCE_SPEED); if (mAlpha > 0) { /* Draw CPBar */ { if (!cpData.isOverloaded()) { drawNormal(bufferedOverload); } else { drawOverload(bufferedOverload); } if (chProvider != null && !chProvider.alive()) chProvider = null; float estmCons = getConsumptionHint(); boolean low = interf || overloadRecovering; if (estmCons != 0) { float ncp = Math.max(0, cpData.getCP() - estmCons); float oldAlpha = mAlpha; mAlpha *= 0.2f + 0.1f * (1 + Math.sin(time / 80.0f)); drawCPBar(pcp, low); mAlpha = oldAlpha; drawCPBar(ncp / cpData.getMaxCP(), low); } else { drawCPBar(bufferedCP, low); } } /* Draw Preset Hint */ { final long preset_wait = 2000L; if (time - presetChangeTime < preset_wait) drawPresetHint((double) (time - presetChangeTime) / preset_wait, time - lastPresetTime); } // Draw data { float alpha; long dt = lastShowValueChange == 0 ? Long.MAX_VALUE : time - lastShowValueChange; if (cpData.isOverloaded()) { alpha = 0.0f; } else if (showingNumbers) { alpha = MathUtils.clampf(0, 1, (dt - 200) / 400f); // Delay display by 200ms for visual pleasure } else if (dt < 300f) { alpha = 1 - dt / 300f; } else { alpha = 0.0f; } if (alpha > 0) { final double x0 = 110; IFont font = Resources.font(); FontOption option = new FontOption(40); option.color.a = 0.6f * mAlpha * alpha; String str10 = "CP "; String str11 = String.format("%.0f", cpData.getCP()); String str12 = String.format("/%.0f", cpData.getMaxCP()); String str20 = "OL "; String str21 = String.format("%.0f", cpData.getOverload()); String str22 = String.format("/%.0f", cpData.getMaxOverload()); double len10 = font.getTextWidth(str10, option), len11 = font.getTextWidth(str11, option), len20 = font.getTextWidth(str20, option), len21 = font.getTextWidth(str21, option); double len0 = Math.max(len10, len20); double len1 = len0 + Math.max(len11, len21); font.draw(str10, x0, 55, option); font.draw(str12, x0 + len1, 55, option); font.draw(str20, x0, 85, option); font.draw(str22, x0 + len1, 85, option); option.align = FontAlign.RIGHT; font.draw(str11, x0 + len1, 55, option); font.draw(str21, x0 + len1, 85, option); } } drawActivateKeyHint(); } if (active) { lastDrawTime = time; } lastFrameActive = active; GL11.glColor4d(1, 1, 1, 1); GL11.glPopMatrix(); // Pop 1 }); }
From source file:cn.academy.ability.client.ui.CPBar.java
License:GNU General Public License
private void color4d(double r, double g, double b, double a) { GL11.glColor4d(r, g, b, mAlpha * a); }
From source file:cn.academy.ability.client.ui.KeyHintUI.java
License:GNU General Public License
private void addDrawing() { listen(FrameEvent.class, (w, e) -> { EntityPlayer player = Minecraft.getMinecraft().thePlayer; CPData cpData = CPData.get(player); canUseAbility = cpData.canUseAbility(); long time = GameTimer.getTime(); if (time - lastFrameTime > 300L) { showTime = time;/*from w w w. j a va2 s .com*/ } if ((time - showTime) < 300L) { mAlpha = (time - showTime) / 300.0; } else { mAlpha = 1.0; } sinAlpha = 0.6f + (1 + MathHelper.sin((time % 100000) / 50.0f)) * 0.2f; if (cpData.isActivated()) { ClientRuntime rt = ClientRuntime.instance(); CooldownData cd = CooldownData.of(rt.getEntity()); Multimap<String, DelegateNode> map = rt.getDelegateRawData(); List<String> groups = new ArrayList<>(map.keySet()); groups.sort((s1, s2) -> { if (s1.equals(ClientRuntime.DEFAULT_GROUP)) return -1; else if (s2.equals(ClientRuntime.DEFAULT_GROUP)) return 1; else return s1.compareTo(s2); }); int availIdx = 0; for (int i = 0; i < groups.size(); ++i) { Collection<DelegateNode> nodes = map.get(groups.get(i)); if (!nodes.isEmpty()) { final double x = -200 - availIdx * 200; double y = 0; for (DelegateNode node : nodes) { GL11.glPushMatrix(); GL11.glTranslated(x, y, 0); drawSingle(node.keyID, node.delegate, cd.getSub(node.delegate.getSkill(), node.delegate.getIdentifier())); GL11.glPopMatrix(); y += 92; } availIdx++; } } } lastFrameTime = time; GL11.glColor4d(1, 1, 1, 1); }); }
From source file:cn.academy.ability.client.ui.KeyHintUI.java
License:GNU General Public License
private void color4d(double r, double g, double b, double a) { GL11.glColor4d(r, g, b, a * mAlpha); }
From source file:cn.academy.ability.electro.client.render.skill.ChargePlaneEffect.java
License:Open Source License
@SideOnly(Side.CLIENT) @Override//from w w w .j ava2 s. c o m public void renderHud(EntityPlayer player, ScaledResolution sr, long time) { GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDepthMask(false); //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPushMatrix(); { GL11.glColor4d(1, 1, 1, 0.4); double w = sr.getScaledWidth_double(), h = sr.getScaledHeight_double(); if (lct == 0 || time - lct > 200) { lct = time; seq.rebuild(); } for (int i = 0; i < 4; ++i) { RenderUtils.loadTexture(TEXS[seq.get(i)]); HudUtils.drawRect(w * pts[i][0], h * pts[i][1], sizes[i] * w, sizes[i] * w); } RenderUtils.bindIdentity(); } GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); }
From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java
License:Open Source License
@SideOnly(Side.CLIENT) @Override/*w w w . j a va 2s. c om*/ public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) { if (type == HandRenderType.EQUIPPED) return; if (dt < DELAY) return; dt -= DELAY; double tz = dt * dt / 3e4; double TRANS_TIME = ANIM_LEN * 0.2; double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1)); //Draw a screen-filling blackout GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GLU.gluOrtho2D(0, 255, 0, 255); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glDepthMask(false); GL11.glLoadIdentity(); { GL11.glTranslated(0, 0, 0); GL11.glColor4d(0, 0, 0, 0.2 * alpha); HudUtils.setZLevel(1); HudUtils.drawModalRect(0, 0, 255, 255); HudUtils.setZLevel(-90); } GL11.glDepthMask(true); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix //Draw the real effect GL11.glColor4d(1, 1, 1, alpha * 0.6); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f); GL11.glPushMatrix(); { GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz); GL11.glRotated(-20.4, 1, 0, 0); drawSingleSide(7); // GL11.glPushMatrix(); { // GL11.glTranslated(-2.3, 0, 0); // drawSingleSide(7); // } GL11.glPopMatrix(); } GL11.glPopMatrix(); GL11.glDisable(GL11.GL_ALPHA_TEST); }
From source file:cn.academy.ability.electro.client.render.skill.SRSmallCharge.java
License:Open Source License
@Override public void draw() { GL11.glDisable(GL11.GL_CULL_FACE);// w w w . jav a2 s . c o m GL11.glDepthMask(false); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4d(1, 1, 1, 0.7); GL11.glTranslated(0, 0.9, 0.2); GL11.glRotated(120, 1, 0, 0); GL11.glScaled(0.5, 0.5, 0.5); //RenderUtils.drawCube(1, 1, 2); for (ArcObject arc : arcs) { arc.draw(); } GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); }
From source file:cn.academy.ability.teleport.client.render.entity.MarkRender.java
License:Open Source License
@Override public void doRender(Entity ent, double x, double y, double z, float var8, float var9) { EntityTPMarking mark = (EntityTPMarking) ent; int texID = (int) ((mark.ticksExisted / 2.5) % tex.length); GL11.glEnable(GL11.GL_BLEND);/*ww w .ja va 2s . co m*/ GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4d(1, 1, 1, 1); GL11.glPushMatrix(); { GL11.glTranslated(x, y, z); GL11.glRotated(-mark.rotationYaw, 0, 1, 0); GL11.glScaled(-1, -1, 1); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f); Tessellator.instance.setBrightness(15728880); RenderUtils.loadTexture(tex[texID]); model.draw(); } GL11.glPopMatrix(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_CULL_FACE); }
From source file:cn.academy.core.client.gui.dev.DiagActionConfirm.java
License:Open Source License
@Override public void draw(double mx, double my, boolean hover) { super.draw(mx, my, hover); RenderUtils.bindColor(dev.DEFAULT_COLOR); ACUtils.drawText(ACLangs.confirmHead(), 57.5, 15, 4.5, Align.CENTER); ACUtils.drawText(ACLangs.confirmTail(), 57.5, 35.5, 5.5, Align.CENTER); RenderUtils.bindColor(200, 97, 29);/*w w w . j av a 2 s . c om*/ ACUtils.drawText(devAction.getActionInfo(dev.data), 57.5, 24, 6, Align.CENTER, 102); GL11.glColor4d(1, 1, 1, 1); }