package shadersmod.client;

import static org.lwjgl.opengl.EXTFramebufferObject.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL13.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.culling.ClippingHelper;
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MathHelper;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL20;
import org.lwjgl.util.glu.Project;

import shadersmod.common.SMCEnvironment;


public class ShadersRender {

	public static void setFrustrumPosition(Frustum frustrum, double x, double y, double z)
	{
		frustrum.setPosition(x, y, z);
	}

	public static void setupTerrain(RenderGlobal renderGlobal, Entity viewEntity, double partialTicks, ICamera camera, int frameCount, boolean playerSpectator)
	{
		renderGlobal.setupTerrain(viewEntity, partialTicks, camera, frameCount, playerSpectator);
	}
	
	public static void updateChunks(RenderGlobal renderGlobal, long finishTimeNano)
	{
		renderGlobal.updateChunks(finishTimeNano);
	}
	
//	public static void clipRenderersByFrustrum(RenderGlobal renderGlobal, Frustrum frustrum, float par2)
//	{
//		Shaders.checkGLError("pre clip");
//		if (!Shaders.isShadowPass) {
//			WorldRenderer[] worldRenderers = renderGlobal.worldRenderers;
//	        for (int i = 0; i < worldRenderers.length; ++i)
//	        {
//	            if (!worldRenderers[i].skipAllRenderPasses())
//	            {
//	                worldRenderers[i].updateInFrustum(frustrum);
//	            }
//	        }
//		} else {
//			WorldRenderer[] worldRenderers = renderGlobal.worldRenderers;
//	        for (int i = 0; i < worldRenderers.length; ++i)
//	        {
//	            if (!worldRenderers[i].skipAllRenderPasses())
//	            {
//                    worldRenderers[i].isInFrustum = true;
//	            }
//	        }
//		}
//	}



