List of usage examples for org.lwjgl.opengl GL11 glColor4f
public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);
From source file:com.jmex.bui.background.TintedBackground.java
License:Open Source License
public void render(Renderer renderer, int x, int y, int width, int height, float alpha) { super.render(renderer, x, y, width, height, alpha); BComponent.applyDefaultStates();/*from w ww. j a v a2 s . c o m*/ BImage.blendState.apply(); GL11.glColor4f(_color.r, _color.g, _color.b, _color.a * alpha); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(x, y); GL11.glVertex2f(x + width, y); GL11.glVertex2f(x + width, y + height); GL11.glVertex2f(x, y + height); GL11.glEnd(); }
From source file:com.jmex.bui.border.LineBorder.java
License:Open Source License
@Override // from BBorder/*from w ww . j a va 2 s. c o m*/ public void render(Renderer renderer, int x, int y, int width, int height, float alpha) { super.render(renderer, x, y, width, height, alpha); BComponent.applyDefaultStates(); BImage.blendState.apply(); if (_width > 0) { RenderContext ctx = DisplaySystem.getDisplaySystem().getCurrentContext(); GL11.glColor4f(_color.r, _color.g, _color.b, _color.a * alpha); // First draw the bottom line. if (_bottom > 0) { ((LineRecord) ctx.getLineRecord()).applyLineWidth(_bottom); float offset = _bottom / 2f; GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2f(x - offset, y); GL11.glVertex2f(x + width, y); GL11.glEnd(); } // Next draw the right hand side. if (_right > 0) { ((LineRecord) ctx.getLineRecord()).applyLineWidth(_right); float offset = _right / 2f; GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2f(x + width - offset, y); GL11.glVertex2f(x + width - offset, y + height); GL11.glEnd(); } // Next draw the top line. if (_top > 0) { ((LineRecord) ctx.getLineRecord()).applyLineWidth(_top); float offset = _top / 2f; GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2f(x + width, y + height - offset); GL11.glVertex2f(x - offset, y + height - offset); GL11.glEnd(); } // Last draw the left hand side. if (_left > 0) { ((LineRecord) ctx.getLineRecord()).applyLineWidth(_left); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2f(x, y + height); GL11.glVertex2f(x, y); GL11.glEnd(); } } }
From source file:com.jmex.bui.BRootNode.java
License:Open Source License
protected void renderModalShade() { BComponent.applyDefaultStates();// www. j av a 2s . c o m BImage.blendState.apply(); int width = DisplaySystem.getDisplaySystem().getWidth(); int height = DisplaySystem.getDisplaySystem().getHeight(); GL11.glColor4f(_modalShade.r, _modalShade.g, _modalShade.b, _modalShade.a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(width, 0); GL11.glVertex2f(width, height); GL11.glVertex2f(0, height); GL11.glEnd(); }
From source file:com.jmex.bui.BTextField.java
License:Open Source License
@Override // documentation inherited protected void renderComponent(Renderer renderer) { super.renderComponent(renderer); Insets insets = getInsets();/*from w w w . j ava 2s . c o m*/ // render our text if (_glyphs != null) { // clip the text to our visible text region boolean scissored = intersectScissorBox(_srect, getAbsoluteX() + insets.left, getAbsoluteY() + insets.bottom, _width - insets.getHorizontal(), _height - insets.getVertical()); try { _glyphs.render(renderer, insets.left - _txoff, insets.bottom, _alpha); } finally { restoreScissorState(scissored, _srect); } } // render the cursor if we have focus if (_showCursor) { int cx = insets.left - _txoff + _cursx; BComponent.applyDefaultStates(); ColorRGBA c = getColor(); GL11.glColor4f(c.r, c.g, c.b, c.a); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2f(cx, insets.bottom); int cheight = getTextFactory().getHeight(); GL11.glVertex2f(cx, insets.bottom + cheight); GL11.glEnd(); } }
From source file:com.kaijin.AdvInvMan.CButton.java
License:Open Source License
/** * Draws this button to the screen./*w w w. jav a2 s. c o m*/ */ @Override public void drawButton(Minecraft mc, int xLoc, int yLoc) { if (drawButton) { FontRenderer fr = mc.fontRenderer; if (texture != null) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(texture); } isHovering = xLoc >= xPosition && yLoc >= yPosition && xLoc < xPosition + width && yLoc < yPosition + height; int hoverState = this.getHoverState(isHovering); if (hoverState == 2) { this.drawTexturedModalRect(xPosition, yPosition, uHoverLoc, vHoverLoc, width, height); } else { this.drawTexturedModalRect(xPosition, yPosition, uLoc, vLoc, width, height); } int defaultColor = color; int renderColor = defaultColor; if (!enabled) { renderColor = -6250336; } else if (isHovering) { renderColor = hoverColor; } fr.drawString(displayString, xPosition + (width - fr.getStringWidth(displayString)) / 2, yPosition + (height - 7) / 2, renderColor); } }
From source file:com.kaijin.AdvInvMan.GuiStocker.java
License:Open Source License
/** * Draw the background layer for the GuiContainer (everything behind the items) *///from ww w .j ava 2 s.c om protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(Info.GUI_PNG); this.drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize); Utils.drawCenteredText(fontRenderer, lang.translateKey(tile.getInvName()), xCenter, yLoc + 6, 4210752); fontRenderer.drawString(lang.translateKey(Info.KEY_GUI_INPUT), xLoc + 8, yLoc + 17, 4210752); Utils.drawRightAlignedText(fontRenderer, lang.translateKey(Info.KEY_GUI_OUTPUT), xLoc + xSize - 8, yLoc + 17, 4210752); //Add snapshot text if (tile.isSnapshotValid) { //Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_READY), xCenter, yLoc + 30, 0x0000FF, 0x000040); if ((tile.metaInfo & 8) == 8) { Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_WORKING), xCenter, yLoc + 60, 0x40FF40, 0x082008); } else { Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_READY), xCenter, yLoc + 60, 0x40FF40, 0x082008); } } else { final String line; if (tile.hasSnapshot) { final boolean alternate = (tile.metaInfo & 8) == 8 && (((int) tile.worldObj.getWorldTime()) & 32) == 32; line = alternate ? lang.translateKey(Info.KEY_GUI_HALTED) : lang.translateKey(Info.KEY_GUI_INVALID); } else { line = lang.translateKey(Info.KEY_GUI_NOSCAN); } Utils.drawCenteredGlowingText(fontRenderer, line, xCenter, yLoc + 60, 0xFF0000, 0x400000); } switch (tile.operationMode) { case NORMAL: Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_NORMAL), xCenter, yLoc + 70, 0x40FFFF, 0x082020); break; case REPLACE: Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_REPLACE), xCenter, yLoc + 70, 0x40FFFF, 0x082020); break; case INSERT: Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_INSERT), xCenter, yLoc + 70, 0x40FFFF, 0x082020); break; case REMOVE: Utils.drawCenteredGlowingText(fontRenderer, lang.translateKey(Info.KEY_GUI_REMOVE), xCenter, yLoc + 70, 0x40FFFF, 0x082020); break; } buttonSnap.displayString = lang.translateKey(tile.isSnapshotValid ? Info.KEY_GUI_CLEAR : Info.KEY_GUI_SCAN); buttonSnap.drawButton(mc, mouseX, mouseY); buttonMode.displayString = lang.translateKey(Info.KEY_GUI_MODE); buttonMode.drawButton(mc, mouseX, mouseY); }
From source file:com.kaijin.AdvPowerMan.CButton.java
License:Open Source License
/** * Draws this button to the screen.//from w ww. jav a 2 s .com */ @Override public void drawButton(Minecraft mc, int xLoc, int yLoc) { if (drawButton) { FontRenderer fr = mc.fontRenderer; if (texture != null) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.func_110577_a(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), texture)); } isHovering = xLoc >= xPosition && yLoc >= yPosition && xLoc < xPosition + width && yLoc < yPosition + height; int hoverState = this.getHoverState(isHovering); if (hoverState == 2) { this.drawTexturedModalRect(xPosition, yPosition, uHoverLoc, vHoverLoc, width, height); } else { this.drawTexturedModalRect(xPosition, yPosition, uLoc, vLoc, width, height); } int defaultColor = color; int renderColor = defaultColor; if (!enabled) { renderColor = -6250336; } else if (isHovering) { renderColor = hoverColor; } fr.drawString(displayString, xPosition + (width - fr.getStringWidth(displayString)) / 2, yPosition + (height - 7) / 2, renderColor); } }
From source file:com.kaijin.AdvPowerMan.gui.CButton.java
License:Open Source License
/** * Draws this button to the screen./*from w w w.j ava2 s . c o m*/ */ @Override public void drawButton(Minecraft mc, int xLoc, int yLoc) { if (visible) { FontRenderer fr = mc.fontRenderer; if (texture != null) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), texture)); } isHovering = xLoc >= xPosition && yLoc >= yPosition && xLoc < xPosition + width && yLoc < yPosition + height; int hoverState = this.getHoverState(isHovering); if (hoverState == 2) { this.drawTexturedModalRect(xPosition, yPosition, uHoverLoc, vHoverLoc, width, height); } else { this.drawTexturedModalRect(xPosition, yPosition, uLoc, vLoc, width, height); } int defaultColor = color; int renderColor = defaultColor; if (!enabled) { renderColor = -6250336; } else if (isHovering) { renderColor = hoverColor; } fr.drawString(displayString, xPosition + (width - fr.getStringWidth(displayString)) / 2, yPosition + (height - 7) / 2, renderColor); } }
From source file:com.kaijin.AdvPowerMan.gui.GuiAdjustableTransformer.java
License:Open Source License
@Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine/*from w ww .j a va 2s . c o m*/ .bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_ADJ_TRANSFORMER)); // Draw GUI background graphic drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize); // Draw title text Utils.drawCenteredText(fontRendererObj, I18n.format(tile.getInvName()), width / 2, yLoc + 6, 4210752); // Draw stats text Utils.drawRightAlignedText(fontRendererObj, I18n.format(Info.KEY_STATS_AVERAGE_EU), xLoc + 180, yLoc + 26, 4210752); Utils.drawRightAlignedText(fontRendererObj, I18n.format(Info.KEY_STATS_AVERAGE_INPUT), xLoc + 180, yLoc + 36, 4210752); Utils.drawLeftAlignedText(fontRendererObj, I18n.format(Info.KEY_EU_BUFFERED), xLoc + 49, yLoc + 26, 4210752); Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.energyBuffer), xLoc + 44, yLoc + 26, GREEN, GREENGLOW); // Factor of 100 because data is in fixed point (x100) final float outAvg = (float) (((ContainerAdjustableTransformer) inventorySlots).outputAvg) / 100F; final float inAvg = (float) (((ContainerAdjustableTransformer) inventorySlots).inputAvg) / 100F; Utils.drawRightAlignedGlowingText(fontRendererObj, fraction.format(outAvg), xLoc + 230, yLoc + 26, GREEN, GREENGLOW); Utils.drawRightAlignedGlowingText(fontRendererObj, fraction.format(inAvg), xLoc + 230, yLoc + 36, GREEN, GREENGLOW); // Packet size section text Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_EMITTER_PACKET), xLoc + 88, yLoc + yOff + 21, 0xB00000); Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.packetSize), xLoc + 146, yLoc + yOff + 49, GREEN, GREENGLOW); fontRendererObj.drawString(Info.AE_PACKET_RANGE, xLoc + 110, yLoc + yOff + 35, 4210752); fontRendererObj.drawString(I18n.format(Info.KEY_EU), xLoc + 152, yLoc + yOff + 49, 4210752); // Transfer rate section text Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_TRANSFORMER_OUTPUT), xLoc + 88, yLoc + yOff + 64, 0xB00000); Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.outputRate), xLoc + 146, yLoc + yOff + 92, GREEN, GREENGLOW); fontRendererObj.drawString(Info.AE_OUTPUT_RANGE, xLoc + 110, yLoc + yOff + 78, 4210752); fontRendererObj.drawString(I18n.format(Info.KEY_EU), xLoc + 152, yLoc + yOff + 92, 4210752); // Side input/output settings text for (int i = 0; i < 6; i++) { Utils.drawGlowingText(fontRendererObj, I18n.format((tile.sideSettings[i] & 1) == 0 ? Info.KEY_IN : Info.KEY_OUT), xLoc + 214, yLoc + yOff + 27 + 13 * i, GREEN, GREENGLOW); } // Buttons MUST be drawn after other texture stuff or it will not draw // the battery meter correctly for (CButton button : buttons) { button.drawButton(mc, mouseX, mouseY); } for (CButton button : dirButtons) { button.drawButton(mc, mouseX, mouseY); } }
From source file:com.kaijin.AdvPowerMan.gui.GuiAdvEmitter.java
License:Open Source License
@Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(new ResourceLocation(Info.TITLE_PACKED.toLowerCase(), Info.GUI_TEX_EMITTER)); // Draw GUI background graphic drawTexturedModalRect(xLoc, yLoc, 0, 0, xSize, ySize); // Draw title text Utils.drawCenteredText(fontRendererObj, I18n.format(tile.getInvName()), width / 2, yLoc + 7, 4210752); // Packet size section text Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_EMITTER_PACKET), width / 2, yLoc + 21, 0xB00000);/*from w w w . jav a 2 s .co m*/ Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.packetSize), xLoc + 146, yLoc + 49, GREEN, GREENGLOW); fontRendererObj.drawString(Info.AE_PACKET_RANGE, xLoc + 110, yLoc + 35, 4210752); fontRendererObj.drawString(I18n.format(Info.KEY_EU), xLoc + 152, yLoc + 49, 4210752); // Output rate section text Utils.drawCenteredText(fontRendererObj, I18n.format(Info.KEY_EMITTER_OUTPUT), width / 2, yLoc + 64, 0xB00000); Utils.drawRightAlignedGlowingText(fontRendererObj, Integer.toString(tile.outputRate), xLoc + 146, yLoc + 92, GREEN, GREENGLOW); fontRendererObj.drawString(Info.AE_OUTPUT_RANGE, xLoc + 110, yLoc + 78, 4210752); fontRendererObj.drawString(I18n.format(Info.KEY_EU), xLoc + 152, yLoc + 92, 4210752); // Buttons MUST be drawn after other texture stuff or it will not draw // the battery meter correctly for (CButton button : buttons) { button.drawButton(mc, mouseX, mouseY); } }