List of usage examples for org.lwjgl.opengl GL11 GL_FLAT
int GL_FLAT
To view the source code for org.lwjgl.opengl GL11 GL_FLAT.
Click Source Link
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 *//* ww w .j av a 2 s . co 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:appeng.client.render.BaseBlockRender.java
License:Open Source License
public void renderTile(final B block, final T tile, final Tessellator tess, final double x, final double y, final double z, final float f, final RenderBlocks renderer) { renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0; final ForgeDirection up = ForgeDirection.UP; final ForgeDirection forward = ForgeDirection.SOUTH; this.applyTESRRotation(x, y, z, forward, up); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); RenderHelper.disableStandardItemLighting(); if (Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else {//from ww w .j av a 2 s . com GL11.glShadeModel(GL11.GL_FLAT); } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); tess.setTranslation(-tile.xCoord, -tile.yCoord, -tile.zCoord); tess.startDrawingQuads(); // note that this is a terrible approach... renderer.setRenderBoundsFromBlock(block); renderer.renderStandardBlock(block, tile.xCoord, tile.yCoord, tile.zCoord); tess.draw(); tess.setTranslation(0, 0, 0); RenderHelper.enableStandardItemLighting(); renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0; }
From source file:appeng.client.render.blocks.RenderBlockCrank.java
License:Open Source License
@Override public void renderTile(final BlockCrank blk, final TileCrank tile, final Tessellator tess, final double x, final double y, final double z, final float f, final RenderBlocks renderBlocks) { if (tile.getUp() == null || tile.getUp() == ForgeDirection.UNKNOWN) { return;/*w w w . j a va2s . c om*/ } Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); RenderHelper.disableStandardItemLighting(); if (Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp()); GL11.glTranslated(0.5, 0, 0.5); GL11.glRotatef(tile.getVisibleRotation(), 0, 1, 0); GL11.glTranslated(-0.5, 0, -0.5); tess.setTranslation(-tile.xCoord, -tile.yCoord, -tile.zCoord); tess.startDrawingQuads(); renderBlocks.renderAllFaces = true; renderBlocks.blockAccess = tile.getWorldObj(); renderBlocks.setRenderBounds(0.5D - 0.05, 0.5D - 0.5, 0.5D - 0.05, 0.5D + 0.05, 0.5D + 0.1, 0.5D + 0.05); renderBlocks.renderStandardBlock(blk, tile.xCoord, tile.yCoord, tile.zCoord); renderBlocks.setRenderBounds(0.70D - 0.15, 0.55D - 0.05, 0.5D - 0.05, 0.70D + 0.15, 0.55D + 0.05, 0.5D + 0.05); renderBlocks.renderStandardBlock(blk, tile.xCoord, tile.yCoord, tile.zCoord); tess.draw(); tess.setTranslation(0, 0, 0); RenderHelper.enableStandardItemLighting(); }
From source file:appeng.client.render.tesr.CrankTESR.java
License:Open Source License
@Override public void renderTileEntityAt(TileCrank te, double x, double y, double z, float partialTicks, int destroyStage) { // Most of this is blatantly copied from FastTESR Tessellator tessellator = Tessellator.getInstance(); this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend();/*w w w.j a va 2 s. c o m*/ GlStateManager.disableCull(); if (Minecraft.isAmbientOcclusionEnabled()) { GlStateManager.shadeModel(GL11.GL_SMOOTH); } else { GlStateManager.shadeModel(GL11.GL_FLAT); } IBlockState blockState = te.getWorld().getBlockState(te.getPos()); BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); IBakedModel model = dispatcher.getModelForState(blockState); VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); // The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos // This makes the translations that follow much easier buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ()); dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), model, blockState, te.getPos(), buffer, false); buffer.setTranslation(0, 0, 0); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); // Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation GlStateManager.translate(0.5, 0.5, 0.5); FacingToRotation.get(te.getForward(), te.getUp()).glRotateCurrentMat(); GlStateManager.rotate(te.getVisibleRotation(), 0, 1, 0); GlStateManager.translate(-0.5, -0.5, -0.5); tessellator.draw(); GlStateManager.popMatrix(); RenderHelper.enableStandardItemLighting(); }
From source file:blusunrize.immersiveengineering.api.ManualPageMultiblock.java
@Override public void renderPage(GuiManual gui, int x, int y, int mx, int my) { boolean openBuffer = false; int stackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); try {//from w w w. java2s.c om if (multiblock.getStructureManual() != null) { if (!canTick) { // renderInfo.reset(); // renderInfo.setShowLayer(9); //LAYER CACHING!! } else if (++tick % 20 == 0) renderInfo.step(); int structureLength = renderInfo.structureLength; int structureWidth = renderInfo.structureWidth; int structureHeight = renderInfo.structureHeight; int yOffTotal = (int) (transY - y + scale * Math.sqrt(renderInfo.structureHeight * renderInfo.structureHeight + renderInfo.structureWidth * renderInfo.structureWidth + renderInfo.structureLength * renderInfo.structureLength) / 2); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); RenderHelper.disableStandardItemLighting(); // GL11.glEnable(GL11.GL_DEPTH_TEST); // GL11.glDepthFunc(GL11.GL_ALWAYS); // GL11.glDisable(GL11.GL_CULL_FACE); int i = 0; ItemStack highlighted = ItemStack.EMPTY; final BlockRendererDispatcher blockRender = Minecraft.getMinecraft().getBlockRendererDispatcher(); float f = (float) Math.sqrt(structureHeight * structureHeight + structureWidth * structureWidth + structureLength * structureLength); GlStateManager.translate(transX, transY, Math.max(structureHeight, Math.max(structureWidth, structureLength))); GlStateManager.scale(scale, -scale, 1); GlStateManager.rotate(rotX, 1, 0, 0); GlStateManager.rotate(90 + rotY, 0, 1, 0); GlStateManager.translate((float) structureLength / -2f, (float) structureHeight / -2f, (float) structureWidth / -2f); GlStateManager.disableLighting(); if (Minecraft.isAmbientOcclusionEnabled()) GlStateManager.shadeModel(GL11.GL_SMOOTH); else GlStateManager.shadeModel(GL11.GL_FLAT); gui.mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); int idx = 0; if (showCompleted && multiblock.canRenderFormedStructure()) multiblock.renderFormedStructure(); else for (int h = 0; h < structureHeight; h++) for (int l = 0; l < structureLength; l++) for (int w = 0; w < structureWidth; w++) { BlockPos pos = new BlockPos(l, h, w); if (!blockAccess.isAirBlock(pos)) { GlStateManager.translate(l, h, w); boolean b = multiblock.overwriteBlockRender(renderInfo.data[h][l][w], idx++); GlStateManager.translate(-l, -h, -w); if (!b) { IBlockState state = blockAccess.getBlockState(pos); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); openBuffer = true; blockRender.renderBlock(state, pos, blockAccess, buffer); tessellator.draw(); openBuffer = false; } } } GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.enableBlend(); RenderHelper.disableStandardItemLighting(); manual.fontRenderer.setUnicodeFlag(true); if (localizedText != null && !localizedText.isEmpty()) manual.fontRenderer.drawSplitString(localizedText, x, y + yOffTotal, 120, manual.getTextColour()); manual.fontRenderer.setUnicodeFlag(false); if (componentTooltip != null) { manual.fontRenderer.drawString("?", x + 116, y + yOffTotal / 2 - 4, manual.getTextColour(), false); if (mx >= x + 116 && mx < x + 122 && my >= y + yOffTotal / 2 - 4 && my < y + yOffTotal / 2 + 4) gui.drawHoveringText(componentTooltip, mx, my, manual.fontRenderer); } } } catch (Exception e) { e.printStackTrace(); } if (openBuffer) try { Tessellator.getInstance().draw(); } catch (Exception e) { } int newStackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); while (newStackDepth > stackDepth) { GlStateManager.popMatrix(); newStackDepth--; } }
From source file:blusunrize.immersiveengineering.client.ClientEventHandler.java
@SubscribeEvent public void onRenderWorldLastEvent(RenderWorldLastEvent event) { //Overlay renderer for the sample drill boolean chunkBorders = false; if (sampleDrill.isEmpty()) sampleDrill = new ItemStack(IEContent.blockMetalDevice1, 1, BlockTypes_MetalDevice1.SAMPLE_DRILL.getMeta()); for (EnumHand hand : EnumHand.values()) if (OreDictionary.itemMatches(sampleDrill, ClientUtils.mc().player.getHeldItem(hand), true)) { chunkBorders = true;//ww w . j a v a2 s . c o m break; } if (!chunkBorders && ClientUtils.mc().objectMouseOver != null && ClientUtils.mc().objectMouseOver.typeOfHit == Type.BLOCK && ClientUtils.mc().world.getTileEntity( ClientUtils.mc().objectMouseOver.getBlockPos()) instanceof TileEntitySampleDrill) chunkBorders = true; float partial = event.getPartialTicks(); if (!ParticleFractal.PARTICLE_FRACTAL_DEQUE.isEmpty()) { double px = TileEntityRendererDispatcher.staticPlayerX; double py = TileEntityRendererDispatcher.staticPlayerY; double pz = TileEntityRendererDispatcher.staticPlayerZ; Tessellator tessellator = Tessellator.getInstance(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableCull(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); tessellator.getBuffer().setTranslation(-px, -py, -pz); ParticleFractal part; while ((part = ParticleFractal.PARTICLE_FRACTAL_DEQUE.pollFirst()) != null) part.render(tessellator, tessellator.getBuffer(), partial); tessellator.getBuffer().setTranslation(0, 0, 0); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } if (chunkBorders) { EntityPlayer player = ClientUtils.mc().player; double px = TileEntityRendererDispatcher.staticPlayerX; double py = TileEntityRendererDispatcher.staticPlayerY; double pz = TileEntityRendererDispatcher.staticPlayerZ; int chunkX = (int) player.posX >> 4 << 4; int chunkZ = (int) player.posZ >> 4 << 4; int y = Math.min((int) player.posY - 2, player.getEntityWorld().getChunk(new BlockPos(player.posX, 0, player.posZ)).getLowestHeight()); float h = (float) Math.max(32, player.posY - y + 4); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableCull(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); float r = Lib.COLOUR_F_ImmersiveOrange[0]; float g = Lib.COLOUR_F_ImmersiveOrange[1]; float b = Lib.COLOUR_F_ImmersiveOrange[2]; BufferBuilder.setTranslation(chunkX - px, y + 2 - py, chunkZ - pz); GlStateManager.glLineWidth(5f); BufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); BufferBuilder.pos(0, 0, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, h, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 0, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, h, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 0, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, h, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 0, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, h, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(0, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 16).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 0).color(r, g, b, .375f).endVertex(); BufferBuilder.pos(16, 2, 16).color(r, g, b, .375f).endVertex(); tessellator.draw(); BufferBuilder.setTranslation(0, 0, 0); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableCull(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } if (!FAILED_CONNECTIONS.isEmpty()) { Entity viewer = ClientUtils.mc().getRenderViewEntity(); if (viewer == null) viewer = ClientUtils.mc().player; double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial; double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial; double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial; Tessellator tes = Tessellator.getInstance(); BufferBuilder bb = tes.getBuffer(); float oldLineWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH); GlStateManager.glLineWidth(5); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); for (Entry<Connection, Pair<BlockPos, AtomicInteger>> entry : FAILED_CONNECTIONS.entrySet()) { Connection conn = entry.getKey(); bb.setTranslation(conn.start.getX() - dx, conn.start.getY() - dy, conn.start.getZ() - dz); Vec3d[] points = conn.getSubVertices(ClientUtils.mc().world); int time = entry.getValue().getValue().get(); float alpha = (float) Math.min((2 + Math.sin(time * Math.PI / 40)) / 3, time / 20F); for (int i = 0; i < points.length - 1; i++) { bb.pos(points[i].x, points[i].y, points[i].z).color(1, 0, 0, alpha).endVertex(); alpha = (float) Math.min((2 + Math.sin((time + (i + 1) * 8) * Math.PI / 40)) / 3, time / 20F); bb.pos(points[i + 1].x, points[i + 1].y, points[i + 1].z).color(1, 0, 0, alpha).endVertex(); } } bb.setTranslation(0, 0, 0); tes.draw(); GlStateManager.glLineWidth(oldLineWidth); GlStateManager.enableBlend(); GlStateManager.color(1, 0, 0, .5F); renderObstructingBlocks(bb, tes, dx, dy, dz); //Code to render the obstructing block through other blocks //GlStateManager.color(1, 0, 0, .25F); //GlStateManager.depthFunc(GL11.GL_GREATER); //renderObstructingBlocks(bb, tes, dx, dy, dz); //GlStateManager.depthFunc(GL11.GL_LEQUAL); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } }
From source file:blusunrize.immersiveengineering.client.ClientUtils.java
public static void drawColouredRect(int x, int y, int w, int h, int colour) { GlStateManager.disableTexture2D();//from ww w .jav a 2 s . c o m GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(x, y + h, 0) .color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); worldrenderer.pos(x + w, y + h, 0) .color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); worldrenderer.pos(x + w, y, 0) .color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255).endVertex(); worldrenderer.pos(x, y, 0).color(colour >> 16 & 255, colour >> 8 & 255, colour & 255, colour >> 24 & 255) .endVertex(); tessellator.draw(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); }
From source file:blusunrize.immersiveengineering.client.ClientUtils.java
public static void drawGradientRect(int x0, int y0, int x1, int y1, int colour0, int colour1) { float f = (float) (colour0 >> 24 & 255) / 255.0F; float f1 = (float) (colour0 >> 16 & 255) / 255.0F; float f2 = (float) (colour0 >> 8 & 255) / 255.0F; float f3 = (float) (colour0 & 255) / 255.0F; float f4 = (float) (colour1 >> 24 & 255) / 255.0F; float f5 = (float) (colour1 >> 16 & 255) / 255.0F; float f6 = (float) (colour1 >> 8 & 255) / 255.0F; float f7 = (float) (colour1 & 255) / 255.0F; GlStateManager.disableTexture2D();/*from w w w . j a v a2 s . c o m*/ GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(x1, y0, 0).color(f1, f2, f3, f).endVertex(); worldrenderer.pos(x0, y0, 0).color(f1, f2, f3, f).endVertex(); worldrenderer.pos(x0, y1, 0).color(f5, f6, f7, f4).endVertex(); worldrenderer.pos(x1, y1, 0).color(f5, f6, f7, f4).endVertex(); tessellator.draw(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); }
From source file:blusunrize.immersiveengineering.client.render.TileRenderSheetmetalTank.java
@Override public void render(TileEntitySheetmetalTank tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (!tile.formed || tile.pos != 4 || !tile.getWorld().isBlockLoaded(tile.getPos(), false)) return;// ww w . j a v a 2 s. com GlStateManager.pushMatrix(); GlStateManager.translate(x + .5, y, z + .5); FluidStack fs = tile.tank.getFluid(); GlStateManager.translate(0, 3.5f, 0); float baseScale = .0625f; GlStateManager.scale(baseScale, -baseScale, baseScale); float xx = -.5f; float zz = 1.5f - .004f; xx /= baseScale; zz /= baseScale; for (int i = 0; i < 4; i++) { GlStateManager.translate(xx, 0, zz); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.disableLighting(); BufferBuilder worldrenderer = ClientUtils.tes().getBuffer(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(-4, -4, 0).color(0x22, 0x22, 0x22, 0xff).endVertex(); worldrenderer.pos(-4, 20, 0).color(0x22, 0x22, 0x22, 0xff).endVertex(); worldrenderer.pos(20, 20, 0).color(0x22, 0x22, 0x22, 0xff).endVertex(); worldrenderer.pos(20, -4, 0).color(0x22, 0x22, 0x22, 0xff).endVertex(); ClientUtils.tes().draw(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); if (fs != null) { float h = fs.amount / (float) tile.tank.getCapacity(); GlStateManager.depthMask(false); GlStateManager.translate(0, 0, .004f); ClientUtils.drawRepeatedFluidSprite(fs, 0, 0 + (1 - h) * 16, 16, h * 16); GlStateManager.translate(0, 0, -.004f); GlStateManager.depthMask(true); } GlStateManager.translate(-xx, 0, -zz); GlStateManager.rotate(90, 0, 1, 0); GlStateManager.enableAlpha(); GlStateManager.alphaFunc(516, 0.1F); GlStateManager.enableBlend(); OpenGlHelper.glBlendFunc(770, 771, 1, 0); } GlStateManager.popMatrix(); }
From source file:cn.academy.core.client.render.block.RenderDynamicBlock.java
License:GNU General Public License
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float pt) { Block blockType = t.getBlockType();// w w w . j a va 2 s. c om Tessellator tes = Tessellator.instance; tes.setColorOpaque_F(1.0F, 1.0F, 1.0F); renderBlocks.blockAccess = t.getWorldObj(); { if (Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } RenderHelper.disableStandardItemLighting(); RenderUtils.loadTexture(TextureMap.locationBlocksTexture); tes.startDrawingQuads(); tes.setTranslation(x - t.xCoord, y - t.yCoord, z - t.zCoord); renderBlocks.renderBlockAllFaces(blockType, t.xCoord, t.yCoord, t.zCoord); tes.setTranslation(0, 0, 0); tes.draw(); RenderHelper.enableStandardItemLighting(); } }