	public static void beginTerrainSolid() {
		if (Shaders.isRenderingWorld)
		{
			Shaders.fogEnabled = true;
			Shaders.useProgram(Shaders.ProgramTerrain);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}
	public static void beginTerrainCutoutMipped() {
		if (Shaders.isRenderingWorld)
		{
			Shaders.useProgram(Shaders.ProgramTerrain);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}
	public static void beginTerrainCutout() {
		if (Shaders.isRenderingWorld)
		{
			Shaders.useProgram(Shaders.ProgramTerrain);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}
	public static void endTerrain() {
		if (Shaders.isRenderingWorld)
		{
			Shaders.useProgram(Shaders.ProgramTexturedLit);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}
	public static void beginTranslucent() {
		if (Shaders.isRenderingWorld)
		{
			if (Shaders.usedDepthBuffers >= 2) {
				// copy depth buffer to depthtex1
				glActiveTexture(GL13.GL_TEXTURE11);
				Shaders.checkGLError("pre copy depth");
				GL11.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Shaders.renderWidth, Shaders.renderHeight);
				Shaders.checkGLError("copy depth");
				glActiveTexture(GL_TEXTURE0);
			}
			Shaders.useProgram(Shaders.ProgramWater);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}
	public static void endTranslucent() {
		if (Shaders.isRenderingWorld)
		{
			Shaders.useProgram(Shaders.ProgramTexturedLit);
			//ShadersTex.bindNSTextures(defaultTexture.getMultiTexID()); // flat
		}
	}

	public static void renderHand0(EntityRenderer er, float par1, int par2) {
		if (!Shaders.isShadowPass)
		{
			Item item = (Shaders.itemToRender!=null)? Shaders.itemToRender.getItem(): null;
			Block block = (item instanceof ItemBlock)? ((ItemBlock)item).getBlock(): null; 

			if (!(item instanceof ItemBlock) || !(block instanceof Block) || (block.getBlockLayer()==EnumWorldBlockLayer.SOLID))
			{
				Shaders.readCenterDepth();
				Shaders.beginHand();
				glColor4f(1, 1, 1, 1);
				Dummy.invoke_entityRenderer_renderHand(er, par1, par2);
				Shaders.endHand();
				Shaders.isHandRendered = true;
			}
		}
	}

	public static void renderHand1(EntityRenderer er, float par1, int par2) {
		if (!Shaders.isShadowPass)
		{
			if (!Shaders.isHandRendered) {
				Shaders.readCenterDepth();
				GL11.glEnable(GL11.GL_BLEND);
				Shaders.beginHand();
				glColor4f(1, 1, 1, 1);
				Dummy.invoke_entityRenderer_renderHand(er, par1, par2);
				Shaders.endHand();
				Shaders.isHandRendered = true;
			}
		}
	}

	public static void renderItemFP(ItemRenderer itemRenderer, float par1) {
		// clear depth buffer locally
		GL11.glDepthMask(true);
		//GL11.glDisable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_ALWAYS);
		GL11.glPushMatrix();
		IntBuffer drawBuffers = Shaders.activeDrawBuffers;
		Shaders.setDrawBuffers(Shaders.drawBuffersNone);
		Shaders.renderItemPass1DepthMask = true;
		itemRenderer.renderItemInFirstPerson(par1);
		Shaders.renderItemPass1DepthMask = false;
		Shaders.setDrawBuffers(drawBuffers);
		GL11.glPopMatrix();
		//GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_LEQUAL);
		// really render item or hand
		glColor4f(1, 1, 1, 1);
		itemRenderer.renderItemInFirstPerson(par1);
	}
	
	public static void renderFPOverlay(EntityRenderer er, float par1, int par2) {
		if (!Shaders.isShadowPass)
		{
			Shaders.beginFPOverlay();
			Dummy.invoke_entityRenderer_renderHand(er, par1, par2);
			Shaders.endFPOverlay();
		}
	}
	
	public static void beginBlockDamage()
	{
		if (Shaders.isRenderingWorld)
		{
			Shaders.useProgram(Shaders.ProgramDamagedBlock);
			if (Shaders.programsID[Shaders.ProgramDamagedBlock] == Shaders.programsID[Shaders.ProgramTerrain]) {
				Shaders.setDrawBuffers(Shaders.drawBuffersColorAtt0);
				glDepthMask(false);
				//GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA,GL11.GL_ONE,GL11.GL_ZERO);
			}
		}
	}
	public static void endBlockDamage()
	{
		if (Shaders.isRenderingWorld)
		{
			glDepthMask(true);
			Shaders.useProgram(Shaders.ProgramTexturedLit);
		}
	}
	public static void renderShadowMap(EntityRenderer entityRenderer, int pass, float partialTicks, long finishTimeNano)
	{
		if (Shaders.usedShadowDepthBuffers > 0 && --Shaders.shadowPassCounter <= 0) {
			// do shadow pass
			Minecraft mc = Minecraft.getMinecraft();
			mc.mcProfiler.endStartSection("shadow pass");
			//SMCLog.info("shadow pass start");
			RenderGlobal renderGlobal = mc.renderGlobal;
			Shaders.isShadowPass = true;
			Shaders.shadowPassCounter = Shaders.shadowPassInterval;
			Shaders.preShadowPassThirdPersonView = mc.gameSettings.thirdPersonView;
			mc.gameSettings.thirdPersonView = 1;
	
			Shaders.checkGLError("pre shadow");
			glMatrixMode(GL_PROJECTION);
			GL11.glPushMatrix();
			glMatrixMode(GL_MODELVIEW);
			GL11.glPushMatrix();
			
			mc.mcProfiler.endStartSection("shadow clear");
			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Shaders.sfb);
			Shaders.checkGLError("shadow bind sfb");
			Shaders.useProgram(Shaders.ProgramShadow);
			
			mc.mcProfiler.endStartSection("shadow camera");
			Dummy.invoke_entityRenderer_setupCameraTransform(entityRenderer, partialTicks, 2);
			Shaders.setCameraShadow(partialTicks);
			ActiveRenderInfo.updateRenderInfo(mc.thePlayer, mc.gameSettings.thirdPersonView == 2);
			Shaders.checkGLError("shadow camera");
			
			//Shaders.printIntBuffer("shadow DrawBuffers ", Shaders.programsDrawBuffers[Shaders.ProgramShadow]);
			glDrawBuffers(Shaders.sfbDrawBuffers);
			Shaders.checkGLError("shadow drawbuffers");
			glReadBuffer(GL_NONE);
			Shaders.checkGLError("shadow readbuffer");
			// No need to clear shadow depth 1. It will be overwritten.
			//if (Shaders.usedShadowDepthBuffers > 1) {
			//	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Shaders.sfbDepthTextures.get(1), 0);
			//	glClear(GL_DEPTH_BUFFER_BIT);
			//}
			glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Shaders.sfbDepthTextures.get(0), 0);
			if (Shaders.usedShadowColorBuffers != 0) {
				glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Shaders.sfbColorTextures.get(0), 0);
			}
			Shaders.checkFramebufferStatus("shadow fb");
			glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
			glClear((Shaders.usedShadowColorBuffers!=0)? (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT): (GL_DEPTH_BUFFER_BIT));
			Shaders.checkGLError("shadow clear");

			mc.mcProfiler.endStartSection("shadow frustum");
			ClippingHelper clippingHelper = ClippingHelperShadow.getInstance();
			mc.mcProfiler.endStartSection("shadow culling");
			Frustum frustum = new Frustum(clippingHelper);
			//{
			//	public boolean isBoundingBoxInFrustum(AxisAlignedBB bb) { return true; }
			//};
			Entity viewEntity = mc.getRenderViewEntity();
			double viewPosX = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * (double)partialTicks;
			double viewPosY = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * (double)partialTicks;
			double viewPosZ = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * (double)partialTicks;
			frustum.setPosition(viewPosX, viewPosY, viewPosZ);
			
			GlStateManager.shadeModel(GL11.GL_SMOOTH);
			GlStateManager.enableDepth();
			GlStateManager.depthFunc(GL11.GL_LEQUAL);
			GlStateManager.depthMask(true);
			GlStateManager.colorMask(true, true, true, true);
			GlStateManager.enableCull();
			
			//if (Shaders.configCloudShadow)
			//	entityRenderer.renderCloudsCheck(renderGlobal, partialTicks, 2);
			
			mc.mcProfiler.endStartSection("shadow prepareterrain");
			mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
			
			mc.mcProfiler.endStartSection("shadow setupterrain");
			int frameCount = 0;
			frameCount = Dummy.get_entityRenderer_frameCount(entityRenderer);
			Dummy.put_entityRenderer_frameCount(entityRenderer,frameCount+1);
			renderGlobal.setupTerrain(viewEntity, (double)partialTicks, frustum, frameCount, mc.thePlayer.isSpectator());
			mc.mcProfiler.endStartSection("shadow updatechunks");
			//mc.renderGlobal.updateChunks(finishTimeNano);
			
			mc.mcProfiler.endStartSection("shadow terrain");
			
			GlStateManager.matrixMode(GL_MODELVIEW);
			GlStateManager.pushMatrix();
			GlStateManager.disableAlpha();
			renderGlobal.renderBlockLayer(EnumWorldBlockLayer.SOLID, (double)partialTicks, 2, viewEntity);
			Shaders.checkGLError("shadow terrain solid");
			GlStateManager.enableAlpha();
			renderGlobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT_MIPPED, (double)partialTicks, 2, viewEntity);
			Shaders.checkGLError("shadow terrain cutoutmipped");
			mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
			renderGlobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT, (double)partialTicks, 2, viewEntity);
			Shaders.checkGLError("shadow terrain cutout");
			mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
			GlStateManager.shadeModel(7424);
			GlStateManager.alphaFunc(516, 0.1F);
			
			GlStateManager.matrixMode(GL_MODELVIEW);
			GlStateManager.popMatrix();
			GlStateManager.pushMatrix();
			
			mc.mcProfiler.endStartSection("shadow entities");
			if (SMCEnvironment.hasForge) {
				Dummy.invoke_forgeHooksClient_setRenderPass(0);
			}
			renderGlobal.renderEntities(viewEntity, frustum, partialTicks);
			Shaders.checkGLError("shadow entities");

			GlStateManager.matrixMode(GL_MODELVIEW);
			GlStateManager.popMatrix();
			
			
			//GlStateManager.depthMask(false);
			//GlStateManager.enableCull();
			//this.mc.mcProfiler.endStartSection("weather");
			//this.renderRainSnow(partialTicks);
			GlStateManager.depthMask(true);
			//renderGlobal.renderWorldBorder(viewEntity, partialTicks);
			GlStateManager.disableBlend();
			GlStateManager.enableCull();
			GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
			GlStateManager.alphaFunc(516, 0.1F);
			
			if (Shaders.usedShadowDepthBuffers >= 2) {
				// copy depth buffer to shadowtex1
				glActiveTexture(GL_TEXTURE5);
				Shaders.checkGLError("pre copy shadow depth");
				GL11.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Shaders.shadowMapWidth, Shaders.shadowMapHeight);
				Shaders.checkGLError("copy shadow depth");
				glActiveTexture(GL_TEXTURE0);
			}
			
			//GlStateManager.enableBlend();
			GlStateManager.disableBlend();
			GlStateManager.depthMask(true);
			mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
			GlStateManager.shadeModel(7425);
			Shaders.checkGLError("shadow pre-translucent");
			glDrawBuffers(Shaders.sfbDrawBuffers);
			Shaders.checkGLError("shadow drawbuffers pre-translucent");
			Shaders.checkFramebufferStatus("shadow pre-translucent");
			
			mc.mcProfiler.endStartSection("shadow translucent");
			renderGlobal.renderBlockLayer(EnumWorldBlockLayer.TRANSLUCENT, (double)partialTicks, 2, viewEntity);
			Shaders.checkGLError("shadow translucent");

			if (SMCEnvironment.hasForge) {
				RenderHelper.enableStandardItemLighting();
				Dummy.invoke_forgeHooksClient_setRenderPass(1);
				renderGlobal.renderEntities(viewEntity, frustum, partialTicks);
				Dummy.invoke_forgeHooksClient_setRenderPass(-1);
				RenderHelper.disableStandardItemLighting();
				Shaders.checkGLError("shadow entities 1");
			}

			GlStateManager.shadeModel(7424);
			GlStateManager.depthMask(true);
			GlStateManager.enableCull();
			GlStateManager.disableBlend();
			//---------------------------------------

			// Tell OpenGL to start rendering if it has not already started.
			glFlush();
			Shaders.checkGLError("shadow flush");

			Shaders.isShadowPass = false;
			mc.gameSettings.thirdPersonView = Shaders.preShadowPassThirdPersonView;

			mc.mcProfiler.endStartSection("shadow postprocess");

			if (Shaders.hasGlGenMipmap) {
				if (Shaders.usedShadowDepthBuffers >= 1) {
					if (Shaders.shadowMipmapEnabled[0]) {
						glActiveTexture(GL_TEXTURE4);
						glBindTexture(GL_TEXTURE_2D, Shaders.sfbDepthTextures.get(0));
						glGenerateMipmap(GL_TEXTURE_2D);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Shaders.shadowFilterNearest[0]? GL_NEAREST_MIPMAP_NEAREST: GL_LINEAR_MIPMAP_LINEAR);
					}
					if (Shaders.usedShadowDepthBuffers >= 2) {
						if (Shaders.shadowMipmapEnabled[1]) {
							glActiveTexture(GL_TEXTURE5);
							glBindTexture(GL_TEXTURE_2D, Shaders.sfbDepthTextures.get(1));
							glGenerateMipmap(GL_TEXTURE_2D);
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Shaders.shadowFilterNearest[1]? GL_NEAREST_MIPMAP_NEAREST: GL_LINEAR_MIPMAP_LINEAR);
						}
					}
					glActiveTexture(GL_TEXTURE0);
				}
				if (Shaders.usedShadowColorBuffers >= 1) {
					if (Shaders.shadowColorMipmapEnabled[0]) {
						glActiveTexture(GL_TEXTURE13);
						glBindTexture(GL_TEXTURE_2D, Shaders.sfbColorTextures.get(0));
						glGenerateMipmap(GL_TEXTURE_2D);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,  Shaders.shadowColorFilterNearest[0]? GL_NEAREST_MIPMAP_NEAREST: GL_LINEAR_MIPMAP_LINEAR);
					}
					if (Shaders.usedShadowColorBuffers >= 2) {
						if (Shaders.shadowColorMipmapEnabled[1]) {
							glActiveTexture(GL_TEXTURE14);
							glBindTexture(GL_TEXTURE_2D, Shaders.sfbColorTextures.get(1));
							glGenerateMipmap(GL_TEXTURE_2D);
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,  Shaders.shadowColorFilterNearest[1]? GL_NEAREST_MIPMAP_NEAREST: GL_LINEAR_MIPMAP_LINEAR);
						}
					}
					glActiveTexture(GL_TEXTURE0);
				}
			}
			
			//SMCLog.info("shadow pass end");
			// After shadow pass
			Shaders.checkGLError("shadow postprocess");
			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Shaders.dfb);
			GL11.glViewport(0, 0, Shaders.renderWidth, Shaders.renderHeight);
			Shaders.activeDrawBuffers = null;
			mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
			Shaders.useProgram(Shaders.ProgramTerrain);
			glMatrixMode(GL_MODELVIEW);
			GL11.glPopMatrix();
			glMatrixMode(GL_PROJECTION);
			GL11.glPopMatrix();
			glMatrixMode(GL_MODELVIEW);
			Shaders.checkGLError("shadow end");
			//----------
		}
	}

	public static void preRenderChunkLayer()
	{
		if (OpenGlHelper.useVbo()) {
			GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
			GL20.glEnableVertexAttribArray(Shaders.midTexCoordAttrib);
			GL20.glEnableVertexAttribArray(Shaders.tangentAttrib);
			GL20.glEnableVertexAttribArray(Shaders.entityAttrib);
		}
	}
	public static void postRenderChunkLayer()
	{
		if (OpenGlHelper.useVbo()) {
			GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
			GL20.glDisableVertexAttribArray(Shaders.midTexCoordAttrib);
			GL20.glDisableVertexAttribArray(Shaders.tangentAttrib);
			GL20.glDisableVertexAttribArray(Shaders.entityAttrib);
		}
	}
	public static void setupArrayPointersVbo()
	{
		final int vertexSizeI = SVertexFormat.vertexSizeBlock;
		GL11.glVertexPointer(3, GL11.GL_FLOAT, (vertexSizeI*4), 0L);
		GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, (vertexSizeI*4), 12L);
		GL11.glTexCoordPointer(2, GL11.GL_FLOAT, (vertexSizeI*4), 16L);
		OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
		GL11.glTexCoordPointer(2, GL11.GL_SHORT, (vertexSizeI*4), 24L);
		OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
		GL11.glNormalPointer(GL11.GL_BYTE, (vertexSizeI*4), 28L);
		GL20.glVertexAttribPointer(Shaders.midTexCoordAttrib, 2, GL11.GL_FLOAT, false, (vertexSizeI*4), SVertexFormat.offsetMidTexCoord*4);
		GL20.glVertexAttribPointer(Shaders.tangentAttrib, 4, GL11.GL_SHORT, false, (vertexSizeI*4), SVertexFormat.offsetTangent*4);
		GL20.glVertexAttribPointer(Shaders.entityAttrib, 3, GL11.GL_SHORT, false, (vertexSizeI*4), SVertexFormat.offsetEntity*4);
	}

	public static void beaconBeamBegin() {
		Shaders.useProgram(Shaders.ProgramBeaconBeam);
	}
	public static void beaconBeamStartQuad1() {
	}

	public static void beaconBeamStartQuad2() {
//		Tessellator tess = Tessellator.getInstance();
//		WorldRenderer wrr = tess.getWorldRenderer();
//		SVertexBuilder svb = Dummy.get_worldRenderer_sVertexBuilder(wrr);
//		wrr.setVertexFormat(DefaultVertexFormats.BLOCK);
//		wrr.setBrightness(240);
//        glActiveTexture(GL_TEXTURE1);
//        glBindTexture(GL_TEXTURE_2D,0);
//        glActiveTexture(GL_TEXTURE2);
//        glBindTexture(GL_TEXTURE_2D,0);
//        glActiveTexture(GL_TEXTURE3);
//        glBindTexture(GL_TEXTURE_2D,0);
//        glActiveTexture(GL_TEXTURE0);
	}

	public static void beaconBeamDraw1() {
	}

	public static void beaconBeamDraw2() {
		GlStateManager.disableBlend();
	}
	
	public static void layerArmorBaseDrawEnchantedGlintBegin() {
		Shaders.useProgram(Shaders.ProgramArmorGlint);
	}
	public static void layerArmorBaseDrawEnchantedGlintEnd() {
		Shaders.useProgram(Shaders.ProgramEntities);
	}
}

