List of usage examples for org.lwjgl.opengl GL11 glPushAttrib
public static native void glPushAttrib(@NativeType("GLbitfield") int mask);
From source file:appeng.client.render.items.ToolColorApplicatorRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { final IIcon par2Icon = item.getIconIndex(); float f4 = par2Icon.getMinU(); float f5 = par2Icon.getMaxU(); float f6 = par2Icon.getMinV(); float f7 = par2Icon.getMaxV(); final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix();/*from www . j a v a2 s . co m*/ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); if (type == ItemRenderType.INVENTORY) { GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(16F, 16F, 10F); GL11.glTranslatef(0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(1, 0, 0, f5, f7); tessellator.addVertexWithUV(1, 1, 0, f5, f6); tessellator.addVertexWithUV(0, 1, 0, f4, f6); tessellator.draw(); } else { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else if (type == ItemRenderType.EQUIPPED) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else { GL11.glTranslatef(-0.5F, -0.3F, 0.01F); } final float f12 = 0.0625F; ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(-1F, -1F, 1F); GL11.glTranslatef(-1.125F, 0.0f, f12 / -2.0f); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); } final IIcon dark = ExtraItemTextures.ToolColorApplicatorTip_Dark.getIcon(); final IIcon med = ExtraItemTextures.ToolColorApplicatorTip_Medium.getIcon(); final IIcon light = ExtraItemTextures.ToolColorApplicatorTip_Light.getIcon(); GL11.glScalef(1F / 16F, 1F / 16F, 1F); if (type != ItemRenderType.INVENTORY) { GL11.glTranslatef(2, 0, 0); } GL11.glDisable(GL11.GL_LIGHTING); final AEColor col = ((ToolColorApplicator) item.getItem()).getActiveColor(item); if (col != null) { tessellator.startDrawingQuads(); f4 = dark.getMinU(); f5 = dark.getMaxU(); f6 = dark.getMinV(); f7 = dark.getMaxV(); tessellator.setColorOpaque_I(col.blackVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); f4 = light.getMinU(); f5 = light.getMaxU(); f6 = light.getMinV(); f7 = light.getMaxV(); tessellator.setColorOpaque_I(col.whiteVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); f4 = med.getMinU(); f5 = med.getMaxU(); f6 = med.getMinV(); f7 = med.getMaxV(); tessellator.setColorOpaque_I(col.mediumVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); tessellator.draw(); } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.client.render.items.ToolWirelessTerminalRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { Entity itemLocation = item.getItemFrame(); if (itemLocation == null) { itemLocation = Minecraft.getMinecraft().thePlayer; }/* w w w .j ava 2 s. c o m*/ final boolean displayAntenna = ((ToolWirelessTerminal) item.getItem()).getIsUsable(item, itemLocation); final boolean hasPower = ((ToolWirelessTerminal) item.getItem()).hasPower(null, 0.5, item); IIcon border; if (displayAntenna) { border = ExtraItemTextures.WirelessTerminal_Border.getIcon(); } else { border = ExtraItemTextures.WirelessTerminal_Border_Inactive.getIcon(); } final IIcon scrollBar = ExtraItemTextures.WirelessTerminal_ScrollBar.getIcon(); final IIcon icons = ExtraItemTextures.WirelessTerminal_Icons.getIcon(); IIcon screen = ExtraItemTextures.WirelessTerminal_Screen.getIcon(); final AEColor color = ToolWirelessTerminal.getColor(item); if (color == null) { screen = item.getIconIndex(); } final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); //translate stuff for different item render types if (type != ItemRenderType.INVENTORY) { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else if (type == ItemRenderType.EQUIPPED) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else { GL11.glTranslatef(-0.5F, -0.3F, 0.01F); } } else { GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(16F, 16F, 10F); GL11.glTranslatef(0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); } final float f12 = 0.0625F; //Border, which is uncolored subRenderItem(type, tessellator, border, f12); if (hasPower) { RenderHelper.disableStandardItemLighting(); } //If a terminal isn't colored, use the default icon which doesn't require icons or scrollbar if (color != null) { //Icons, which are dark colored { final int blackColor = color.blackVariant; final float r = (blackColor >> 16) & 0xFF; final float g = (blackColor >> 8) & 0xFF; final float b = blackColor & 0xFF; GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f); subRenderItem(type, tessellator, icons, f12); } //Scrollbar, which is medium colored { final int medColor = color.mediumVariant; final float r = (medColor >> 16) & 0xFF; final float g = (medColor >> 8) & 0xFF; final float b = medColor & 0xFF; GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f); subRenderItem(type, tessellator, scrollBar, f12); } } //Screen, which is light colored { if (color != null) { final int whiteColor = color.whiteVariant; final float r = (whiteColor >> 16) & 0xFF; final float g = (whiteColor >> 8) & 0xFF; final float b = whiteColor & 0xFF; GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f); } subRenderItem(type, tessellator, screen, f12); } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.parts.reporting.PartStorageMonitor.java
License:Open Source License
private void tesrRenderScreen(Tessellator tess, IAEItemStack ais) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); ForgeDirection d = this.side; GL11.glTranslated(d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77); if (d == ForgeDirection.UP) { GL11.glScalef(1.0f, -1.0f, 1.0f); GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f); GL11.glRotatef(this.spin * 90.0F, 0, 0, 1); }/*from w w w . ja va 2 s . c o m*/ if (d == ForgeDirection.DOWN) { GL11.glScalef(1.0f, -1.0f, 1.0f); GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); GL11.glRotatef(this.spin * -90.0F, 0, 0, 1); } if (d == ForgeDirection.EAST) { GL11.glScalef(-1.0f, -1.0f, -1.0f); GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); } if (d == ForgeDirection.WEST) { GL11.glScalef(-1.0f, -1.0f, -1.0f); GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f); } if (d == ForgeDirection.NORTH) { GL11.glScalef(-1.0f, -1.0f, -1.0f); } if (d == ForgeDirection.SOUTH) { GL11.glScalef(-1.0f, -1.0f, -1.0f); GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f); } GL11.glPushMatrix(); try { ItemStack sis = ais.getItemStack(); sis.stackSize = 1; int br = 16 << 20 | 16 << 4; int var11 = br % 65536; int var12 = br / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL12.GL_RESCALE_NORMAL); // RenderHelper.enableGUIStandardItemLighting(); tess.setColorOpaque_F(1.0f, 1.0f, 1.0f); ClientHelper.proxy.doRenderItem(sis, this.tile.getWorldObj()); } catch (Exception e) { AELog.error(e); } GL11.glPopMatrix(); GL11.glTranslatef(0.0f, 0.14f, -0.24f); GL11.glScalef(1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f); final long stackSize = ais.getStackSize(); final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize); FontRenderer fr = Minecraft.getMinecraft().fontRenderer; int width = fr.getStringWidth(renderedStackSize); GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f); fr.drawString(renderedStackSize, 0, 0, 0); GL11.glPopAttrib(); }
From source file:arg.RenderRecipe.java
License:Open Source License
public void draw() { File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes"); if (!dir.exists() && !dir.mkdirs()) { throw new RuntimeException("The recipes directory could not be created: " + dir); }/*from ww w.jav a 2 s . com*/ name = name.replace(" ", ""); File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png"); if (file.exists()) return; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glViewport(0, 0, width, height); GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GL11.glEnable(GL11.GL_COLOR_MATERIAL); try { drawScreen(0, 0, 0); } catch (Exception e) { e.printStackTrace(); } int[] pixels = new int[width * height]; int bindex; ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); GL11.glPopMatrix(); GL11.glPopAttrib(); GL11.glPopClientAttrib(); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); try { Display.swapBuffers(); } catch (LWJGLException e1) { e1.printStackTrace(); } BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * 3; int r = fb.get(i) & 0xFF; int g = fb.get(i + 1) & 0xFF; int b = fb.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } try { ImageIO.write(image, "png", file); } catch (Exception e) { e.printStackTrace(); } }
From source file:buildcraft.builders.render.RenderArchitect.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileArchitect architect = (TileArchitect) tileentity; GL11.glPushMatrix();/*from ww w .j av a 2s .co m*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); for (LaserData laser : architect.subLasers) { if (laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaserWave(TileEntityRendererDispatcher.instance.field_147553_e, laser, EntityLaser.LASER_TEXTURES[3]); GL11.glPopMatrix(); } } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:buildcraft.builders.render.RenderConstructionMarker.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileConstructionMarker marker = (TileConstructionMarker) tileentity; GL11.glPushMatrix();// w w w . jav a 2s .com GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); if (marker.laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, marker.laser, EntityLaser.LASER_TEXTURES[4]); GL11.glPopMatrix(); } if (marker.itemBlueprint != null) { doRenderItem(marker.itemBlueprint, marker.xCoord + 0.5F, marker.yCoord + 0.2F, marker.zCoord + 0.5F); } //GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopAttrib(); GL11.glPopMatrix(); renderItems.render(tileentity, x, y, z); }
From source file:buildcraft.builders.RenderArchitect.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileArchitect architect = (TileArchitect) tileentity; if (architect != null) { GL11.glPushMatrix();//www . j a v a 2 s . c o m GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); for (LaserData laser : architect.subLasers) { if (laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaserWave(TileEntityRendererDispatcher.instance.field_147553_e, laser, EntityLaser.LASER_TEXTURES[3]); GL11.glPopMatrix(); } } GL11.glPopAttrib(); GL11.glPopMatrix(); } }
From source file:buildcraft.builders.RenderBuilder.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileAbstractBuilder builder = (TileAbstractBuilder) tileentity; if (builder != null) { GL11.glPushMatrix();/*w ww .j a v a 2 s . c o m*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); if (builder.getPathLaser() != null) { for (LaserData laser : builder.getPathLaser()) { if (laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser, EntityLaser.LASER_TEXTURES[4]); GL11.glPopMatrix(); } } } //GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopAttrib(); GL11.glPopMatrix(); } GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); if (builder.getBuilders() != null) { for (BuildingItem i : builder.getBuilders()) { doRenderItem(i, 1.0F); } } GL11.glPopMatrix(); }
From source file:buildcraft.builders.RenderConstructionMarker.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileConstructionMarker marker = (TileConstructionMarker) tileentity; if (marker != null) { GL11.glPushMatrix();//from w w w. j a v a2s . co m GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); if (marker.laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, marker.laser, EntityLaser.LASER_TEXTURES[4]); GL11.glPopMatrix(); } if (marker.itemBlueprint != null) { doRenderItem(marker.itemBlueprint, marker.xCoord + 0.5F, marker.yCoord + 0.2F, marker.zCoord + 0.5F); } //GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopAttrib(); GL11.glPopMatrix(); renderItems.render(tileentity, x, y, z); } }
From source file:buildcraft.builders.RenderPathMarker.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { TilePathMarker marker = (TilePathMarker) tileentity; if (marker != null) { GL11.glPushMatrix();/*ww w .j a va2 s . co m*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); for (LaserData laser : marker.lasers) { if (laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser, EntityLaser.LASER_TEXTURES[3]); GL11.glPopMatrix(); } } //GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopAttrib(); GL11.glPopMatrix(); } }