net.minecraft.client.renderer.OpenGlHelper Java Examples

The following examples show how to use net.minecraft.client.renderer.OpenGlHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GTRenderDisplayScreen.java    From GT-Classic with GNU Lesser General Public License v3.0 9 votes vote down vote up
@Override
public void render(GTTileDisplayScreen screen, double x, double y, double z, float partialTicks, int destroyStage,
		float alpha) {
	if (screen != null && screen.shouldDraw) {
		FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
		GlStateManager.pushMatrix();
		screen.applyRotation((float) x, (float) y, (float) z);
		screen.applySize(2.5F, 4D, 4D, -0.001D);
		int bright = 0xF0;
		int brightX = bright % 65536;
		int brightY = bright / 65536;
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY);
		int i = 0;
		for (String text : screen.information.getWrapperList()) {
			i++;
			if (i > 8) {
				break;
			}
			renderer.drawString(text, (int) x + 10, (int) (y - 2) + (10 * i), Color.CYAN.getRGB());
		}
		GlStateManager.popMatrix();
	}
}
 
Example #2
Source File: FramebufferBlitter.java    From OpenModsLib with MIT License 6 votes vote down vote up
public static boolean setup() {
	if (OpenGlHelper.framebufferSupported) {
		final ContextCapabilities caps = GLContext.getCapabilities();

		if (caps.OpenGL30) {
			Log.debug("Using OpenGL 3.0 FB blit");
			INSTANCE = new GL30Impl();
			return true;
		}

		if (caps.GL_EXT_framebuffer_blit) {
			Log.debug("Using EXT FB blit");
			INSTANCE = new ExtImpl();
			return true;
		}
	}

	Log.debug("FB blit not supported");
	return false;
}
 
Example #3
Source File: TextureHelper.java    From malmo with MIT License 6 votes vote down vote up
public static int createProgram(String shader)
{
    int prog = -1;
    try
    {
        int f_shader = loadShader(shader + ".fsh", OpenGlHelper.GL_FRAGMENT_SHADER);
        int v_shader = loadShader(shader + ".vsh", OpenGlHelper.GL_VERTEX_SHADER);
        prog = OpenGlHelper.glCreateProgram();
        OpenGlHelper.glAttachShader(prog, v_shader);
        OpenGlHelper.glAttachShader(prog, f_shader);
        OpenGlHelper.glLinkProgram(prog);
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    return prog;
}
 
Example #4
Source File: VboRenderListSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderChunkLayer(BlockRenderLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderChunk : this.renderChunks)
        {
            this.renderBlocks(renderChunk.getVertexBufferByLayer(layer.ordinal()), renderChunk);
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();

        this.renderChunks.clear();
    }
}
 
Example #5
Source File: VboRenderListSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderBlockOverlays(OverlayRenderType type)
{
    if (this.initialized)
    {
        for (RenderChunkSchematicVbo renderChunk : this.overlayRenderChunks)
        {
            this.renderOverlay(renderChunk.getOverlayVertexBuffer(type), renderChunk, type.getGlMode());
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();

        this.overlayRenderChunks.clear();
    }
}
 
Example #6
Source File: TextureHelper.java    From malmo with MIT License 6 votes vote down vote up
@Override
public void renderWorld(float partialTicks, long finishTimeNano)
{
    if (isProducingColourMap)
    {
        // Creating a colourmap requires a completely separate pass through the render pipeline
        colourmapFrame = true;
        // Set the sky renderer to produce a solid block of colour:
        Minecraft.getMinecraft().world.provider.setSkyRenderer(blankSkyRenderer);
        // Render the world:
        super.renderWorld(partialTicks, finishTimeNano);
        // Now reset the sky renderer to default:
        Minecraft.getMinecraft().world.provider.setSkyRenderer(null);
        colourmapFrame = false;
        // And get the render pipeline ready to go again:
        OpenGlHelper.glUseProgram(0);
        GlStateManager.clear(16640);
        Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
        GlStateManager.enableTexture2D();
    }
    // Normal render:
    super.renderWorld(partialTicks, finishTimeNano);
}
 
Example #7
Source File: RenderChunkSchematicVbo.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public RenderChunkSchematicVbo(World worldIn, RenderGlobal renderGlobalIn, int indexIn)
{
    super(worldIn, renderGlobalIn, indexIn);

    this.renderGlobal = (RenderGlobalSchematic) renderGlobalIn;
    this.chunkRenderDataLock = new ReentrantLock();
    this.schematicChunkRenderData = CompiledChunkSchematic.EMPTY;

    if (OpenGlHelper.useVbo())
    {
        for (int i = 0; i < OverlayRenderType.values().length; ++i)
        {
            this.vertexBufferOverlay[i] = new VertexBuffer(DefaultVertexFormats.POSITION_COLOR);
        }
    }
}
 
Example #8
Source File: PlayerSpecials.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void renderExtras(EntityPlayer player, boolean post) {
	if (!post) {
		GL11.glPushMatrix();
		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
		if (player.isSneaking()) {
			GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F);
		}
		boolean armor = player.getCurrentArmor(1) != null;
		GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
		GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
		GL11.glTranslatef(-0.25F, -0.85F, armor ? 0.2F : 0.28F);
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		GL11.glColor3f(1.0F, 1.0F, 1.0F);
		int light = 0xF000F0;
		int lightmapX = light % 0x10000;
		int lightmapY = light / 0x10000;
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);

		IIcon icon = toRender.getIconIndex();
		ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 1.0F / 16.0F);
		GL11.glPopMatrix();
	}
}
 
