List of usage examples for org.lwjgl.opengl GL11 glPushAttrib
public static native void glPushAttrib(@NativeType("GLbitfield") int mask);
From source file:mods.railcraft.client.render.RenderTrackBuffer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float time) { if (tile instanceof TileTrack) { if (((TileTrack) tile).getTrackInstance() instanceof TrackBufferStop) { TrackBufferStop track = (TrackBufferStop) ((TileTrack) tile).getTrackInstance(); GL11.glPushMatrix();/*w w w.j a va2 s . c om*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glColor3f(1, 1, 1); GL11.glTranslatef((float) x, (float) y, (float) z); model.resetRotation(); int meta = tile.getBlockMetadata(); if (meta == 1) { model.rotateY((float) (Math.PI / 2.0)); } if (meta == 0 != track.isReversed()) { model.rotateY((float) Math.PI); } bindTexture(TEXTURE); model.render(1f / 16f); GL11.glPopAttrib(); GL11.glPopMatrix(); } } }
From source file:net.adam_keenan.voxel.hud.HUD.java
License:Creative Commons License
public static void drawCrosshairs() { float screenx = (float) Display.getWidth() / 2, screeny = (float) Display.getHeight() / 2; float x1, y1, x2, y2, width1 = 4, height1 = 20, width2 = height1, height2 = width1; x1 = screenx - width1 / 2;//from w w w.j a v a2s. c o m y1 = screeny - height1 / 2; x2 = screenx - width2 / 2; y2 = screeny - height2 / 2; FloatBuffer perspectiveProjectionMatrix; FloatBuffer orthographicProjectionMatrix; perspectiveProjectionMatrix = BufferUtils.createFloatBuffer(16); orthographicProjectionMatrix = BufferUtils.createFloatBuffer(16); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix); // GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_PROJECTION); // For text drawing GL11.glLoadMatrix(orthographicProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glLoadIdentity(); // Clears matrix GL11.glColor4f(0, 0, 0, .5f); GL11.glRectf(x1, y1, x1 + width1, y1 + height1); GL11.glRectf(x2, y2, x2 + (width2 - width1) / 2, y2 + height2); GL11.glRectf(x2 + (width2 + width1) / 2, y2, x2 + width2, y2 + height2); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
From source file:net.cortexmodders.lyoko.client.render.RenderUtil.java
License:MIT License
/** * called for things with alpha. thank you MachineMuse. :D *///from w w w . jav a 2s .co m public static void alphaOn() { GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); if (Minecraft.isFancyGraphicsEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } }
From source file:net.malisis.core.client.gui.component.UIComponent.java
License:Open Source License
/** * Draws this {@link UIComponent} Called by {@link #parent} component.<br> * Will set the size of {@link #shape} according to the size of this <code>UIComponent</code><br> * Rendering is surrounded by glPushAttrib(GL_ALL_ATTRIB_BITS) so no state should bleed between components. Also, a draw() is triggered * between background and foreground./* ww w . ja v a 2 s .c o m*/ * * @param renderer the renderer * @param mouseX the mouse x * @param mouseY the mouse y * @param partialTick the partial tick */ public void draw(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) { if (!isVisible()) return; if (shape != null) { shape.resetState(); shape.setSize(getWidth(), getHeight()); } if (rp != null) rp.reset(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); if (getAlpha() < 255) { GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA); GL14.glBlendColor(1, 1, 1, (float) getAlpha() / 255); } //draw background renderer.currentComponent = this; drawBackground(renderer, mouseX, mouseY, partialTick); renderer.next(); //draw foreground renderer.currentComponent = this; ClipArea area = this instanceof IClipable ? ((IClipable) this).getClipArea() : null; if (area != null) renderer.startClipping(area); //GL11.glColor4f(1, 1, 1, 0.5F); drawForeground(renderer, mouseX, mouseY, partialTick); if (area != null) renderer.endClipping(area); renderer.next(); for (IControlComponent c : controlComponents) c.draw(renderer, mouseX, mouseY, partialTick); GL11.glPopAttrib(); }
From source file:net.malisis.core.client.gui.GuiRenderer.java
License:Open Source License
/** * Starts clipping an area to prevent drawing outside of it. * * @param area the area/* www. j av a 2 s .c o m*/ */ public void startClipping(ClipArea area) { if (area.noClip || area.width() <= 0 || area.height() <= 0) return; GL11.glPushAttrib(GL11.GL_SCISSOR_BIT); GL11.glEnable(GL11.GL_SCISSOR_TEST); int f = ignoreScale ? 1 : scaleFactor; int x = area.x * f; int y = displayHeight - (area.y + area.height()) * f; int w = area.width() * f; int h = area.height() * f; ; GL11.glScissor(x, y, w, h); }
From source file:net.malisis.core.renderer.MalisisRenderer.java
License:Open Source License
/** * Prepares the {@link Tessellator} and the GL states for the <b>renderType</b>. <b>data</b> is only used for TESR and IRWL.<br> * TESR and IRWL rendering are surrounded by glPushAttrib(GL_LIGHTING_BIT) and block texture sheet is bound. * * @param renderType the render type/* w ww . j av a2 s.c o m*/ * @param data the data */ public void prepare(RenderType renderType, double... data) { _initialize(); this.renderType = renderType; if (renderType == RenderType.ISBRH_WORLD) { tessellatorShift(); } else if (renderType == RenderType.ISBRH_INVENTORY) { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); startDrawing(); } else if (renderType == RenderType.ITEM_INVENTORY) { GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); startDrawing(); } else if (renderType == RenderType.TESR_WORLD) { GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); RenderHelper.disableStandardItemLighting(); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glTranslated(data[0], data[1], data[2]); bindTexture(TextureMap.locationBlocksTexture); startDrawing(); } else if (renderType == RenderType.WORLD_LAST) { GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); RenderHelper.disableStandardItemLighting(); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glTranslated(data[0], data[1], data[2]); bindTexture(TextureMap.locationBlocksTexture); startDrawing(); } }
From source file:net.mechanicalcat.pycode.gui.GuiTextArea.java
License:Open Source License
public void drawEditor() { String content = getString(); // first up, determine the scroll offset int xoff = textXOffset / SCROLL_SCALE; int yoff = textYOffset / SCROLL_SCALE; if (yoff > 0) { yoff = 0;/*from w ww . ja v a2 s .co m*/ textYOffset = 0; } else { int totHeight = -this.fontRenderer.FONT_HEIGHT * this.lines.length; if (totHeight < height && yoff < totHeight + height) { yoff = totHeight + height; textYOffset = yoff * SCROLL_SCALE; } } if (xoff < 0) { xoff = 0; textXOffset = 0; } else { int maxWidth = 0; for (String line : this.lines) { int w = this.fontRenderer.getStringWidth(line); if (w > maxWidth) maxWidth = w; } if (maxWidth > width && xoff > maxWidth - width) { xoff = maxWidth - width; textXOffset = xoff * SCROLL_SCALE; } } // offset rendering by the scroll offset GlStateManager.pushMatrix(); GlStateManager.translate(-xoff, yoff, 0); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(xScissor, yScissor, wScissor, hScissor); // draw cursor int cursorPos; if (this.cursorRow == this.lines.length) { cursorPos = 0; // current line is empty } else { cursorPos = this.fontRenderer .getStringWidth(this.lines[this.cursorRow].substring(0, this.cursorColumn)); } int cursor_x = this.xPosition + cursorPos; int cursor_y = this.yPosition + this.cursorRow * this.fontRenderer.FONT_HEIGHT + 1; if (this.cursorCounter / 6 % 2 == 0) { this.fontRenderer.drawString("_", cursor_x, cursor_y, 0); } else { this.fontRenderer.drawString("_", cursor_x, cursor_y, 0x55000000); } // draw content int x = this.xPosition; int y = this.yPosition; for (String s : this.lines) { this.fontRenderer.drawString(s, x, y, 0); y += this.fontRenderer.FONT_HEIGHT; } // reset state GlStateManager.popMatrix(); GL11.glPopAttrib(); }
From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock.java
License:Open Source License
@SideOnly(Side.CLIENT) @Override//from w w w . j a va 2 s . c o m public void renderInventoryBlock(net.minecraft.block.Block block, int metadata, int modelId, RenderBlocks renderer) { Optional<ItemRenderer> opRenderer = this.dummy.components.getOp(ItemRenderer.class); if (opRenderer.isPresent()) { GL11.glPushAttrib(GL_TEXTURE_BIT); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); Tessellator.instance.startDrawingQuads(); BWModel model = new BWModel(); opRenderer.get().onRender.accept(model); model.render(); Tessellator.instance.draw(); GL11.glPopMatrix(); GL11.glPopAttrib(); } }
From source file:ocelot.mods.qp2.client.RenderRefinery.java
License:Open Source License
private void render(TileRefineryPlus tile, double x, double y, double z) { FluidStack liquid1 = null, liquid2 = null, liquidResult = null; float anim = 0; int angle = 0; ModelRenderer theMagnet = this.magnet[0]; if (tile != null) { liquid1 = tile.src1;/*from ww w . j a va2s .c o m*/ liquid2 = tile.src2; liquidResult = tile.res; anim = tile.getAnimationStage(); angle = 0; switch (tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) { case 2: angle = 90; break; case 3: angle = 270; break; case 4: angle = 180; break; case 5: angle = 0; break; } if (tile.animationSpeed <= 1) { theMagnet = this.magnet[0]; } else if (tile.animationSpeed <= 2.5) { theMagnet = this.magnet[1]; } else if (tile.animationSpeed <= 4.5) { theMagnet = this.magnet[2]; } else { theMagnet = this.magnet[3]; } } GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glRotatef(angle, 0, 1, 0); bindTexture(TEXTURE); GL11.glPushMatrix(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-4F * pixel, 0, -4F * pixel); this.tank.render(pixel); GL11.glTranslatef(4F * pixel, 0, 4F * pixel); GL11.glTranslatef(-4F * pixel, 0, 4F * pixel); this.tank.render(pixel); GL11.glTranslatef(4F * pixel, 0, -4F * pixel); GL11.glTranslatef(4F * pixel, 0, 0); this.tank.render(pixel); GL11.glTranslatef(-4F * pixel, 0, 0); GL11.glPopMatrix(); float trans1, trans2; if (anim <= 100) { trans1 = 12F * pixel * anim / 100F; trans2 = 0; } else if (anim <= 200) { trans1 = 12F * pixel - (12F * pixel * (anim - 100F) / 100F); trans2 = 12F * pixel * (anim - 100F) / 100F; } else { trans1 = 12F * pixel * (anim - 200F) / 100F; trans2 = 12F * pixel - (12F * pixel * (anim - 200F) / 100F); } GL11.glPushMatrix(); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glTranslatef(-0.51F, trans1 - 0.5F, -0.5F); theMagnet.render(pixel); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(0.99F, 0.99F, 0.99F); GL11.glTranslatef(-0.51F, trans2 - 0.5F, 12F * pixel - 0.5F); theMagnet.render(pixel); GL11.glPopMatrix(); if (tile != null) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glScalef(0.5F, 1, 0.5F); if (liquid1 != null && liquid1.amount > 0) { int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false); if (list1 != null) { bindTexture(FluidRenderer.getFluidSheet(liquid1)); FluidRenderer.setColorForFluidStack(liquid1); GL11.glCallList( list1[(int) (liquid1.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); } } if (liquid2 != null && liquid2.amount > 0) { int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.worldObj, false); if (list2 != null) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 1); bindTexture(FluidRenderer.getFluidSheet(liquid2)); FluidRenderer.setColorForFluidStack(liquid2); GL11.glCallList( list2[(int) (liquid2.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); GL11.glPopMatrix(); } } if (liquidResult != null && liquidResult.amount > 0) { int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.worldObj, false); if (list3 != null) { GL11.glPushMatrix(); GL11.glTranslatef(1, 0, 0.5F); bindTexture(FluidRenderer.getFluidSheet(liquidResult)); FluidRenderer.setColorForFluidStack(liquidResult); GL11.glCallList(list3[(int) (liquidResult.amount / (float) tile.buf * (FluidRenderer.DISPLAY_STAGES - 1))]); GL11.glPopMatrix(); } } GL11.glPopAttrib(); } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:org.agpu.oc.common.tileentity.AdvancedMonitor.java
public void startDrawing3D(int x, int y, int width, int height, float fov, float zNear, float zFar) { if (worldObj.isRemote) { GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glViewport(0, 0, width, height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();//from w w w .j av a 2 s . co m GL11.glLoadIdentity(); GLU.gluPerspective(fov, (float) width / (float) height, zNear, zFar); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glClearColor(cr, cg, cb, ca); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } }