@Override public void drawButton(Minecraft mc, int x, int y, float partialTicks) { if (thisVisible) super.drawButton(mc, x, y, partialTicks); if (visible) { if (renderedStacks != null) { int middleX = this.x + width / 2; int startX = middleX - renderedStacks.length * 9 + 1; GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); for (int i = 0; i < renderedStacks.length; i++) { itemRenderer.renderItemAndEffectIntoGUI(renderedStacks[i], startX + i * 18, this.y + 2); } RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } if (resLoc != null) { mc.getTextureManager().bindTexture(resLoc); drawModalRectWithCustomSizedTexture(this.x + width / 2 - 8, this.y + 2, 0, 0, 16, 16, 16, 16); } if (enabled && !thisVisible && x >= this.x && y >= this.y && x < this.x + width && y < this.y + height) { Gui.drawRect(this.x, this.y, this.x + width, this.y + height, invisibleHoverColor); } } }
public static void allocateTextureImpl(int p_180600_0_, int p_180600_1_, int p_180600_2_, int p_180600_3_) { deleteTexture(p_180600_0_); bindTexture(p_180600_0_); if (p_180600_1_ >= 0) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, p_180600_1_); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)p_180600_1_); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); } for (int i = 0; i <= p_180600_1_; ++i) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, p_180600_2_ >> i, p_180600_3_ >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null)); } }
private static void uploadTextureImageSubImpl(BufferedImage p_110993_0_, int p_110993_1_, int p_110993_2_, boolean p_110993_3_, boolean p_110993_4_) { int i = p_110993_0_.getWidth(); int j = p_110993_0_.getHeight(); int k = 4194304 / i; int[] aint = new int[k * i]; setTextureBlurred(p_110993_3_); setTextureClamped(p_110993_4_); for (int l = 0; l < i * j; l += i * k) { int i1 = l / i; int j1 = Math.min(k, j - i1); int k1 = i * j1; p_110993_0_.getRGB(0, i1, i, j1, aint, 0, i); copyToBuffer(aint, k1); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, p_110993_1_, p_110993_2_ + i1, i, j1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)dataBuffer); } }
private static void uploadTextureSub(int p_147947_0_, int[] p_147947_1_, int p_147947_2_, int p_147947_3_, int p_147947_4_, int p_147947_5_, boolean p_147947_6_, boolean p_147947_7_, boolean p_147947_8_) { int i = 4194304 / p_147947_2_; setTextureBlurMipmap(p_147947_6_, p_147947_8_); setTextureClamped(p_147947_7_); int j; for (int k = 0; k < p_147947_2_ * p_147947_3_; k += p_147947_2_ * j) { int l = k / p_147947_2_; j = Math.min(i, p_147947_3_ - l); int i1 = p_147947_2_ * j; copyToBufferPos(p_147947_1_, k, i1); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, p_147947_0_, p_147947_4_, p_147947_5_ + l, p_147947_2_, j, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)dataBuffer); } }
public static int loadCubeMap(MyFile[] textureFiles) { int texID = GL11.glGenTextures(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); for (int i = 0; i < textureFiles.length; i++) { TextureData data = decodeTextureFile(textureFiles[i]); GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, data.getBuffer()); } GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0); return texID; }
/** * Draws an ItemStack * * @param itemStack itemstack to draw * @param x startX * @param y startY */ public void drawItemStack(ItemStack itemStack, int x, int y) { int[][] savedGLState = OpenGLHelper.saveGLState(new int[]{GL11.GL_ALPHA_TEST, GL11.GL_LIGHTING}); RenderItem renderItem = mc.getRenderItem(); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_DEPTH_TEST); renderItem.renderItemIntoGUI(itemStack, x, y); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); OpenGLHelper.restoreGLState(savedGLState); }
private static void doSave(ResourceLocation texture, String filename) { mc.getTextureManager().bindTexture(texture); RenderUtil.checkGLError("Before save texture"); int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); //int format = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_INTERNAL_FORMAT); int bufferSize = width * height; RenderUtil.checkGLError("After get texture info"); IntBuffer pixelBuffer = BufferUtils.createIntBuffer(bufferSize); int[] pixelValues = new int[bufferSize]; GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer); pixelBuffer.get(pixelValues); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); img.setRGB(0, 0, width, height, pixelValues, 0, width); try { ImageIO.write(img, "png", new File(filename)); } catch (IOException e) { e.printStackTrace(); } RenderUtil.checkGLError("After save texture"); }
@Override public void doRender(Entity entity, double x, double y, double z, float f, float partialTickTime) { GL11.glDisable(GL12.GL_RESCALE_NORMAL); EntitySmallAsteroid asteroid = (EntitySmallAsteroid) entity; GL11.glPushMatrix(); GL11.glTranslatef((float) x, (float) y + 0.5F, (float) z); GL11.glRotatef(asteroid.rotationPitch, 1, 0, 0); GL11.glRotatef(asteroid.rotationYaw, 0, 1, 0); this.bindEntityTexture(asteroid); this.blockRenderer.renderBlockAsItem(AsteroidBlocks.blockBasic, 0, 1.0F); GL11.glPopMatrix(); }
@Override public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) { GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); final float var24 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9; final float var25 = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * par9; GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180.0F - var24, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-var25, 0.0F, 1.0F, 0.0F); this.bindEntityTexture(entity); GL11.glScalef(-1.0F, -1.0F, 1.0F); GL11.glScalef(0.65F, 0.6F, 0.65F); modelEntryPod.renderAll(); GL11.glPopMatrix(); }
private void renderGrappleGun(ItemRenderType type, RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { if (type == ItemRenderType.INVENTORY) { GL11.glPushMatrix(); GL11.glScalef(0.7F, 0.75F, 0.5F); GL11.glTranslatef(0.5F, -0.2F, -0.5F); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderManager.instance.itemRenderer.renderItem(FMLClientHandler.instance().getClientPlayerEntity(), new ItemStack(Items.string, 1), 0, ItemRenderType.INVENTORY); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } GL11.glPushMatrix(); this.transform(type); FMLClientHandler.instance().getClient().renderEngine.bindTexture(ItemRendererGrappleHook.grappleTexture); ItemRendererGrappleHook.modelGrapple.renderAll(); GL11.glPopMatrix(); }
@Override public void renderTileEntityAt(TileEntity var1, double par2, double par4, double par6, float var8) { GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) par2, (float) par4, (float) par6); GL11.glTranslatef(0.5F, 3.0F, 0.5F); GL11.glScalef(1.3F, -1.3F, -1.3F); this.bindTexture(TileEntityNasaWorkbenchRenderer.assemblyTableTexture); this.model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
@Override public void drawIcons() { int x = buttonX(); LayoutManager.drawIcon(x+4, 4, new Image(120, 24, 12, 12)); x+=24; LayoutManager.drawIcon(x+4, 4, new Image(120, 12, 12, 12)); x+=24; LayoutManager.drawIcon(x+4, 4, new Image(168, 24, 12, 12)); x+=24; LayoutManager.drawIcon(x+4, 4, new Image(144, 12, 12, 12)); x+=24; LayoutManager.drawIcon(x+4, 4, new Image(180, 24, 12, 12)); x+=24; LayoutManager.drawIcon(x+4, 4, new Image(132, 12, 12, 12)); x+=24; RenderHelper.enableGUIStandardItemLighting(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); ItemStack sword = new ItemStack(Items.diamond_sword); sword.addEnchantment(Enchantment.sharpness, 1); GuiContainerManager.drawItem(x+2, 2, sword); x+=24; GuiContainerManager.drawItem(x+2, 2, new ItemStack(Items.potionitem)); x+=24; GuiContainerManager.drawItem(x+2, 2, new ItemStack(Blocks.stone)); x+=24; }
public static void renderEquippedItem(ItemRenderType type, IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLivingBase entity, ItemStack item) { if (customRenderer.shouldUseRenderHelper(type, item, EQUIPPED_BLOCK)) { GL11.glPushMatrix(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); customRenderer.renderItem(type, item, renderBlocks, entity); GL11.glPopMatrix(); } else { GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(0.0F, -0.3F, 0.0F); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); customRenderer.renderItem(type, item, renderBlocks, entity); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } }
public static void drawPoint(Vertice v1, float size) { GL11.glPushMatrix(); GL11.glTranslatef(v1.x, v1.y, v1.z); GL11.glEnable(GL12.GL_RESCALE_NORMAL); size /= 2; Tessellator t = Tessellator.instance; GL11.glRotatef(180 - Minecraft.getMinecraft().thePlayer.rotationYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90 - Minecraft.getMinecraft().thePlayer.rotationPitch, 1.0F, 0.0F, 0.0F); t.startDrawingQuads(); t.setNormal(0.0F, 1.0F, 0.0F); t.addVertexWithUV(-size, 0, -size, 0, 0); t.addVertexWithUV(size, 0, -size, 1, 0); t.addVertexWithUV(size, 0, size, 1, 1); t.addVertexWithUV(-size, 0, size, 0, 1); t.draw(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
public static void drawLine(Vertice v1, float size1, Vertice v2, float size2) { GL11.glPushMatrix(); GL11.glTranslatef(v1.x, v1.y, v1.z); GL11.glEnable(GL12.GL_RESCALE_NORMAL); size1 /= 2; size2 /= 2; Tessellator t = Tessellator.instance; GL11.glRotatef(180 - Minecraft.getMinecraft().thePlayer.rotationYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90 - Minecraft.getMinecraft().thePlayer.rotationPitch, 1.0F, 0.0F, 0.0F); t.startDrawingQuads(); t.setNormal(0.0F, 1.0F, 0.0F); t.addVertexWithUV(-size1, 0, -size1, 0, 0); t.addVertexWithUV(size1, 0, -size1, 1, 0); t.addVertexWithUV(size1, 0, size1, 1, 1); t.addVertexWithUV(-size1, 0, size1, 0, 1); t.draw(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
@Override public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) { er += 13.46; EntityRoddiskOfficer erd = (EntityRoddiskOfficer) var1; Minecraft.getMinecraft().renderEngine.bindTexture(RivalRebels.etdisk2); GL11.glPushMatrix(); GL11.glTranslatef((float) var2, (float) var4, (float) var6); GL11.glRotatef(erd.rotationPitch, 0.0F, 0.0F, 1.0F); GL11.glRotatef(erd.rotationYaw - 90.0f + er, 0.0F, 1.0F, 0.0F); GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glPushMatrix(); model.render(); GL11.glPopMatrix(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
@Override public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) { er += 13.46; EntityRoddiskRegular erd = (EntityRoddiskRegular) var1; Minecraft.getMinecraft().renderEngine.bindTexture(RivalRebels.etdisk0); GL11.glPushMatrix(); GL11.glTranslatef((float) var2, (float) var4, (float) var6); GL11.glRotatef(erd.rotationPitch, 0.0F, 0.0F, 1.0F); GL11.glRotatef(erd.rotationYaw - 90.0f + er, 0.0F, 1.0F, 0.0F); GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glPushMatrix(); model.render(); GL11.glPopMatrix(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
@Override public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) { er += 13.46; EntityRoddiskRebel erd = (EntityRoddiskRebel) var1; Minecraft.getMinecraft().renderEngine.bindTexture(RivalRebels.etdisk1); GL11.glPushMatrix(); GL11.glTranslatef((float) var2, (float) var4, (float) var6); GL11.glRotatef(erd.rotationPitch, 0.0F, 0.0F, 1.0F); GL11.glRotatef(erd.rotationYaw - 90.0f + er, 0.0F, 1.0F, 0.0F); GL11.glScalef(0.4f, 0.4f, 0.4f); GL11.glPushMatrix(); model.render(); GL11.glPopMatrix(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
private OpenGlState() { this.enableBlend = isSet(GL11.GL_BLEND); this.blendSource = getInteger(GL11.GL_BLEND_SRC); this.blendDest = getInteger(GL11.GL_BLEND_DST); this.blendEquation = getInteger(GL14.GL_BLEND_EQUATION); this.enableAlphaTest = isSet(GL11.GL_ALPHA_TEST); this.alphaTestFunc = getInteger(GL11.GL_ALPHA_TEST_FUNC); this.alphaTestRef = getFloat(GL11.GL_ALPHA_TEST_REF); this.depthTest = isSet(GL11.GL_DEPTH_TEST); this.depthFunc = getInteger(GL11.GL_DEPTH_FUNC); this.lighting = isSet(GL11.GL_LIGHTING); this.depthMask = isSet(GL11.GL_DEPTH_WRITEMASK); this.normal = isSet(GL11.GL_NORMALIZE); this.rescaleNormal = isSet(GL12.GL_RESCALE_NORMAL); GlStateManager.pushMatrix(); }
public void renderTileEntityAt(final TileEntity tileEntity, final double x, final double y, final double z, final float distance) { final TileEntityAvaritiaddonsChest tileEntityAvaritiaddonsChest = (TileEntityAvaritiaddonsChest) tileEntity; bindTexture(tileEntityAvaritiaddonsChest.getTexture()); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef(tileEntityAvaritiaddonsChest.hasWorldObj() ? tileEntityAvaritiaddonsChest.getFacingSide() : -90, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = tileEntityAvaritiaddonsChest.prevLidAngle + (tileEntityAvaritiaddonsChest.lidAngle - tileEntityAvaritiaddonsChest.prevLidAngle) * distance; f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; modelChest.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F); modelChest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
@Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks){ if(thisVisible) super.drawButton(mc, mouseX, mouseY, partialTicks); if(visible) { if(renderedStacks != null) { int middleX = this.x + width / 2; int startX = middleX - renderedStacks.length * 9 + 1; GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); for(int i = 0; i < renderedStacks.length; i++) { itemRenderer.renderItemAndEffectIntoGUI(renderedStacks[i], startX + i * 18, this.y + 2); } RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } if(resLoc != null) { mc.getTextureManager().bindTexture(resLoc); drawModalRectWithCustomSizedTexture(this.x + width / 2 - 8, this.y + 2, 0, 0, 16, 16, 16, 16); } if(enabled && !thisVisible && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + width && mouseY < this.y + height) { Gui.drawRect(this.x, this.y, this.x + width, this.y + height, invisibleHoverColor); } } }
private void screenshotImpl() { screenshot = false; File out = new File("saves/screenshot.png"); int i = 1; while (out.exists()) { out = new File("saves/screenshot" + i++ + ".png"); } out.getParentFile().mkdirs(); try { FileOutputStream fos = new FileOutputStream(out); GL11.glReadBuffer(GL11.GL_FRONT); ByteBuffer buf = BufferUtils.createByteBuffer(getWidth() * getHeight() * 3); GL11.glReadPixels(0, 0, window.getWidth(), getWidth(), GL12.GL_BGR, GL11.GL_UNSIGNED_BYTE, buf); BufferedImage img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_3BYTE_BGR); for (int y = getHeight() - 1; y >= 0; y--) { buf.get(((DataBufferByte) img.getRaster().getDataBuffer()).getData(), getWidth() * 3 * y, getWidth() * 3); } ImageIO.write(img, "PNG", fos); fos.close(); Logs.d("Took screenshot"); } catch (IOException e) { Logs.e(e); } }
private void renderVortex(EntityVortex entity, double x, double y, double z, float var1, float partialTicks) { int circlePoints = 200; double radius = 0.5D; GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4d(0.8, 0.8, 0.8D, 0.7D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F); GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks, 0.0F, 1.0F, 0.0F); for (int i = 0; i < circlePoints; i++) { float angleRadians = (float) i / (float) circlePoints * 2F * (float) Math.PI; GL11.glPushMatrix(); GL11.glTranslated(radius * Math.sin(angleRadians), radius * Math.cos(angleRadians), 0); renderGust(); GL11.glPopMatrix(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
@Override @SideOnly(Side.CLIENT) public void render3D(float partialTicks) { GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(false); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Minecraft.getMinecraft().getRenderManager().renderEngine.bindTexture(Textures.GLOW_RESOURCE); // mc.func_110434_K().func_110577_a(Textures.GLOW_RESOURCE); for (Map.Entry<EntityItem, Integer> entry : searchedItems.entrySet()) { EntityItem item = entry.getKey(); float height = MathHelper.sin((item.getAge() + partialTicks) / 10.0F + item.hoverStart) * 0.1F + 0.2F; RenderSearchItemBlock.renderSearch(item.lastTickPosX + (item.posX - item.lastTickPosX) * partialTicks, item.lastTickPosY + (item.posY - item.lastTickPosY) * partialTicks + height, item.lastTickPosZ + (item.posZ - item.lastTickPosZ) * partialTicks, entry.getValue(), totalSearchedItemCount); } for (int i = 0; i < searchedBlocks.size(); i++) { if (!searchedBlocks.get(i).renderSearchBlock(totalSearchedItemCount)) { searchedBlocks.remove(i); i--; } } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL12.GL_RESCALE_NORMAL); }
public void render(double size, float partialTicks) { double renderRotationAngle = oldRotationAngle + (rotationAngle - oldRotationAngle) * partialTicks; BufferBuilder wr = Tessellator.getInstance().getBuffer(); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); // GL11.glLineWidth((float)size * 20F); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glRotatef((float) renderRotationAngle, 0, 0, 1); for (int j = 0; j < 2; j++) { wr.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION); for (int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) { wr.pos(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0).endVertex(); wr.pos(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0).endVertex(); } Tessellator.getInstance().draw(); if (renderAsTagged) { GL11.glColor4d(1, 0, 0, 1); wr.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); for (int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) { wr.pos(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0).endVertex(); } for (int i = PneumaticCraftUtils.circlePoints / 4 - 1; i >= 0; i--) { wr.pos(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0).endVertex(); } Tessellator.getInstance().draw(); GL11.glColor4d(1, 1, 0, 0.5); } GL11.glRotatef(180, 0, 0, 1); } GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
public static void drawItemStack(ItemStack stack, int x, int y) { GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); itemRenderer.renderItemAndEffectIntoGUI(stack, x, y); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); }
private int calcBytesPerVertex() { if (dataType == GL11.GL_FLOAT || dataType == GL11.GL_UNSIGNED_INT || dataType == GL11.GL_INT) { return 4 * componentCount; } else if (dataType == GL11.GL_SHORT || dataType == GL11.GL_UNSIGNED_SHORT) { return 2 * componentCount; } else if (dataType == GL11.GL_BYTE || dataType == GL11.GL_UNSIGNED_BYTE) { return 1 * componentCount; } else if (dataType == GL12.GL_UNSIGNED_INT_2_10_10_10_REV) { return 4; } System.err.println("Unsupported data type for VAO attribute: " + dataType); return 0; }
private void setTextureParams(){ int filterType = nearestFiltering ? GL11.GL_NEAREST : GL11.GL_LINEAR; GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filterType); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filterType); int wrapType = clampEdges ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT; GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapType); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapType); }
private static void uploadTextureSub(int p_147947_0_, int[] p_147947_1_, int p_147947_2_, int p_147947_3_, int p_147947_4_, int p_147947_5_, boolean p_147947_6_, boolean p_147947_7_, boolean p_147947_8_) { int i = 4194304 / p_147947_2_; setTextureBlurMipmap(p_147947_6_, p_147947_8_); setTextureClamped(p_147947_7_); int l; for (int j = 0; j < p_147947_2_ * p_147947_3_; j += p_147947_2_ * l) { int k = j / p_147947_2_; l = Math.min(i, p_147947_3_ - k); int i1 = p_147947_2_ * l; copyToBufferPos(p_147947_1_, j, i1); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, p_147947_0_, p_147947_4_, p_147947_5_ + k, p_147947_2_, l, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)dataBuffer); } }
public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { if (!(entity instanceof EntityWindBlade)) { return; } this.bindEntityTexture(entity); GL11.glPushMatrix(); GL11.glTranslated(x, y, z); //原点移到实体中心 GL11.glRotatef(entity.rotationYaw - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(entity.rotationPitch, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(1, 0.1f, 1); for (int i = 0; i < 180; ++i) { GL11.glRotatef(1F, 1.0F, 0.0F, 0.0F); //GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-1D, -1D, 0.0D, 0, 1); // 左下 tessellator.addVertexWithUV( 1D, -1D, 0.0D, 0, 0); // 左上 tessellator.addVertexWithUV( 1D, 1D, 0.0D, 1, 0); // 右上 tessellator.addVertexWithUV(-1D, 1D, 0.0D, 1, 1); // 右下 tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
/** * This renders the player model in standard inventory position (in later * versions of Minecraft / Forge, you can simply call * GuiInventory.drawEntityOnScreen directly instead of copying this code) */ public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 50.0F); GL11.glScalef(-scale, scale, scale); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F; Minecraft.getMinecraft().getRenderManager().setRenderShadow(false); Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false); Minecraft.getMinecraft().getRenderManager().setRenderShadow(true); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); }
public static void updateDynTexSubImage1(int[] src, int width, int height, int posX, int posY, int page) { int i = width * height; IntBuffer intbuffer = getIntBuffer(i); intbuffer.clear(); int j = page * i; if (src.length >= j + i) { intbuffer.put(src, j, i).position(0).limit(i); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, posX, posY, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer); intbuffer.clear(); } }
public static void uploadTexSub1(int[][] src, int width, int height, int posX, int posY, int page) { int i = width * height; IntBuffer intbuffer = getIntBuffer(i); int j = src.length; int k = 0; int l = width; int i1 = height; int j1 = posX; for (int k1 = posY; l > 0 && i1 > 0 && k < j; ++k) { int l1 = l * i1; int[] aint = src[k]; intbuffer.clear(); if (aint.length >= l1 * (page + 1)) { intbuffer.put(aint, l1 * page, l1).position(0).limit(l1); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, k, j1, k1, l, i1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer); } l >>= 1; i1 >>= 1; j1 >>= 1; k1 >>= 1; } intbuffer.clear(); }
public static void setupTexture(MultiTexID multiTex, int[] src, int width, int height, boolean linear, boolean clamp) { int i = linear ? 9729 : 9728; int j = clamp ? 10496 : 10497; int k = width * height; IntBuffer intbuffer = getIntBuffer(k); intbuffer.clear(); intbuffer.put(src, 0, k).position(0).limit(k); GlStateManager.bindTexture(multiTex.base); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j); intbuffer.put(src, k, k).position(0).limit(k); GlStateManager.bindTexture(multiTex.norm); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j); intbuffer.put(src, k * 2, k).position(0).limit(k); GlStateManager.bindTexture(multiTex.spec); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)intbuffer); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, i); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, j); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, j); GlStateManager.bindTexture(multiTex.base); }
public static void allocateMipmapTextures(int p_allocateMipmapTextures_0_, int p_allocateMipmapTextures_1_, String p_allocateMipmapTextures_2_) { Dimension[] adimension = makeMipmapDimensions(p_allocateMipmapTextures_0_, p_allocateMipmapTextures_1_, p_allocateMipmapTextures_2_); for (int i = 0; i < adimension.length; ++i) { Dimension dimension = adimension[i]; int j = dimension.width; int k = dimension.height; int l = i + 1; GL11.glTexImage2D(GL11.GL_TEXTURE_2D, l, GL11.GL_RGBA, j, k, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null)); } }
public static void allocateTextureImpl(int p_180600_0_, int p_180600_1_, int p_180600_2_, int p_180600_3_) { Object object = TextureUtil.class; if (Reflector.SplashScreen.exists()) { object = Reflector.SplashScreen.getTargetClass(); } synchronized (object) { deleteTexture(p_180600_0_); bindTexture(p_180600_0_); } if (p_180600_1_ >= 0) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, p_180600_1_); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)p_180600_1_); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); } for (int i = 0; i <= p_180600_1_; ++i) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, p_180600_2_ >> i, p_180600_3_ >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null)); } }