Example #9
Source File: GuiSurgery.java    From Cyberware with MIT License 6 votes vote down vote up
public void renderModel(ModelBase model, float x, float y, float scale, float rotation)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, 120F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(10.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	float f1 = 0.7F;
	GlStateManager.glLightModel(2899, RenderHelper.setColorBuffer(f1, f1, f1, 1.0F));
	model.render(null, 0, 0, 0, 0, 0, .0625f);
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
	GlStateManager.enableTexture2D();

}
 
Example #10
Source File: RenderEnderminy.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public void doRenderLayer(EntityEnderminy em, float p_177201_2_, float p_177201_3_, float p_177201_4_, float p_177201_5_, float p_177201_6_,
    float p_177201_7_, float p_177201_8_) {

  bindTexture(endermanEyesTexture);
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
  GlStateManager.disableLighting();
  GlStateManager.depthMask(!em.isInvisible());
  int i = 61680;
  int j = i % 65536;
  int k = i / 65536;
  OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
  GlStateManager.enableLighting();
  GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  getMainModel().render(em, p_177201_2_, p_177201_3_, p_177201_5_, p_177201_6_, p_177201_7_, p_177201_8_);
  setLightmap(em);
  GlStateManager.depthMask(true);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();

}
 
Example #11
Source File: GuiSurgery.java    From Cyberware with MIT License 6 votes vote down vote up
public void renderEntity(Entity entity, float x, float y, float scale, float rotation)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate(x, y, 50.0F);
	GlStateManager.scale(-scale, scale, scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
	Minecraft.getMinecraft().getRenderManager().doRenderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
	GlStateManager.enableTexture2D();
}
 
Example #12
Source File: MoCRenderFirefly.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the glowing belly
 */
protected int setTailBrightness(MoCEntityFirefly entityliving, int par2, float par3)
{
    if (par2 != 0)
    {
        return -1;
    }
    else
    {
        this.loadTexture(MoCreatures.proxy.MODEL_TEXTURE + "fireflyglow.png");
        float var4 = 1.0F;
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
        char var5 = 61680;
        int var6 = var5 % 65536;
        int var7 = var5 / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) var6 / 1.0F, (float) var7 / 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, var4);
        return 1;
    }
}
 
Example #13
Source File: GuiHudEditor.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onGuiClosed() {
    Seppuku.INSTANCE.getConfigManager().saveAll();

    final HudEditorModule mod = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class);

    if (mod != null) {
        if (mod.blur.getValue()) {
            if (OpenGlHelper.shadersSupported) {
                mc.entityRenderer.stopUseShader();
            }
        }
    }

    for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) {
        if (component instanceof DraggableHudComponent) {
            if (component.isVisible()) {
                final DraggableHudComponent draggable = (DraggableHudComponent) component;
                if (draggable.isDragging())
                    draggable.setDragging(false);
            }
        }
    }
}
 
Example #14
Source File: HudEditorModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onToggle() {
    super.onToggle();
    final Minecraft mc = Minecraft.getMinecraft();

    if (mc.world != null) {
        mc.displayGuiScreen(new GuiHudEditor());

        if(this.blur.getValue()) {
            if (OpenGlHelper.shadersSupported) {
                mc.entityRenderer.loadShader(new ResourceLocation("minecraft", "shaders/post/blur.json"));
            }
        }
        this.open = true;
    }
}
 
