List of usage examples for org.lwjgl.opengl GL11 glNewList
public static native void glNewList(@NativeType("GLuint") int n, @NativeType("GLenum") int mode);
From source file:buildcraft.core.render.FluidRenderer.java
License:Minecraft Mod Public
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) { if (fluidStack == null) { return null; }/*from w w w . j a v a 2s . c o m*/ Fluid fluid = fluidStack.getFluid(); if (fluid == null) { return null; } Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache; int[] diplayLists = cache.get(fluid); if (diplayLists != null) { return diplayLists; } diplayLists = new int[DISPLAY_STAGES]; if (fluid.getBlock() != null) { liquidBlock.baseBlock = fluid.getBlock(); liquidBlock.texture = getFluidTexture(fluidStack, flowing); } else { liquidBlock.baseBlock = Blocks.water; liquidBlock.texture = getFluidTexture(fluidStack, flowing); } cache.put(fluid, diplayLists); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_CULL_FACE); for (int s = 0; s < DISPLAY_STAGES; ++s) { diplayLists[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/); liquidBlock.minX = 0.01f; liquidBlock.minY = 0; liquidBlock.minZ = 0.01f; liquidBlock.maxX = 0.99f; liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES; liquidBlock.maxZ = 0.99f; RenderEntityBlock.INSTANCE.renderBlock(liquidBlock, world, 0, 0, 0, false, true); GL11.glEndList(); } GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); return diplayLists; }
From source file:buildcraft.core.render.LiquidRenderer.java
License:Minecraft Mod Public
public static int[] getLiquidDisplayLists(LiquidStack liquid, World world, boolean flowing) { if (liquid == null) { return null; }/*ww w . j a va 2s . c om*/ liquid = liquid.canonical(); if (liquid == null) { throw new LiquidCanonException(liquid); } Map<LiquidStack, int[]> cache = flowing ? flowingRenderCache : stillRenderCache; int[] diplayLists = cache.get(liquid); if (diplayLists != null) { return diplayLists; } diplayLists = new int[DISPLAY_STAGES]; if (liquid.itemID < Block.blocksList.length && Block.blocksList[liquid.itemID] != null) { liquidBlock.baseBlock = Block.blocksList[liquid.itemID]; if (!flowing) { liquidBlock.texture = getLiquidTexture(liquid); } } else if (Item.itemsList[liquid.itemID] != null) { liquidBlock.baseBlock = Block.waterStill; liquidBlock.texture = getLiquidTexture(liquid); } else { return null; } cache.put(liquid, diplayLists); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_CULL_FACE); ItemStack stack = liquid.asItemStack(); int color = stack.getItem().getColorFromItemStack(stack, 0); float c1 = (float) (color >> 16 & 255) / 255.0F; float c2 = (float) (color >> 8 & 255) / 255.0F; float c3 = (float) (color & 255) / 255.0F; GL11.glColor4f(c1, c2, c3, 1); for (int s = 0; s < DISPLAY_STAGES; ++s) { diplayLists[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/); liquidBlock.minX = 0.01f; liquidBlock.minY = 0; liquidBlock.minZ = 0.01f; liquidBlock.maxX = 0.99f; liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES; liquidBlock.maxZ = 0.99f; RenderEntityBlock.renderBlock(liquidBlock, world, 0, 0, 0, false, true); GL11.glEndList(); } GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); return diplayLists; }
From source file:buildcraft.core.render.RenderLaser.java
License:Minecraft Mod Public
private static void initScaledBoxes() { if (scaledBoxes == null) { scaledBoxes = new int[100][20]; for (int size = 0; size < 100; ++size) { for (int i = 0; i < 20; ++i) { scaledBoxes[size][i] = GLAllocation.generateDisplayLists(1); GL11.glNewList(scaledBoxes[size][i], GL11.GL_COMPILE); RenderInfo block = new RenderInfo(); float minSize = 0.2F * size / 100F; float maxSize = 0.4F * size / 100F; //float minSize = 0.1F; //float maxSize = 0.2F; float range = maxSize - minSize; float diff = (float) (Math.cos(i / 20F * 2 * Math.PI) * range / 2F); block.minX = 0.0;//from w w w. ja va2 s .c om block.minY = -maxSize / 2F + diff; block.minZ = -maxSize / 2F + diff; block.maxX = STEP; block.maxY = maxSize / 2F - diff; block.maxZ = maxSize / 2F - diff; RenderEntityBlock.INSTANCE.renderBlock(block, null, 0, 0, 0, false, true); GL11.glEndList(); } } } }
From source file:buildcraft.factory.RenderRefinery.java
License:Minecraft Mod Public
private int[] getDisplayLists(int liquidId, World world) { if (stage.containsKey(liquidId)) return stage.get(liquidId); int[] d = new int[displayStages]; stage.put(liquidId, d);/*www .j a v a 2s .c om*/ BlockInterface block = new BlockInterface(); // Retrieve the texture depending on type of item. if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) block.texture = Block.blocksList[liquidId].blockIndexInTexture; else if (Item.itemsList[liquidId] != null) block.texture = Item.itemsList[liquidId].getIconFromDamage(0); else return null; for (int s = 0; s < displayStages; ++s) { d[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d[s], 4864 /* GL_COMPILE */); block.minX = 0.5 - 4F * factor + 0.01; block.minY = 0; block.minZ = 0.5 - 4F * factor + 0.01; block.maxX = 0.5 + 4F * factor - 0.01; block.maxY = (float) s / (float) displayStages; block.maxZ = 0.5 + 4F * factor - 0.01; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }
From source file:buildcraft.factory.RenderTank.java
License:Minecraft Mod Public
private int[] getDisplayLists(int liquidId, int damage, World world) { if (stage.containsKey(liquidId)) return stage.get(liquidId); int[] d = new int[displayStages]; stage.put(liquidId, d);// w w w . ja va 2s .co m BlockInterface block = new BlockInterface(); if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) block.texture = Block.blocksList[liquidId].blockIndexInTexture; else block.texture = Item.itemsList[liquidId].getIconFromDamage(damage); for (int s = 0; s < displayStages; ++s) { d[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d[s], 4864 /* GL_COMPILE */); block.minX = 0.125 + 0.01; block.minY = 0; block.minZ = 0.125 + 0.01; block.maxX = 0.875 - 0.01; block.maxY = (float) s / (float) displayStages; block.maxZ = 0.875 - 0.01; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }
From source file:buildcraft.transport.render.PipeRendererTESR.java
License:Minecraft Mod Public
private DisplayFluidList getDisplayFluidLists(int liquidId, World world) { if (displayFluidLists.containsKey(liquidId)) { return displayFluidLists.get(liquidId); }//from w w w . j a v a 2 s . c om DisplayFluidList d = new DisplayFluidList(); displayFluidLists.put(liquidId, d); RenderInfo block = new RenderInfo(); Fluid fluid = FluidRegistry.getFluid(liquidId); if (fluid.getBlock() != null) { block.baseBlock = fluid.getBlock(); } else { block.baseBlock = Blocks.water; } block.texture = fluid.getStillIcon(); float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; // render size for (int s = 0; s < LIQUID_STAGES; ++s) { float ratio = (float) s / (float) LIQUID_STAGES; // SIDE HORIZONTAL d.sideHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */); block.minX = 0.0F; block.minZ = CoreConstants.PIPE_MIN_POS + 0.01F; block.maxX = block.minX + size / 2F + 0.01F; block.maxZ = block.minZ + size - 0.02F; block.minY = CoreConstants.PIPE_MIN_POS + 0.01F; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // SIDE VERTICAL d.sideVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */); block.minY = CoreConstants.PIPE_MAX_POS - 0.01; block.maxY = 1; block.minX = 0.5 - (size / 2 - 0.01) * ratio; block.maxX = 0.5 + (size / 2 - 0.01) * ratio; block.minZ = 0.5 - (size / 2 - 0.01) * ratio; block.maxZ = 0.5 + (size / 2 - 0.01) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER HORIZONTAL d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */); block.minX = CoreConstants.PIPE_MIN_POS + 0.01; block.minZ = CoreConstants.PIPE_MIN_POS + 0.01; block.maxX = block.minX + size - 0.02; block.maxZ = block.minZ + size - 0.02; block.minY = CoreConstants.PIPE_MIN_POS + 0.01; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER VERTICAL d.centerVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */); block.minY = CoreConstants.PIPE_MIN_POS + 0.01; block.maxY = CoreConstants.PIPE_MAX_POS - 0.01; block.minX = 0.5 - (size / 2 - 0.02) * ratio; block.maxX = 0.5 + (size / 2 - 0.02) * ratio; block.minZ = 0.5 - (size / 2 - 0.02) * ratio; block.maxZ = 0.5 + (size / 2 - 0.02) * ratio; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }
From source file:buildcraft.transport.render.PipeRendererTESR.java
License:Minecraft Mod Public
private void initializeDisplayPowerList(World world) { if (initialized) { return;//from w ww . j a v a2 s . c o m } initialized = true; RenderInfo block = new RenderInfo(); block.texture = BuildCraftTransport.instance.pipeIconProvider .getIcon(PipeIconProvider.TYPE.Power_Normal.ordinal()); float size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerList[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(displayPowerList[s], 4864 /* GL_COMPILE */); float minSize = 0.005F; float unit = (size - minSize) / 2F / POWER_STAGES; block.minY = 0.5 - (minSize / 2F) - unit * s; block.maxY = 0.5 + (minSize / 2F) + unit * s; block.minZ = 0.5 - (minSize / 2F) - unit * s; block.maxZ = 0.5 + (minSize / 2F) + unit * s; block.minX = 0; block.maxX = 0.5 + (minSize / 2F) + unit * s; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } block.texture = BuildCraftTransport.instance.pipeIconProvider .getIcon(PipeIconProvider.TYPE.Power_Overload.ordinal()); size = CoreConstants.PIPE_MAX_POS - CoreConstants.PIPE_MIN_POS; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(displayPowerListOverload[s], 4864 /* GL_COMPILE */); float minSize = 0.005F; float unit = (size - minSize) / 2F / POWER_STAGES; block.minY = 0.5 - (minSize / 2F) - unit * s; block.maxY = 0.5 + (minSize / 2F) + unit * s; block.minZ = 0.5 - (minSize / 2F) - unit * s; block.maxZ = 0.5 + (minSize / 2F) + unit * s; block.minX = 0; block.maxX = 0.5 + (minSize / 2F) + unit * s; RenderEntityBlock.INSTANCE.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } }
From source file:buildcraft.transport.render.RenderPipe.java
License:Minecraft Mod Public
private DisplayLiquidList getDisplayLiquidLists(int liquidId, int meta, World world) { if (displayLiquidLists.containsKey(liquidId)) { HashMap<Integer, DisplayLiquidList> x = displayLiquidLists.get(liquidId); if (x.containsKey(meta)) return x.get(meta); } else {/*from w w w .j av a 2 s.c o m*/ displayLiquidLists.put(liquidId, new HashMap<Integer, DisplayLiquidList>()); } DisplayLiquidList d = new DisplayLiquidList(); displayLiquidLists.get(liquidId).put(meta, d); BlockInterface block = new BlockInterface(); if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) { block.texture = Block.blocksList[liquidId].getBlockTextureFromSideAndMetadata(0, meta); } else { block.texture = Item.itemsList[liquidId].getIconFromDamage(meta); } float size = Utils.pipeMaxPos - Utils.pipeMinPos; // render size for (int s = 0; s < LIQUID_STAGES; ++s) { float ratio = (float) s / (float) LIQUID_STAGES; // SIDE HORIZONTAL d.sideHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */); block.minX = 0.0F; block.minZ = Utils.pipeMinPos + 0.01F; block.maxX = block.minX + size / 2F + 0.01F; block.maxZ = block.minZ + size - 0.02F; block.minY = Utils.pipeMinPos + 0.01F; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // SIDE VERTICAL d.sideVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */); block.minY = Utils.pipeMaxPos - 0.01; block.maxY = 1; block.minX = 0.5 - (size / 2 - 0.01) * ratio; block.maxX = 0.5 + (size / 2 - 0.01) * ratio; block.minZ = 0.5 - (size / 2 - 0.01) * ratio; block.maxZ = 0.5 + (size / 2 - 0.01) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER HORIZONTAL d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */); block.minX = Utils.pipeMinPos + 0.01; block.minZ = Utils.pipeMinPos + 0.01; block.maxX = block.minX + size - 0.02; block.maxZ = block.minZ + size - 0.02; block.minY = Utils.pipeMinPos + 0.01; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER VERTICAL d.centerVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */); block.minY = Utils.pipeMinPos + 0.01; block.maxY = Utils.pipeMaxPos - 0.01; block.minX = 0.5 - (size / 2 - 0.02) * ratio; block.maxX = 0.5 + (size / 2 - 0.02) * ratio; block.minZ = 0.5 - (size / 2 - 0.02) * ratio; block.maxZ = 0.5 + (size / 2 - 0.02) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }
From source file:buildcraft.transport.render.RenderPipe.java
License:Minecraft Mod Public
private void initializeDisplayPowerList(World world) { if (initialized) return;/*from ww w. j a v a2 s .c om*/ initialized = true; BlockInterface block = new BlockInterface(); block.texture = 4; float size = Utils.pipeMaxPos - Utils.pipeMinPos; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerList[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(displayPowerList[s], 4864 /* GL_COMPILE */); float minSize = 0.005F; float unit = (size - minSize) / 2F / POWER_STAGES; block.minY = 0.5 - (minSize / 2F) - unit * s; block.maxY = 0.5 + (minSize / 2F) + unit * s; block.minZ = 0.5 - (minSize / 2F) - unit * s; block.maxZ = 0.5 + (minSize / 2F) + unit * s; block.minX = 0; block.maxX = 0.5 + (minSize / 2F) + unit * s; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } block.texture = 6; size = Utils.pipeMaxPos - Utils.pipeMinPos; for (int s = 0; s < POWER_STAGES; ++s) { displayPowerListOverload[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(displayPowerListOverload[s], 4864 /* GL_COMPILE */); float minSize = 0.005F; float unit = (size - minSize) / 2F / POWER_STAGES; block.minY = 0.5 - (minSize / 2F) - unit * s; block.maxY = 0.5 + (minSize / 2F) + unit * s; block.minZ = 0.5 - (minSize / 2F) - unit * s; block.maxZ = 0.5 + (minSize / 2F) + unit * s; block.minX = 0; block.maxX = 0.5 + (minSize / 2F) + unit * s; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } }
From source file:buildcraft.transport.RenderPipe.java
License:Minecraft Mod Public
private DisplayLiquidList getDisplayLiquidLists(int liquidId, int meta, World world) { if (displayLiquidLists.containsKey(liquidId)) { HashMap<Integer, DisplayLiquidList> x = displayLiquidLists.get(liquidId); if (x.containsKey(meta)) { return x.get(meta); }//from ww w .j a va 2 s . c om } else { displayLiquidLists.put(liquidId, new HashMap<Integer, DisplayLiquidList>()); } DisplayLiquidList d = new DisplayLiquidList(); displayLiquidLists.get(liquidId).put(meta, d); BlockInterface block = new BlockInterface(); if (liquidId < Block.blocksList.length && Block.blocksList[liquidId] != null) block.texture = Block.blocksList[liquidId].blockIndexInTexture; else block.texture = Item.itemsList[liquidId].getIconFromDamage(meta); float size = Utils.pipeMaxPos - Utils.pipeMinPos; // render size for (int s = 0; s < displayLiquidStages; ++s) { float ratio = (float) s / (float) displayLiquidStages; // SIDE HORIZONTAL d.sideHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideHorizontal[s], 4864 /* GL_COMPILE */); block.minX = 0.0F; block.minZ = Utils.pipeMinPos + 0.01F; block.maxX = block.minX + size / 2F + 0.01F; block.maxZ = block.minZ + size - 0.02F; block.minY = Utils.pipeMinPos + 0.01F; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // SIDE VERTICAL d.sideVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.sideVertical[s], 4864 /* GL_COMPILE */); block.minY = Utils.pipeMaxPos - 0.01; block.maxY = 1; block.minX = 0.5 - (size / 2 - 0.01) * ratio; block.maxX = 0.5 + (size / 2 - 0.01) * ratio; block.minZ = 0.5 - (size / 2 - 0.01) * ratio; block.maxZ = 0.5 + (size / 2 - 0.01) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER HORIZONTAL d.centerHorizontal[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerHorizontal[s], 4864 /* GL_COMPILE */); block.minX = Utils.pipeMinPos + 0.01; block.minZ = Utils.pipeMinPos + 0.01; block.maxX = block.minX + size - 0.02; block.maxZ = block.minZ + size - 0.02; block.minY = Utils.pipeMinPos + 0.01; block.maxY = block.minY + (size - 0.02F) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); // CENTER VERTICAL d.centerVertical[s] = GLAllocation.generateDisplayLists(1); GL11.glNewList(d.centerVertical[s], 4864 /* GL_COMPILE */); block.minY = Utils.pipeMinPos + 0.01; block.maxY = Utils.pipeMaxPos - 0.01; block.minX = 0.5 - (size / 2 - 0.02) * ratio; block.maxX = 0.5 + (size / 2 - 0.02) * ratio; block.minZ = 0.5 - (size / 2 - 0.02) * ratio; block.maxZ = 0.5 + (size / 2 - 0.02) * ratio; RenderEntityBlock.renderBlock(block, world, 0, 0, 0, false, true); GL11.glEndList(); } return d; }