List of usage examples for org.lwjgl.opengl GL11 glDisable
public static void glDisable(@NativeType("GLenum") int target)
From source file:$.DrawSystem.java
License:Open Source License
@Override protected void processEntities(ImmutableBag<Entity> entities) { GL11.glClearColor(0.1f, 0, 0, 1f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); List<Entity> entititesSortedByZ = new ArrayList<>(entities.size()); for (int i = 0, n = entities.size(); i < n; ++i) { final Entity e = entities.get(i); if (e.isEnabled()) { entititesSortedByZ.add(e); }/*w ww . j a v a 2 s .c o m*/ } Collections.sort(entititesSortedByZ, zComparator); GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); updateViewPort(); GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height); GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); Game game = (Game) world; Entity hero = game.getHero(); if (null != hero) { Sprite heroSprite = spriteMapper.get(hero); Vector heroPos = spriteProjector.project(heroSprite.getPosition()); GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f); } for (Entity e : entititesSortedByZ) { MainMenu mainMenu = mainMenuMapper.getSafe(e); if (null != mainMenu) { mainMenu.draw(); } DialogueComponent dialog = dialogMapper.getSafe(e); if (null != dialog) { dialog.draw(); } Level level = levelMapper.getSafe(e); if (null != level) { drawLevel(level); } Sprite sprite = spriteMapper.getSafe(e); if (null != sprite) { drawSprite(sprite); } } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:$.DrawSystem.java
License:Open Source License
private void drawSprite(Sprite sprite) { Vector pos = spriteProjector.project(sprite.getPosition()); final IPlay play = sprite.getPlay(); if (null != play) { GL11.glPushMatrix();/*from ww w . jav a 2 s . com*/ GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f); GL11.glScalef(sprite.getScale(), sprite.getScale(), 1); final IAnimationFrame frame = play.getCurrentFrame(); final IAnimationImage image = frame.getImage(); if (image.hasAlpha()) { GL11.glEnable(GL11.GL_BLEND); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) image.getId()); final float u1, u2; if (sprite.isMirrorX()) { u1 = frame.getU2(); u2 = frame.getU1(); } else { u1 = frame.getU1(); u2 = frame.getU2(); } final float v1, v2; if (sprite.isMirrorY()) { v1 = frame.getV1(); v2 = frame.getV2(); } else { v1 = frame.getV2(); v2 = frame.getV1(); } GL11.glColor4f(sprite.getRed(), sprite.getGreen(), sprite.getBlue(), sprite.getAlpha()); float x1 = -sprite.getWidth() / 2.0f; float x2 = sprite.getWidth() / 2.0f; float y1 = -sprite.getHeight() / 2.0f; float y2 = sprite.getHeight() / 2.0f; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glColor3f(1f, 1f, 1f); if (image.hasAlpha()) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); } if (null != sprite.getLabel()) { GL11.glPushMatrix(); GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glScalef(0.5f, -0.5f, 1f); GL11.glEnable(GL11.GL_BLEND); LwjglNuitFont font = (LwjglNuitFont) assets.getFont(""); font.drawString(sprite.getLabel(), LwjglNuitFont.Align.CENTER); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } }
From source file:a1.gui.GUI_Edit.java
License:Open Source License
public void DoRender() { int state;//from w w w .j a v a2 s . c o m if (!enabled) state = StateDisable; else { if (isFocused()) state = StateNormal_Checked; else { if (MouseInMe()) { if (pressed) state = StatePressed; else state = StateHighlight; } else state = StateNormal; } } getSkin().Draw(skin_element, abs_pos.x, abs_pos.y, size.x, size.y, state); Render2D.PushScissor(new Rect(abs_pos.x + OFFSET, abs_pos.y + OFFSET, size.x - OFFSET, size.y - OFFSET)); int left = Render2D.GetTextWidth(font_name, getVisualText().substring(0, getSelectionStart())); int SelectionWidth = Render2D.GetTextWidth(font_name, getVisualText().substring(getSelectionStart(), getSelectionFinish())); int CursorShift = Render2D.GetTextWidth(font_name, getVisualText().substring(0, pos2)); if (isFocused()) { GL11.glDisable(GL11.GL_TEXTURE_2D); if (pos1 != pos2) { Render2D.FillRect(new Coord(abs_pos.x + left + OFFSET - scroll, abs_pos.y), new Coord(SelectionWidth, size.y), new Color(0.5f, 0.5f, 0.8f, 0.9f)); } if ((System.currentTimeMillis() % 1000) > 500) { Render2D.ChangeColor(Color.green); Render2D.Rectangle(new Coord(abs_pos.x + CursorShift + OFFSET - scroll + 1, abs_pos.y), new Coord(1, size.y)); } GL11.glEnable(GL11.GL_TEXTURE_2D); } if (getVisualText().length() > 0) Render2D.Text(font_name, abs_pos.x + OFFSET - scroll, abs_pos.y + OFFSET, size.x - OFFSET, size.y - OFFSET, Render2D.Align_Left + Render2D.Align_VStretch, getVisualText(), text_color); Render2D.PopScissor(); }
From source file:a1.Main.java
License:Open Source License
private void initGL() { // enable textures since we're going to use these for our sprites GL11.glPointSize(1);/* w w w . j a v a 2 s.c o m*/ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); glClearColor(0.0f, 0.0f, 0.0f, 0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // disable the OpenGL depth test since we're rendering 2D graphics GL11.glDisable(GL11.GL_DEPTH_TEST); }
From source file:a1.Render2D.java
License:Open Source License
static public void PopScissor() { if (scissors.size() < 1) return;//from w w w . j av a 2 s. c o m current_scissor = scissors.pop(); if (current_scissor != null) GL11.glScissor(current_scissor.x, current_scissor.y, current_scissor.w, current_scissor.h); else GL11.glDisable(GL11.GL_SCISSOR_TEST); }
From source file:a1.Render2D.java
License:Open Source License
static public void Disable2D() { if (enabled2d) { GL11.glDisable(GL11.GL_TEXTURE_2D); Sprite.binded_texture_id = -1;//w ww.j a va 2 s . c om enabled2d = false; } }
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 . java2s . 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.GuiTeleportManager.java
License:Minecraft Mod Public
private void renderPipeMap(int map, MapData mapData) { RenderHelper.disableStandardItemLighting(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_DEPTH_TEST); mc.renderEngine.bindTexture(MAP_TEXTURE); GL11.glPushMatrix();//from ww w. j a va 2 s . c o m Tessellator var4 = Tessellator.instance; var4.startDrawingQuads(); byte var5 = 7; var4.addVertexWithUV(0 - var5, 128 + var5, 0.0D, 0.0D, 1.0D); var4.addVertexWithUV(128 + var5, 128 + var5, 0.0D, 1.0D, 1.0D); var4.addVertexWithUV(128 + var5, 0 - var5, 0.0D, 1.0D, 0.0D); var4.addVertexWithUV(0 - var5, 0 - var5, 0.0D, 0.0D, 0.0D); var4.draw(); mapRenderer.renderMap(mc.thePlayer, mc.renderEngine, mapData); PropertyIntArray pipeArr = (PropertyIntArray) clientProps.propPipes.value.get(PropertyInteger.create(map)); int[] pipes = pipeArr != null ? pipeArr.value : ArrayUtils.EMPTY_INT_ARRAY; for (int p = 0; p < pipes.length / 3; p++) { int centerX = pipes[p * 3 + 1]; int centerZ = pipes[p * 3 + 2]; GL11.glPushMatrix(); GL11.glTranslatef(centerX / 2.0F + 64.0F - 4, centerZ / 2.0F + 64.0F - 4, -0.02F); GL11.glScalef(0.5F, 0.5F, 0.5F); itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine, new ItemStack(getTeleportPipe(PipeType.values()[pipes[p * 3]]), 1), 0, 0); GL11.glPopMatrix(); } GL11.glPopMatrix(); }
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();//from w w w .ja v a 2 s . c om 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 ww . j a v a 2s .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); }