List of usage examples for org.lwjgl.opengl GL11 glDepthMask
public static void glDepthMask(@NativeType("GLboolean") boolean flag)
From source file:me.ukl.api.gui.renderer.GuiRendererDepth.java
License:MIT License
@Override public void setClip(int x, int y, int width, int height) { super.setClip(x, y, width, height); GL11.glDepthMask(true); //Write to depth clearClip();// www . j a v a 2 s . c o m GL11.glDepthFunc(GL11.GL_ALWAYS); GL11.glColorMask(false, false, false, false); RenderUtil.drawRect(x, y, width, height, Color.WHITE); GL11.glDepthMask(false);//No more writing to depth GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glColorMask(true, true, true, true); // addClip(x, y, width, height); }
From source file:micdoodle8.mods.galacticraft.planets.mars.client.SkyProviderMars.java
License:LGPL
@Override public void render(float partialTicks, WorldClient world, Minecraft mc) { GL11.glDisable(GL11.GL_TEXTURE_2D);//from w w w. ja va 2s . c om Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks); float f1 = (float) vec3.xCoord; float f2 = (float) vec3.yCoord; float f3 = (float) vec3.zCoord; float f6; if (mc.gameSettings.anaglyph) { float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; f1 = f4; f2 = f5; f3 = f6; } GL11.glColor3f(f1, f2, f3); Tessellator tessellator1 = Tessellator.instance; GL11.glDepthMask(false); GL11.glEnable(GL11.GL_FOG); GL11.glColor3f(f1, f2, f3); GL11.glCallList(this.glSkyList); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); RenderHelper.disableStandardItemLighting(); float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks); float f7; float f8; float f9; float f10; float f18 = world.getStarBrightness(partialTicks); if (f18 > 0.0F) { GL11.glColor4f(f18, f18, f18, f18); GL11.glCallList(this.starList); } afloat = new float[4]; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); afloat[0] = 255 / 255.0F; afloat[1] = 194 / 255.0F; afloat[2] = 180 / 255.0F; afloat[3] = 0.3F; f6 = afloat[0]; f7 = afloat[1]; f8 = afloat[2]; float f11; if (mc.gameSettings.anaglyph) { f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F; f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F; f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F; f6 = f9; f7 = f10; f8 = f11; } tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN); tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3] * 2); tessellator1.addVertex(0.0D, 100.0D, 0.0D); byte b0 = 16; tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); // Render sun aura f10 = 20.0F; tessellator1.addVertex(-f10, 100.0D, -f10); tessellator1.addVertex(0, 100.0D, (double) -f10 * 1.5F); tessellator1.addVertex(f10, 100.0D, -f10); tessellator1.addVertex((double) f10 * 1.5F, 100.0D, 0); tessellator1.addVertex(f10, 100.0D, f10); tessellator1.addVertex(0, 100.0D, (double) f10 * 1.5F); tessellator1.addVertex(-f10, 100.0D, f10); tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, 0); tessellator1.addVertex(-f10, 100.0D, -f10); tessellator1.draw(); tessellator1.startDrawing(GL11.GL_TRIANGLE_FAN); tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]); tessellator1.addVertex(0.0D, 100.0D, 0.0D); tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); // Render larger sun aura f10 = 40.0F; tessellator1.addVertex(-f10, 100.0D, -f10); tessellator1.addVertex(0, 100.0D, (double) -f10 * 1.5F); tessellator1.addVertex(f10, 100.0D, -f10); tessellator1.addVertex((double) f10 * 1.5F, 100.0D, 0); tessellator1.addVertex(f10, 100.0D, f10); tessellator1.addVertex(0, 100.0D, (double) f10 * 1.5F); tessellator1.addVertex(-f10, 100.0D, f10); tessellator1.addVertex((double) -f10 * 1.5F, 100.0D, 0); tessellator1.addVertex(-f10, 100.0D, -f10); tessellator1.draw(); GL11.glPopMatrix(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_TEXTURE_2D); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO); GL11.glPushMatrix(); f7 = 0.0F; f8 = 0.0F; f9 = 0.0F; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef(f7, f8, f9); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); // Render sun f10 = 14.0F; mc.renderEngine.bindTexture(SkyProviderMars.sunTexture); tessellator1.startDrawingQuads(); tessellator1.addVertexWithUV(-f10, 100.0D, -f10, 0.0D, 0.0D); tessellator1.addVertexWithUV(f10, 100.0D, -f10, 1.0D, 0.0D); tessellator1.addVertexWithUV(f10, 100.0D, f10, 1.0D, 1.0D); tessellator1.addVertexWithUV(-f10, 100.0D, f10, 0.0D, 1.0D); tessellator1.draw(); // Render earth f10 = 0.5F; GL11.glScalef(0.6F, 0.6F, 0.6F); GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(SkyProviderMars.overworldTexture); tessellator1.startDrawingQuads(); tessellator1.addVertexWithUV(-f10, -100.0D, f10, 0, 1); tessellator1.addVertexWithUV(f10, -100.0D, f10, 1, 1); tessellator1.addVertexWithUV(f10, -100.0D, -f10, 1, 0); tessellator1.addVertexWithUV(-f10, -100.0D, -f10, 0, 0); tessellator1.draw(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_FOG); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0.0F, 0.0F, 0.0F); double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon(); if (d0 < 0.0D) { GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 12.0F, 0.0F); GL11.glCallList(this.glSkyList2); GL11.glPopMatrix(); f8 = 1.0F; f9 = -((float) (d0 + 65.0D)); f10 = -f8; tessellator1.startDrawingQuads(); tessellator1.setColorRGBA_I(0, 255); tessellator1.addVertex(-f8, f9, f8); tessellator1.addVertex(f8, f9, f8); tessellator1.addVertex(f8, f10, f8); tessellator1.addVertex(-f8, f10, f8); tessellator1.addVertex(-f8, f10, -f8); tessellator1.addVertex(f8, f10, -f8); tessellator1.addVertex(f8, f9, -f8); tessellator1.addVertex(-f8, f9, -f8); tessellator1.addVertex(f8, f10, -f8); tessellator1.addVertex(f8, f10, f8); tessellator1.addVertex(f8, f9, f8); tessellator1.addVertex(f8, f9, -f8); tessellator1.addVertex(-f8, f9, -f8); tessellator1.addVertex(-f8, f9, f8); tessellator1.addVertex(-f8, f10, f8); tessellator1.addVertex(-f8, f10, -f8); tessellator1.addVertex(-f8, f10, -f8); tessellator1.addVertex(-f8, f10, f8); tessellator1.addVertex(f8, f10, f8); tessellator1.addVertex(f8, f10, -f8); tessellator1.draw(); } if (world.provider.isSkyColored()) { GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F); } else { GL11.glColor3f(f1, f2, f3); } GL11.glPushMatrix(); GL11.glTranslatef(0.0F, -((float) (d0 - 16.0D)), 0.0F); GL11.glCallList(this.glSkyList2); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); }
From source file:minecraft.phoenix.cityscape.space.util.SkyRendererUtil.java
License:LGPL
@Override @SideOnly(Side.CLIENT)/*from w ww .j a v a 2 s. c o m*/ public void render(float partialTicks, WorldClient world, Minecraft mc) { if (!once) { this.starGLCallList = GLAllocation.generateDisplayLists(3); GL11.glPushMatrix(); GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE); SkyRendererUtil.renderStars().draw(); GL11.glEndList(); GL11.glPopMatrix(); Tessellator var5 = Tessellator.instance; this.glSkyList = this.starGLCallList + 1; GL11.glNewList(this.glSkyList, GL11.GL_COMPILE); byte var7 = 64; int var8 = 256 / var7 + 2; float var6 = 16.0F; int var9; int var10; for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7) { for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7) { var5.startDrawingQuads(); var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + 0)); var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + 0)); var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + var7)); var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + var7)); var5.draw(); } } GL11.glEndList(); this.glSkyList2 = this.starGLCallList + 2; GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE); var6 = -16.0F; var5.startDrawingQuads(); for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7) { for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7) { var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + 0)); var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + 0)); var5.addVertex((double) (var9 + 0), (double) var6, (double) (var10 + var7)); var5.addVertex((double) (var9 + var7), (double) var6, (double) (var10 + var7)); } } var5.draw(); GL11.glEndList(); } GL11.glDisable(GL11.GL_TEXTURE_2D); float var3 = 0.0F; float var4 = 0.0F; float var5 = 0.0F; GL11.glColor3f(var3, var4, var5); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_FOG); GL11.glColor3f(var3, var4, var5); GL11.glCallList(this.glSkyList); GL11.glDisable(GL11.GL_FOG); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.disableStandardItemLighting(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glPushMatrix(); float var9 = 0.0F; float var10 = 0.0F; float var11 = 0.0F; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef(var9, var10, var11); GL11.glDisable(GL11.GL_TEXTURE_2D); float var20 = world.getStarBrightness(partialTicks); GL11.glColor4f(var20, var20, var20, var20); GL11.glCallList(this.starGLCallList); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_FOG); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(0.0F, 0.0F, 0.0F); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 100.0F, 0.0F); GL11.glCallList(this.glSkyList2); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); }
From source file:minesweeperMod.client.FieldStatHandler.java
License:LGPL
@SubscribeEvent public void tickEnd(TickEvent.RenderTickEvent event) { if (MinesweeperMod.instance.configStatEnabled) { Minecraft minecraft = FMLClientHandler.instance().getClient(); EntityPlayer player = minecraft.thePlayer; if (player != null) { World world = minecraft.theWorld; boolean shouldUpdate = false; if (!isTriggeredThisTick && player.ticksExisted % 20 == 0) { isTriggeredThisTick = true; shouldUpdate = true;/*from w w w . j a v a 2 s. c o m*/ } else if (player.ticksExisted % 20 != 0) { isTriggeredThisTick = false; } ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPushMatrix(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glColor4d(0, 1, 0, 0.8D); if (minesweeperStat == null) { minesweeperStat = new GuiAnimatedStat("Minefield Statistics:", sr.getScaledWidth() - 2, 2, 0x3000AA00, null, true); minesweeperStat.setMinDimensionsAndReset(0, 0); } List<String> textList = new ArrayList<String>(); if (world.getBlock(x, y, z) == MinesweeperMod.blockMinesweeper) { minesweeperStat.openWindow(); if (shouldUpdate || forceUpdate) { List<int[]> tiles = new ArrayList<int[]>(); ((BlockMinesweeper) MinesweeperMod.blockMinesweeper).getAccessoryTiles(tiles, world, x, y, z); flagCount = 0; bombCount = 0; int hardcoreBombCount = 0; for (int[] tile : tiles) { if (MinesweeperUtils.isTileBomb(world.getBlockMetadata(tile[0], tile[1], tile[2]))) bombCount++; if (MinesweeperUtils.isTileFlagged(world.getBlockMetadata(tile[0], tile[1], tile[2]))) flagCount++; if (MinesweeperUtils .isTileHardcoreBomb(world.getBlockMetadata(tile[0], tile[1], tile[2]))) hardcoreBombCount++; } tileBombRatio = (double) bombCount / (double) tiles.size(); hardcoreBombPercentage = (double) hardcoreBombCount / (double) bombCount; statHoldTimer--; if (forceUpdate) statHoldTimer = MinesweeperMod.instance.configStatDuration; forceUpdate = false; if (statHoldTimer <= 0) { x = 0; y = 0; z = 0; } } textList.add(" Mines: " + bombCount); textList.add("Flagged: " + flagCount); textList.add(" -- -"); textList.add(" Left: " + (bombCount - flagCount)); if (tileBombRatio > 1D / 6D && hardcoreBombPercentage > 0.5D) { textList.add("Difficulty: Hardcore"); } else if (tileBombRatio > 1D / 6D) { textList.add("Difficulty: Hard"); } else if (tileBombRatio > 1D / 8D) { textList.add("Difficulty: Medium"); } else { textList.add("Difficulty: Easy"); } } else { minesweeperStat.closeWindow(); } int xPos = 0; int yPos = 1; switch (MinesweeperMod.instance.configStatXPos) { case 0: xPos = 2; minesweeperStat.leftSided = false; break; case 1: xPos = sr.getScaledWidth() / 2 - 55; minesweeperStat.leftSided = false; break; case 2: xPos = sr.getScaledWidth() - 2; minesweeperStat.leftSided = true; break; } switch (MinesweeperMod.instance.configStatYPos) { case 0: yPos = 2; break; case 1: yPos = sr.getScaledHeight() / 2 - 40; break; case 2: yPos = sr.getScaledHeight() - 68; break; } minesweeperStat.updateResolution(xPos, yPos); minesweeperStat.render(minecraft.fontRenderer, textList, 0); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_TEXTURE_2D); } } }
From source file:minesweeperMod.client.MinesweeperDrawBlockHighlightHandler.java
License:LGPL
public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks, int tile) { x += 0.5D;// w w w.j av a2 s . c o m y += 0.5D; z += 0.5D; double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; float xScale = 1.0F; float yScale = 1; float zScale = 1.0F; float xShift = 0.0F; float yShift = 0.01F; float zShift = 0.0F; GL11.glDepthMask(false); GL11.glDisable(GL11.GL_CULL_FACE); for (int i = 4; i < 5; i++) { ForgeDirection forgeDir = ForgeDirection.getOrientation(i); int zCorrection = i == 2 ? -1 : 1; GL11.glPushMatrix(); GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift); GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale); GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ); GL11.glTranslated(0, 0, 0.5f * zCorrection); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); drawQuad(-0.5F, -0.5F, 1F, 1F, 0F, tile); GL11.glPopMatrix(); } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); }
From source file:mods.mffs.client.renderer.TECapacitorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityCapacitor) { TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity; GL11.glPushMatrix();//from ww w . j av a 2 s.c om GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Capacitor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("capacity: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getPercentageStorageCapacity()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth( String.valueOf(topview.getPercentageStorageCapacity()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("range: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getTransmitRange()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("linked device: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:mods.mffs.client.renderer.TEExtractorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityExtractor) { TileEntityExtractor topview = (TileEntityExtractor) tileEntity; GL11.glPushMatrix();/* w w w . j a v a2s . com*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Extractor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("WC left:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkCylce()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat("%"), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat("%")), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:mods.railcraft.client.render.RenderTools.java
License:Open Source License
public static void renderString(String name, double xOffset, double yOffset, double zOffset) { RenderManager rm = RenderManager.instance; FontRenderer fontrenderer = rm.getFontRenderer(); float f = 1.6F; float f1 = 1 / 60F * f; GL11.glPushMatrix();//from w w w .j a v a 2s. c o m GL11.glTranslatef((float) xOffset, (float) yOffset, (float) zOffset); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-rm.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(rm.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int j = fontrenderer.getStringWidth(name) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex((double) (-j - 1), (double) -1, 0.0D); tessellator.addVertex((double) (-j - 1), (double) 8, 0.0D); tessellator.addVertex((double) (j + 1), (double) 8, 0.0D); tessellator.addVertex((double) (j + 1), (double) -1, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, 0, 553648127); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, 0, -1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); }
From source file:mwisbest.openbase.gui.Button.java
License:Open Source License
@Override public void render() { GL11.glPushMatrix();/*from www . ja v a2s . c o m*/ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(false); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (Common.currentTextureID != this.texture.getTextureID()) { int texID = this.texture.getTextureID(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); Common.currentTextureID = texID; } GL11.glTranslatef(this.x, this.y, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0, this.texture.getHeight()); GL11.glVertex2f(0, this.height); GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight()); GL11.glVertex2f(this.width, this.height); GL11.glTexCoord2f(this.texture.getWidth(), 0); GL11.glVertex2f(this.width, 0); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:mwisbest.openbase.opengl.UtilsGL.java
License:Open Source License
/** * Draws the specified texture to positions x and y on the screen and scaled with the specified width and height * //from w ww .j a va2s . co m * @param texture * @param x * @param y * @param width * @param height */ public static void drawTexture(Texture texture, int x, int y, int width, int height) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(false); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (Common.currentTextureID != texture.getTextureID()) { int texID = texture.getTextureID(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); Common.currentTextureID = texID; } GL11.glTranslatef(x, y, 0); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0, texture.getHeight()); GL11.glVertex2f(0, height); GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); GL11.glVertex2f(width, height); GL11.glTexCoord2f(texture.getWidth(), 0); GL11.glVertex2f(width, 0); GL11.glEnd(); GL11.glPopMatrix(); }