List of usage examples for org.lwjgl.opengl GL11 glColor4f
public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);
From source file:allout58.mods.techtree.util.RenderingHelper.java
License:Open Source License
public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, int color, int borderColor) throws IllegalArgumentException { if (radius * 2 > Math.abs(width)) throw new IllegalArgumentException("Error! Width not large enough for radius!"); if (radius * 2 > Math.abs(height)) throw new IllegalArgumentException("Error! Height not large enough for radius!"); if (width < 0) { x += width;// w w w .j av a 2 s.c o m width = Math.abs(width); } if (height < 0) { y += height; height = Math.abs(height); } int x1Inner = x + radius; int y1Inner = y + radius; int x2Inner = x + width - radius; int y2Inner = y + height - radius; float red = (float) (borderColor >> 16 & 255) / 255.0F; float green = (float) (borderColor >> 8 & 255) / 255.0F; float blue = (float) (borderColor & 255) / 255.0F; float alpha = (float) (borderColor >> 24 & 255) / 255.0F; Gui.drawRect(x, y1Inner, x1Inner, y2Inner, borderColor); Gui.drawRect(x1Inner, y, x2Inner, y1Inner, borderColor); Gui.drawRect(x2Inner, y1Inner, x + width, y2Inner, borderColor); Gui.drawRect(x1Inner, y2Inner, x2Inner, y + height, borderColor); Gui.drawRect(x1Inner, y1Inner, x2Inner, y2Inner, color); ArrayList<Point> curves = new ArrayList<Point>(); final double[][] start = new double[][] { { x1Inner, y1Inner }, { x2Inner, y1Inner }, { x2Inner, y2Inner }, { x1Inner, y2Inner } }; for (int corner = 0; corner < 4; corner++) { curves.clear(); for (int i = 0; i < VERTEX_PER_CURVE + 1; i++) { double theta = deltaTheta * i + dT[corner]; Point p = new Point(Math.cos(theta), Math.sin(theta)); curves.add(p); } GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glPushMatrix(); GL11.glColor4f(red, green, blue, alpha); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glVertex3d(start[corner][0], start[corner][1], 0); for (int i = curves.size() - 1; i >= 0; i--) { GL11.glVertex3d((curves.get(i).getX()) * radius + start[corner][0], (curves.get(i).getY()) * radius + start[corner][1], 0); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); } }
From source file:aphelion.client.graphics.world.Projectile.java
License:Open Source License
@Override public boolean render(@Nonnull Camera camera, int iteration) { if (!isExists()) { return false; }/* ww w .j a va 2s.c o m*/ if (iteration > 1) { return false; } updateAnimObjects(); Point screenPos = new Point(); camera.mapToScreenPosition(pos, screenPos); if (camera.radarRendering) { if (iteration == 0 && this.animRadar != null) { org.newdawn.slick.Color color = this.animRadar.get(); TextureImpl.bindNone(); GL11.glColor4f(color.r, color.g, color.b, color.a * this.alpha); float x = screenPos.x - 0.5f; float y = screenPos.y - 0.5f; GL11.glBegin(SGL.GL_QUADS); GL11.glVertex2f(x, y); GL11.glVertex2f(x + 1, y); GL11.glVertex2f(x + 1, y + 1); GL11.glVertex2f(x, y + 1); GL11.glEnd(); } return false; } if (iteration == 0) { // render the trail SpriteSheetCounted trail = this.imageTrail.getSpriteSheet(); if (trail != null) { Point trailPos = new Point(); PhysicsPositionVector phyPos = new PhysicsPositionVector(); long rand = imageTrailRandomized.get() ? SwissArmyKnife.fastRandomIsh() : 0; long tick = this.renderingAt_tick - (rand & 0b11); // 0, 1, 2, 3 rand >>= 2; for (int tile = 0; tile < trail.getTilesCount(); tile += (rand & 0b1) + 1, rand >>= 1) { physicsProjectile.getHistoricPosition(phyPos, tick - 2 * tile, true); if (phyPos.pos.set) { trailPos.set(phyPos.pos); trailPos.divide(1024); camera.mapToScreenPosition(trailPos, trailPos); Image img = trail.getSubImage(tile); img.draw(trailPos.x - img.getWidth() / 2, trailPos.y - img.getHeight() / 2, this.alphaFilter); } } } } else if (iteration == 1) { Animation anim; if (imageInactive.isSet() && !this.physicsProjectile.isActive()) { anim = animInactive; } else if (imageBounces.isSet() && this.physicsProjectile.getBouncesLeft() != 0) { anim = animBounces; } else { anim = animNoBounce; // also fallback } if (anim != null) { anim.draw(screenPos.x - anim.getWidth() / 2 * camera.zoom, screenPos.y - anim.getHeight() / 2 * camera.zoom, anim.getWidth() * camera.zoom, anim.getHeight() * camera.zoom, this.alphaFilter); } if (Client.showDebug) { camera.renderPlayerText(this.renderDelay_current + "", screenPos.x + 5, screenPos.y + 5, Color.WHITE); } } return iteration < 1; }
From source file:appeng.client.ClientHelper.java
License:Open Source License
@Override public void doRenderItem(final ItemStack itemstack, final World w) { if (itemstack != null) { final EntityItem entityitem = new EntityItem(w, 0.0D, 0.0D, 0.0D, itemstack); entityitem.getEntityItem().stackSize = 1; // set all this stuff and then do shit? meh? entityitem.hoverStart = 0;/*from w ww . j ava 2s .c o m*/ entityitem.age = 0; entityitem.rotationYaw = 0; GL11.glPushMatrix(); GL11.glTranslatef(0, -0.04F, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // GL11.glDisable( GL11.GL_CULL_FACE ); if (itemstack.isItemEnchanted() || itemstack.getItem().requiresMultipleRenderPasses()) { GL11.glTranslatef(0.0f, -0.05f, -0.25f); GL11.glScalef(1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f); // GL11.glTranslated( -8.0, -12.2, -10.6 ); GL11.glScalef(1.0f, -1.0f, 0.005f); // GL11.glScalef( 1.0f , -1.0f, 1.0f ); final Block block = Block.getBlockFromItem(itemstack.getItem()); if ((itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))) { GL11.glRotatef(25.0f, 1.0f, 0.0f, 0.0f); GL11.glRotatef(15.0f, 0.0f, 1.0f, 0.0f); GL11.glRotatef(30.0f, 0.0f, 1.0f, 0.0f); } final IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, IItemRenderer.ItemRenderType.ENTITY); if (customRenderer != null && !(itemstack.getItem() instanceof ItemBlock)) { if (customRenderer.shouldUseRenderHelper(IItemRenderer.ItemRenderType.ENTITY, itemstack, IItemRenderer.ItemRendererHelper.BLOCK_3D)) { GL11.glTranslatef(0, -0.04F, 0); GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glRotatef(35, 1, 0, 0); GL11.glRotatef(45, 0, 1, 0); GL11.glRotatef(-90, 0, 1, 0); } } else if (itemstack.getItem() instanceof ItemBlock) { GL11.glTranslatef(0, -0.04F, 0); GL11.glScalef(1.1f, 1.1f, 1.1f); GL11.glRotatef(-90, 0, 1, 0); } else { GL11.glTranslatef(0, -0.14F, 0); GL11.glScalef(0.8f, 0.8f, 0.8f); } RenderItem.renderInFrame = true; RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); RenderItem.renderInFrame = false; } else { GL11.glScalef(1.0f / 42.0f, 1.0f / 42.0f, 1.0f / 42.0f); GL11.glTranslated(-8.0, -10.2, -10.4); GL11.glScalef(1.0f, 1.0f, 0.005f); RenderItem.renderInFrame = false; final FontRenderer fr = Minecraft.getMinecraft().fontRenderer; if (!ForgeHooksClient.renderInventoryItem(BLOCK_RENDERER, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, 0, 0)) { ITEM_RENDERER.renderItemIntoGUI(fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0, false); } } GL11.glPopMatrix(); } }
From source file:appeng.client.gui.implementations.GuiInterfaceTerminal.java
License:Open Source License
@Override public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { this.bindTexture("guis/interfaceterminal.png"); this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); int offset = 17; final int ex = this.getScrollBar().getCurrentScroll(); for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) { final Object lineObj = this.lines.get(ex + x); if (lineObj instanceof ClientDCInternalInv) { final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; GL11.glColor4f(1, 1, 1, 1); final int width = inv.getInventory().getSizeInventory() * 18; this.drawTexturedModalRect(offsetX + 7, offsetY + offset, 7, 139, width, 18); }// w w w . j a v a 2 s. c om offset += 18; } if (this.searchField != null) { this.searchField.drawTextBox(); } }
From source file:appeng.client.gui.widgets.GuiImgButton.java
License:Open Source License
@Override public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) { if (this.visible) { final int iconIndex = this.getIconIndex(); if (this.halfSize) { this.width = 8; this.height = 8; GL11.glPushMatrix();//from w w w . jav a 2 s. co m GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F); GL11.glScalef(0.5f, 0.5f, 0.5f); if (this.enabled) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } else { GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f); } par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png")); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; final int uv_y = (int) Math.floor(iconIndex / 16); final int uv_x = iconIndex - uv_y * 16; this.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16); this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16); this.mouseDragged(par1Minecraft, par2, par3); GL11.glPopMatrix(); } else { if (this.enabled) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } else { GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f); } par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png")); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; final int uv_y = (int) Math.floor(iconIndex / 16); final int uv_x = iconIndex - uv_y * 16; this.drawTexturedModalRect(this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16); this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16); this.mouseDragged(par1Minecraft, par2, par3); } } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }
From source file:appeng.client.gui.widgets.GuiScrollbar.java
License:Open Source License
public void draw(final AEBaseGui g) { g.bindTexture("minecraft", "gui/container/creative_inventory/tabs.png"); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (this.getRange() == 0) { g.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15); } else {/* www . ja v a2 s . c o m*/ final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange(); g.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15); } }
From source file:appeng.client.gui.widgets.GuiTabButton.java
License:Open Source License
@Override public void drawButton(final Minecraft minecraft, final int x, final int y) { if (this.visible) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png")); this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; int uv_x = (this.hideEdge > 0 ? 11 : 13); final int offsetX = this.hideEdge > 0 ? 1 : 0; this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22); if (this.myIcon >= 0) { final int uv_y = (int) Math.floor(this.myIcon / 16); uv_x = this.myIcon - uv_y * 16; this.drawTexturedModalRect(offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16);//from w w w .j a v a 2 s . c om } this.mouseDragged(minecraft, x, y); if (this.myItem != null) { this.zLevel = 100.0F; this.itemRenderer.zLevel = 100.0F; GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); final FontRenderer fontrenderer = minecraft.fontRenderer; this.itemRenderer.renderItemAndEffectIntoGUI(fontrenderer, minecraft.renderEngine, this.myItem, offsetX + this.xPosition + 3, this.yPosition + 3); GL11.glDisable(GL11.GL_LIGHTING); this.itemRenderer.zLevel = 0.0F; this.zLevel = 0.0F; } } }
From source file:appeng.client.gui.widgets.GuiToggleButton.java
License:Open Source License
@Override public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) { if (this.visible) { final int iconIndex = this.getIconIndex(); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png")); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; final int uv_y = (int) Math.floor(iconIndex / 16); final int uv_x = iconIndex - uv_y * 16; this.drawTexturedModalRect(this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16); this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16); this.mouseDragged(par1Minecraft, par2, par3); }// w w w . jav a 2 s . c o m }
From source file:appeng.client.render.AppEngRenderItem.java
License:Open Source License
@Override public void renderItemOverlayIntoGUI(final FontRenderer fontRenderer, final TextureManager textureManager, final ItemStack is, final int par4, final int par5, final String par6Str) { if (is != null) { final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f; final float inverseScaleFactor = 1.0f / scaleFactor; final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1; final boolean unicodeFlag = fontRenderer.getUnicodeFlag(); fontRenderer.setUnicodeFlag(false); if (is.getItem().showDurabilityBar(is)) { final double health = is.getItem().getDurabilityForDisplay(is); final int j1 = (int) Math.round(13.0D - health * 13.0D); final int k = (int) Math.round(255.0D - health * 255.0D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); final Tessellator tessellator = Tessellator.instance; final int l = 255 - k << 16 | k << 8; final int i1 = (255 - k) / 4 << 16 | 16128; this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1); this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }/* w ww .j a v a 2 s .co m*/ if (is.stackSize == 0) { final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); final int X = (int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(craftLabelText) * scaleFactor) * inverseScaleFactor); final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize; if (amount != 0) { final String stackSize = this.getToBeRenderedStackSize(amount); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); final int X = (int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor) * inverseScaleFactor); final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } fontRenderer.setUnicodeFlag(unicodeFlag); } }
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 w w w. j a v a 2s .c o m 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; }