List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
From source file:additionalpipes.client.gui.components.GuiSlotEx.java
License:Minecraft Mod Public
/** * draws the slot to the screen, pass in mouse's current x and y and partial ticks *//*from w w w. j a v a 2 s.c o m*/ public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.mouseX = mouseX; this.mouseY = mouseY; drawBackground(); int size = getSize(); int slotLeft = xPos + marginLeft + 2; int slotRight = xPos + width - 2; if (getHiddenHeight() > 0) { slotRight = getScrollBarX() - 2; } if (Mouse.isButtonDown(0)) { if (initialClickY == -1.0F) { boolean slotClicked = true; if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) { int mouseSlotY = mouseY - yPos - marginTop + (int) amountScrolled - getGradientHeight(); int hovered = mouseSlotY / slotHeight; if (/*mouseX < slotLeft || mouseX > slotRight || */hovered < -1 || hovered >= size) { hovered = -1; } boolean doubleClick = hovered == selectedElement && Minecraft.getSystemTime() - lastClicked < 250L; lastClicked = Minecraft.getSystemTime(); elementClicked(hovered, mouseX - xPos, doubleClick); if (hovered >= 0) { selectedElement = hovered; } else if (mouseX >= slotLeft && mouseX <= slotRight && mouseSlotY < 0) { marginClicked(mouseX - slotLeft, mouseY - yPos + (int) amountScrolled - getGradientHeight()); slotClicked = false; } int scrollBarX = getScrollBarX(); if (mouseX >= scrollBarX && mouseX < scrollBarX + scrollBarWidth) { scrollMultiplier = -1.0F; int hiddenHeight = getHiddenHeight(); if (hiddenHeight < 1) { hiddenHeight = 1; } int slotBottom = height * height / getContentHeight(); if (slotBottom < 32) { slotBottom = 32; } if (slotBottom > height - getGradientHeight() * 2) { slotBottom = height - getGradientHeight() * 2; } scrollMultiplier /= (float) (height - slotBottom) / (float) hiddenHeight; } else { scrollMultiplier = 1.0F; } if (slotClicked) { initialClickY = mouseY; } else { initialClickY = -2.0F; } } else { initialClickY = -2.0F; } } else if (initialClickY >= 0.0F) { float scroll = amountScrolled; amountScrolled -= (mouseY - initialClickY) * scrollMultiplier; bindAmountScrolled(); if (scroll != amountScrolled) { initialClickY = mouseY; } } } else if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) { while (!mc.gameSettings.touchscreen && Mouse.next()) { int wheel = Mouse.getEventDWheel(); if (wheel != 0) { if (wheel > 0) { wheel = -1; } else if (wheel < 0) { wheel = 1; } amountScrolled += wheel * slotHeight / 2; bindAmountScrolled(); } } initialClickY = -1.0F; } GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); Tessellator tessellator = Tessellator.instance; drawContainerBackground(tessellator); int scrolledTop = yPos + getGradientHeight() - (int) amountScrolled; if (!drawGradient) { scrolledTop += 2; } if (drawMarginTop) { drawMarginTop(slotLeft, scrolledTop, tessellator); } for (int i = 0; i < size; ++i) { int slotTop = scrolledTop + i * slotHeight + marginTop; int slotHeight = this.slotHeight - 4; if (slotTop <= yPos + height && slotTop + slotHeight >= yPos) { if (showSelectionBox && isSelected(i)) { int outlineLeft = slotLeft - 2; int outlineRight = slotRight + 2; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); tessellator.setColorOpaque_I(0x808080); tessellator.addVertexWithUV(outlineLeft, slotTop + slotHeight + 2, 0.0D, 0.0D, 1.0D); tessellator.addVertexWithUV(outlineRight, slotTop + slotHeight + 2, 0.0D, 1.0D, 1.0D); tessellator.addVertexWithUV(outlineRight, slotTop - 2, 0.0D, 1.0D, 0.0D); tessellator.addVertexWithUV(outlineLeft, slotTop - 2, 0.0D, 0.0D, 0.0D); tessellator.setColorOpaque_I(0x000000); tessellator.addVertexWithUV(outlineLeft + 1, slotTop + slotHeight + 1, 0.0D, 0.0D, 1.0D); tessellator.addVertexWithUV(outlineRight - 1, slotTop + slotHeight + 1, 0.0D, 1.0D, 1.0D); tessellator.addVertexWithUV(outlineRight - 1, slotTop - 1, 0.0D, 1.0D, 0.0D); tessellator.addVertexWithUV(outlineLeft + 1, slotTop - 1, 0.0D, 0.0D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } drawSlot(i, slotLeft, slotTop, slotHeight, tessellator); } } GL11.glDisable(GL11.GL_DEPTH_TEST); drawOverlay(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_TEXTURE_2D); drawGradient(tessellator); drawScrollBar(tessellator); drawFinish(mouseX, mouseY); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); }
From source file:additionalpipes.client.gui.GuiDistributionPipe.java
License:Minecraft Mod Public
@Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { super.drawGuiContainerForegroundLayer(par1, par2); itemRenderer.zLevel = 200F;//www . j a v a2 s .c o m GL11.glEnable(GL11.GL_DEPTH_TEST); itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine, indicator, 9, 7 + 20 * logic.pipe.container.getBlockMetadata()); itemRenderer.zLevel = 0.0F; }
From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java
License:Minecraft Mod Public
private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) { TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine; Tessellator tessellator = Tessellator.instance; if (this.shouldRenderOverlay(itemStack)) { // render colored overlay renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); this.setColorByItemStack(itemStack); Icon icon = this.getIcon(itemStack, 0); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); // render glint if (itemStack.hasEffect(0)) { renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); // first pass GL11.glPushMatrix();/* w w w . ja v a 2s . co m*/ GL11.glScalef(0.125F, 0.125F, 0.125F); float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); // second pass GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } } // render uncolored icon renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Icon icon = this.getIcon(itemStack, 1); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); }
From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java
License:Minecraft Mod Public
private void renderItem2D(ItemRenderType type, ItemStack itemStack, Object... data) { TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine; Tessellator tessellator = Tessellator.instance; if (this.shouldRenderOverlay(itemStack)) { // render colored overlay renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); this.setColorByItemStack(itemStack); Icon icon = this.getIcon(itemStack, 0); ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16); // render glint if (itemStack.hasEffect(0)) { renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT); GL11.glDepthFunc(GL11.GL_GREATER); GL11.glDepthMask(false);//from w w w . j a v a 2 s .c o m GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); // first pass float f2 = Minecraft.getSystemTime() % 3000L / 3000.0F * 256.0F; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * 4.0F) * 0.00390625F, 20 * 0.00390625F); tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * 4.0F) * 0.00390625F, 20 * 0.00390625F); tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0); tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0); tessellator.draw(); // second pass f2 = Minecraft.getSystemTime() % 4873L / 4873.0F * 256.0F; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * -1.0F) * 0.00390625F, 20 * 0.00390625F); tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * -1.0F) * 0.00390625F, 20 * 0.00390625F); tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0); tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0); tessellator.draw(); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); GL11.glDepthFunc(GL11.GL_LEQUAL); } } // render uncolored icon renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber())); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Icon icon = this.getIcon(itemStack, 1); ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16); }
From source file:akarnokd.opengl.experiment.FontExample.java
License:Apache License
/** * Initialise the GL display//from w ww . j a v a 2 s. com * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width, height)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:allout58.mods.techtree.util.RenderingHelper.java
License:Open Source License
public static void draw2DLine(int x1, int y1, int x2, int y2, float width, int colorRGB) { float red = (float) (colorRGB >> 16 & 255) / 255.0F; float blue = (float) (colorRGB >> 8 & 255) / 255.0F; float green = (float) (colorRGB & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D);/* www .jav a2 s . c o m*/ GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(width); GL11.glPushMatrix(); GL11.glColor3f(red, green, blue); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex3d(x1, y1, 0.0D); GL11.glVertex3d(x2, y2, 0.0D); GL11.glEnd(); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
From source file:allout58.mods.techtree.util.RenderingHelper.java
License:Open Source License
public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color, int borderColor) throws IllegalArgumentException { if (radius * 2 > Math.abs(width)) throw new IllegalArgumentException("Error! Width not large enough for radius!"); if (radius * 2 > Math.abs(height)) throw new IllegalArgumentException("Error! Height not large enough for radius!"); if (width < 0) { x += width;/*from ww w.ja va2 s. com*/ width = Math.abs(width); } if (height < 0) { y += height; height = Math.abs(height); } int x1Inner = x + radius; int y1Inner = y + radius; int x2Inner = x + width - radius; int y2Inner = y + height - radius; float red = (float) (borderColor >> 16 & 255) / 255.0F; float green = (float) (borderColor >> 8 & 255) / 255.0F; float blue = (float) (borderColor & 255) / 255.0F; float alpha = (float) (borderColor >> 24 & 255) / 255.0F; Gui.drawRect(x, y1Inner, x1Inner, y2Inner, borderColor); Gui.drawRect(x1Inner, y, x2Inner, y1Inner, borderColor); Gui.drawRect(x2Inner, y1Inner, x + width, y2Inner, borderColor); Gui.drawRect(x1Inner, y2Inner, x2Inner, y + height, borderColor); Gui.drawRect(x1Inner, y1Inner, x2Inner, y2Inner, color); ArrayList<Point> curves = new ArrayList<Point>(); final double[][] start = new double[][] { { x1Inner, y1Inner }, { x2Inner, y1Inner }, { x2Inner, y2Inner }, { x1Inner, y2Inner } }; for (int corner = 0; corner < 4; corner++) { curves.clear(); for (int i = 0; i < VERTEX_PER_CURVE + 1; i++) { double theta = deltaTheta * i + dT[corner]; Point p = new Point(Math.cos(theta), Math.sin(theta)); curves.add(p); } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glPushMatrix(); GL11.glColor4f(red, green, blue, alpha); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex3d(start[corner][0], start[corner][1], 0); for (int i = curves.size() - 1; i >= 0; i--) { GL11.glVertex3d((curves.get(i).getX()) * radius + start[corner][0], (curves.get(i).getY()) * radius + start[corner][1], 0); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); } }
From source file:aphelion.client.Client.java
License:Open Source License
public static void initGL() { int displayWidth = Display.getWidth(); int displayHeight = Display.getHeight(); glDisableAll();/* ww w .j a va 2 s. c om*/ GL11.glViewport(0, 0, displayWidth, displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); // Apply subsequent matrix operations to the projection matrix stack. GL11.glLoadIdentity(); GL11.glOrtho(0, displayWidth, displayHeight, 0, -1, 1); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); AsyncTexture.unbind(); // Enable alpha channels for images GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); Graph.g.setDimensions(displayWidth, displayHeight); Graphics.setCurrent(Graph.g); Graph.g.setDrawMode(Graphics.MODE_NORMAL); }
From source file:appeng.client.gui.widgets.GuiTabButton.java
License:Open Source License
@Override public void drawButton(final Minecraft minecraft, final int x, final int y) { if (this.visible) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png")); this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; int uv_x = (this.hideEdge > 0 ? 11 : 13); final int offsetX = this.hideEdge > 0 ? 1 : 0; this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22); if (this.myIcon >= 0) { final int uv_y = (int) Math.floor(this.myIcon / 16); uv_x = this.myIcon - uv_y * 16; this.drawTexturedModalRect(offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16);//from w w w. ja v a2s . c o m } this.mouseDragged(minecraft, x, y); if (this.myItem != null) { this.zLevel = 100.0F; this.itemRenderer.zLevel = 100.0F; GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); final FontRenderer fontrenderer = minecraft.fontRenderer; this.itemRenderer.renderItemAndEffectIntoGUI(fontrenderer, minecraft.renderEngine, this.myItem, offsetX + this.xPosition + 3, this.yPosition + 3); GL11.glDisable(GL11.GL_LIGHTING); this.itemRenderer.zLevel = 0.0F; this.zLevel = 0.0F; } } }
From source file:appeng.client.render.AppEngRenderItem.java
License:Open Source License
@Override public void renderItemOverlayIntoGUI(final FontRenderer fontRenderer, final TextureManager textureManager, final ItemStack is, final int par4, final int par5, final String par6Str) { if (is != null) { final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f; final float inverseScaleFactor = 1.0f / scaleFactor; final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1; final boolean unicodeFlag = fontRenderer.getUnicodeFlag(); fontRenderer.setUnicodeFlag(false); if (is.getItem().showDurabilityBar(is)) { final double health = is.getItem().getDurabilityForDisplay(is); final int j1 = (int) Math.round(13.0D - health * 13.0D); final int k = (int) Math.round(255.0D - health * 255.0D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); final Tessellator tessellator = Tessellator.instance; final int l = 255 - k << 16 | k << 8; final int i1 = (255 - k) / 4 << 16 | 16128; this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1); this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }// w w w . jav a2 s. c o m if (is.stackSize == 0) { final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); final int X = (int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(craftLabelText) * scaleFactor) * inverseScaleFactor); final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize; if (amount != 0) { final String stackSize = this.getToBeRenderedStackSize(amount); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); final int X = (int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor) * inverseScaleFactor); final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } fontRenderer.setUnicodeFlag(unicodeFlag); } }