Example #15
Source File: Widget.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.0F, 32.0F);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableLighting();
    RenderHelper.enableGUIStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(itemStack, x, y);
    itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableLighting();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    GlStateManager.disableDepth();
}
 
Example #16
Source File: RenderCyberZombie.java    From Cyberware with MIT License 5 votes vote down vote up
public void doRenderLayer(T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
	if (entitylivingbaseIn.isBrute())
	{
		this.czRenderer.bindTexture(HIGHLIGHT_BRUTE);
	}
	else
	{
		this.czRenderer.bindTexture(HIGHLIGHT);
	}
	GlStateManager.enableBlend();
	//GlStateManager.disableAlpha();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);

	if (entitylivingbaseIn.isInvisible())
	{
		GlStateManager.depthMask(false);
	}
	else
	{
		GlStateManager.depthMask(true);
	}

	int i = 61680;
	int j = i % 65536;
	int k = i / 65536;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	this.czRenderer.getMainModel().render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
	i = entitylivingbaseIn.getBrightnessForRender(partialTicks);
	j = i % 65536;
	k = i / 65536;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
	this.czRenderer.setLightmap(entitylivingbaseIn, partialTicks);
	GlStateManager.disableBlend();
	GlStateManager.enableAlpha();
}
 
Example #17
Source File: LayerGlowEye.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public void doRenderLayer(T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    this.render.bindTexture(EYE_TEXTURE);
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);

    if (entitylivingbaseIn.isInvisible()) {
        GlStateManager.depthMask(false);
    } else {
        GlStateManager.depthMask(true);
    }

    int i = 50680;
    int j = i % 65536;
    int k = i / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    Minecraft.getMinecraft().entityRenderer.setupFogColor(true);
    this.render.getMainModel().render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
    Minecraft.getMinecraft().entityRenderer.setupFogColor(false);
    i = entitylivingbaseIn.getBrightnessForRender();
    j = i % 65536;
    k = i / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
    this.render.setLightmap(entitylivingbaseIn);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
}
 
Example #18
Source File: FxLaserHeat.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder worldRendererIn, Entity entityIn,
		float partialTicks, float rotationX, float rotationZ,
		float rotationYZ, float rotationXY, float rotationXZ) {
	//worldRendererIn.finishDrawing();
	
	float x = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX);
	float y = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY);
	float z = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ);
	
	int i = this.getBrightnessForRender(0);
	int j = i >> 16 & 65535;
	int k = i & 65535;
	
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, 0, 0);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
	
	BufferBuilder buffer = Tessellator.getInstance().getBuffer();
	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL);
	GlStateManager.color(0.8f, 0.2f, 0.2f, particleAlpha);
	

	double size = this.size*particleAlpha;
	RenderHelper.renderCube(buffer, x - size, y - size, z - size, x + size, y + size, z + size);
	
	
	Tessellator.getInstance().draw();
	
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_LIGHTING);
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 0, 0);
	GlStateManager.color(1, 1, 1, 1);
	GL11.glLineWidth(1);
}
 
Example #19
Source File: LuminanceProducerImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void getFrame(MissionInit missionInit, ByteBuffer buffer)
{
    final int width = getWidth();
    final int height = getHeight();

    // Render the Minecraft frame into our own FBO, at the desired size:
    OpenGlHelper.glUseProgram(shaderID);
    this.fbo.bindFramebuffer(true);
    Minecraft.getMinecraft().getFramebuffer().framebufferRenderExt(width, height, true);
    GlStateManager.bindTexture(this.fbo.framebufferTexture);
    GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL_RED, GL_UNSIGNED_BYTE, buffer);
    this.fbo.unbindFramebuffer();
    OpenGlHelper.glUseProgram(0);
}
 
Example #20
Source File: RenderButtonUIEntity.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void doRender(EntityUIButton entity, double x, double y, double z,
		float entityYaw, float partialTicks) {

	GL11.glPushMatrix();
	GL11.glTranslated(0, -.25, 0);
	

	RenderHelper.renderTag(Minecraft.getMinecraft().player.getDistanceSqToEntity(entity), "Up a level", x,y,z, 8);
	GL11.glPopMatrix();

	//Clean up and make player not transparent
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 0, 0);
}
 
Example #21
Source File: LayerEnderFighterEyes.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void doRenderLayer(EntityEndermanFighter entityEnderFighter, float p_177201_2, float p_177201_3, float partialTicks, float p_177201_5_, float p_177201_6_, float p_177201_7_, float scale)
{
    if (entityEnderFighter.isRaging())
    {
        this.renderEnderFighter.bindTexture(TEXTURE_EYES_RAGING);
    }
    else
    {
        this.renderEnderFighter.bindTexture(TEXTURE_EYES_NORMAL);
    }

    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.blendFunc(1, 1);
    GlStateManager.disableLighting();
    GlStateManager.depthMask(entityEnderFighter.isInvisible() == false);

    char c0 = 61680;
    int i = c0 % 65536;
    int j = c0 / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i / 1.0F, (float)j / 1.0F);
    GlStateManager.enableLighting();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    this.renderEnderFighter.getMainModel().render(entityEnderFighter, p_177201_2, p_177201_3, p_177201_5_, p_177201_6_, p_177201_7_, scale);
    this.renderEnderFighter.setLightmap(entityEnderFighter);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
}
 
Example #22
Source File: MobileChunkRenderer.java    From archimedes-ships with MIT License 5 votes vote down vote up
/**
 * Render this TileEntity at its current position from the player
 */
public void renderTileEntity(TileEntity tileentity, float partialticks)
{
	int i = chunk.getLightBrightnessForSkyBlocks(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 0);
	int j = i % 65536;
	int k = i / 65536;
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
	GL11.glColor4f(1F, 1F, 1F, 1F);
	TileEntityRendererDispatcher.instance.renderTileEntityAt(tileentity, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, partialticks);
}
 
Example #23
Source File: RenderWitherCat.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public void doRenderLayer(EntityWitherCat cat, float p_177201_2_, float p_177201_3_, float p_177201_4_, float p_177201_5_, float p_177201_6_,
    float p_177201_7_, float p_177201_8_) {

  float blendFactor = 1.0F;
  float scale = cat.getScale();
  blendFactor = 1 - (cat.getAngryScale() - scale);

  if (blendFactor > 0) {
    bindTexture(angryTexture);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);

    GL14.glBlendColor(1.0f, 1.0f, 1.0f, blendFactor);

    GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
    GL11.glPolygonOffset(-1, -1);

    char c0 = 61680;
    int j = c0 % 65536;
    int k = c0 / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j / 1.0F, k / 1.0F);
    GL11.glEnable(GL11.GL_LIGHTING);

    getMainModel().render(cat, p_177201_2_, p_177201_3_, p_177201_5_, p_177201_6_, p_177201_7_, p_177201_8_);
    setLightmap(cat);
  }

}
 
Example #24
Source File: GuiScroll.java    From VersionChecker with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6)
{
    int f = (par5 >> 24 & 255);
    float f1 = (float)(par5 >> 16 & 255) / 255.0F;
    float f2 = (float)(par5 >> 8 & 255) / 255.0F;
    float f3 = (float)(par5 & 255) / 255.0F;
    int f4 = (par6 >> 24 & 255);
    float f5 = (float)(par6 >> 16 & 255) / 255.0F;
    float f6 = (float)(par6 >> 8 & 255) / 255.0F;
    float f7 = (float)(par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); //POSITION_TEX_COLOR?
    buffer.pos((double)par3, (double)par2, 0.0D).color(f1, f2, f3, f).endVertex();
    buffer.pos((double)par1, (double)par2, 0.0D).color(f1, f2, f3, f).endVertex();
    buffer.pos((double)par1, (double)par4, 0.0D).color(f5, f6, f7, f4).endVertex();
    buffer.pos((double)par3, (double)par4, 0.0D).color(f5, f6, f7, f4).endVertex();
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #25
Source File: CachedRendererFactory.java    From OpenModsLib with MIT License 5 votes vote down vote up
public CachedRenderer createRenderer(Tessellator tes) {
	if (OpenGlHelper.useVbo()) {
		return new VboRenderer(tes);
	} else {
		return new DisplayListRenderer(tes);
	}
}
 
Example #26
Source File: GuiPeripheral.java    From AgriCraft with MIT License 5 votes vote down vote up
public void drawButton(Minecraft minecraft, int x, int y) {
    if (this.visible) {
        FontRenderer fontrenderer = minecraft.fontRenderer;
        minecraft.getTextureManager().bindTexture(BUTTON_TEXTURES);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
        int k = this.getHoverState(this.isMouseOver());
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        int vOffset = isActive() ? 86 : 46 + k * 20;
        this.drawTexturedModalRect(this.x, this.y, 0, vOffset, this.width / 2, this.height);
        this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, vOffset, this.width / 2, this.height);
        this.mouseDragged(minecraft, x, y);
        int l = 14737632;
        if (packedFGColour != 0) {
            l = packedFGColour;
        } else if (!this.enabled) {
            l = 10526880;
        } else if (this.hovered) {
            l = 16777120;
        }
        float scale = 0.6F;
        GL11.glScalef(scale, scale, scale);
        this.drawCenteredString(fontrenderer, this.displayString, (int) ((this.x + this.width / 2) / scale), (int) ((this.y + (this.height - 4) / 2) / scale), l);
        GL11.glScalef(1 / scale, 1 / scale, 1 / scale);
    }
}
 
Example #27
Source File: TextureHelper.java    From malmo with MIT License 5 votes vote down vote up
public static void setIsProducingColourMap(boolean usemap)
{
    if (usemap && !isInitialised)
        init();
    isProducingColourMap = usemap;
    if (!usemap)
        OpenGlHelper.glUseProgram(0);
}
 
Example #28
Source File: TextureHelper.java    From malmo with MIT License 5 votes vote down vote up
public static int loadShader(String filename, int shaderType) throws IOException
{
    int shaderID = -1;
    InputStream stream = MalmoMod.class.getClassLoader().getResourceAsStream(filename);
    if (stream == null)
    {
        System.out.println("Cannot find shader.");
        return -1;
    }
    try
    {
        byte[] abyte = IOUtils.toByteArray((InputStream) (new BufferedInputStream(stream)));
        ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
        bytebuffer.put(abyte);
        bytebuffer.position(0);
        shaderID = OpenGlHelper.glCreateShader(shaderType);
        OpenGlHelper.glShaderSource(shaderID, bytebuffer);
        OpenGlHelper.glCompileShader(shaderID);

        if (OpenGlHelper.glGetShaderi(shaderID, OpenGlHelper.GL_COMPILE_STATUS) == 0)
        {
            String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(shaderID, 32768));
            JsonException jsonexception = new JsonException("Couldn\'t compile shader program: " + s);
            throw jsonexception;
        }
    }
    finally
    {
        IOUtils.closeQuietly(stream);
    }
    return shaderID;
}
 
Example #29
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 5 votes vote down vote up
private void setLightmap()
{
	AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
	int i = this.mc.theWorld.getCombinedLight(new BlockPos(abstractclientplayer.posX, abstractclientplayer.posY + (double)abstractclientplayer.getEyeHeight(), abstractclientplayer.posZ), 0);
	float f = (float)(i & 65535);
	float f1 = (float)(i >> 16);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, f, f1);
}
 
Example #30
Source File: GuiInventoryExpandedCrafting.java    From Cyberware with MIT License 5 votes vote down vote up
public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent)
{
	GlStateManager.enableColorMaterial();
	GlStateManager.pushMatrix();
	GlStateManager.translate((float)posX, (float)posY, 50.0F);
	GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
	GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
	float f = ent.renderYawOffset;
	float f1 = ent.rotationYaw;
	float f2 = ent.rotationPitch;
	float f3 = ent.prevRotationYawHead;
	float f4 = ent.rotationYawHead;
	GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
	RenderHelper.enableStandardItemLighting();
	GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
	GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
	ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
	ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
	ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
	ent.rotationYawHead = ent.rotationYaw;
	ent.prevRotationYawHead = ent.rotationYaw;
	GlStateManager.translate(0.0F, 0.0F, 0.0F);
	RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
	rendermanager.setPlayerViewY(180.0F);
	rendermanager.setRenderShadow(false);
	rendermanager.doRenderEntity(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
	rendermanager.setRenderShadow(true);
	ent.renderYawOffset = f;
	ent.rotationYaw = f1;
	ent.rotationPitch = f2;
	ent.prevRotationYawHead = f3;
	ent.rotationYawHead = f4;
	GlStateManager.popMatrix();
	RenderHelper.disableStandardItemLighting();
	GlStateManager.disableRescaleNormal();
	GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
	GlStateManager.disableTexture2D();
	GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}