Java Code Examples for net.minecraft.client.renderer.GlStateManager#enableTexture2D()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#enableTexture2D() . 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: CustomCrosshairGraphics.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void drawLine(final int x1, final int y1, final int x2, final int y2,
                            final Color colour) {
    final Tessellator tessellator = Tessellator.getInstance();
    final WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GlStateManager
        .color(colour.getRed() / 255.0f, colour.getGreen() / 255.0f, colour.getBlue() / 255.0f,
            colour.getAlpha() / 255.0f);
    worldrenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
    worldrenderer.pos(x1, y1, 0.0).endVertex();
    worldrenderer.pos(x2, y2, 0.0).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
Example 2
Source File: GuiItemHandlerDestination.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
private static void drawRedCross(int x, int y){
    int size = 16;
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    GlStateManager.disableTexture2D();
    GlStateManager.disableDepth();
    GlStateManager.color(1, 0, 0);
    bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);

    bufferBuilder.pos(x, y + 1, 0.0D).endVertex();
    bufferBuilder.pos(x + size - 1, y + size, 0.0D).endVertex();
    bufferBuilder.pos(x + size, y + size - 1, 0.0D).endVertex();
    bufferBuilder.pos(x + 1, y, 0.0D).endVertex();

    bufferBuilder.pos(x, y + size - 1, 0.0D).endVertex();
    bufferBuilder.pos(x + 1, y + size, 0.0D).endVertex();
    bufferBuilder.pos(x + size, y + 1, 0.0D).endVertex();
    bufferBuilder.pos(x + size - 1, y, 0.0D).endVertex();

    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.enableDepth();
}
 
Example 3
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 4
Source File: GuiScrollable.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	if (!isVisible() || (getMaxScroll(direction) == 0)) return;
	
	int sliderSize = getSliderSize();
	int sliderPosition = (int)(getSliderRaw() * (getSize(direction) - sliderSize));
	int x, y, w, h;
	if (direction == Direction.HORIZONTAL) {
		x = sliderPosition; y = 0;
		w = sliderSize; h = getHeight();
	} else {
		x = 0; y = sliderPosition;
		w = getWidth(); h = sliderSize;
	}
	
	GlStateManager.disableTexture2D();
	drawColoredRectRGB(0, 0, getWidth(), getHeight(), Color.BLACK);
	drawColoredRectRGB(x, y, w, h, 0x808080);
	drawColoredRectRGB(x, y, w - 1, h - 1, 0xC0C0C0);
	GlStateManager.enableTexture2D();
}
 
Example 5
Source File: AboveHeadRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderName(RenderPlayerEvent event, LevelheadTag tag, EntityPlayer player, double x, double y, double z) {
    FontRenderer fontrenderer = event.getRenderManager().getFontRenderer();
    float f = (float) (1.6F * Levelhead.getInstance().getDisplayManager().getMasterConfig().getFontSize());
    float f1 = 0.016666668F * f;
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x + 0.0F, (float) y + player.height + 0.5F, (float) z);
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-event.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(event.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(-f1, -f1, f1);
    GlStateManager.disableLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    int i = 0;

    int j = fontrenderer.getStringWidth(tag.getString()) / 2;
    GlStateManager.disableTexture2D();
    worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();

    renderString(fontrenderer, tag);

    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}
 
Example 6
Source File: Notification.java    From ClientBase with MIT License 5 votes vote down vote up
public static void drawRect(double left, double top, double right, double bottom, int color) {
    if (left < right) {
        double i = left;
        left = right;
        right = i;
    }

    if (top < bottom) {
        double j = top;
        top = bottom;
        bottom = j;
    }

    float f3 = (float) (color >> 24 & 255) / 255.0F;
    float f = (float) (color >> 16 & 255) / 255.0F;
    float f1 = (float) (color >> 8 & 255) / 255.0F;
    float f2 = (float) (color & 255) / 255.0F;
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.color(f, f1, f2, f3);
    worldrenderer.begin(7, DefaultVertexFormats.POSITION);
    worldrenderer.pos(left, bottom, 0.0D).endVertex();
    worldrenderer.pos(right, bottom, 0.0D).endVertex();
    worldrenderer.pos(right, top, 0.0D).endVertex();
    worldrenderer.pos(left, top, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
Example 7
Source File: TabGui.java    From ClientBase with MIT License 5 votes vote down vote up
public static void drawRect(int glFlag, int left, int top, int right, int bottom, int color) {
    if (left < right) {
        int i = left;
        left = right;
        right = i;
    }

    if (top < bottom) {
        int j = top;
        top = bottom;
        bottom = j;
    }

    float f3 = (float) (color >> 24 & 255) / 255.0F;
    float f = (float) (color >> 16 & 255) / 255.0F;
    float f1 = (float) (color >> 8 & 255) / 255.0F;
    float f2 = (float) (color & 255) / 255.0F;
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.color(f, f1, f2, f3);
    worldrenderer.begin(glFlag, DefaultVertexFormats.POSITION);
    worldrenderer.pos((double) left, (double) bottom, 0.0D).endVertex();
    worldrenderer.pos((double) right, (double) bottom, 0.0D).endVertex();
    worldrenderer.pos((double) right, (double) top, 0.0D).endVertex();
    worldrenderer.pos((double) left, (double) top, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
Example 8
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void renderSchematicOverlay()
{
    boolean invert = Hotkeys.INVERT_OVERLAY_RENDER_STATE.getKeybind().isKeybindHeld();

    if (Configs.Visuals.ENABLE_SCHEMATIC_OVERLAY.getBooleanValue() != invert)
    {
        boolean renderThrough = Configs.Visuals.SCHEMATIC_OVERLAY_RENDER_THROUGH.getBooleanValue() || Hotkeys.RENDER_OVERLAY_THROUGH_BLOCKS.getKeybind().isKeybindHeld();
        float lineWidth = (float) (renderThrough ? Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH_THROUGH.getDoubleValue() : Configs.Visuals.SCHEMATIC_OVERLAY_OUTLINE_WIDTH.getDoubleValue());

        GlStateManager.pushMatrix();
        GlStateManager.disableTexture2D();
        GlStateManager.disableCull();
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.001F);
        GlStateManager.enablePolygonOffset();
        GlStateManager.doPolygonOffset(-0.4f, -0.8f);
        fi.dy.masa.malilib.render.RenderUtils.setupBlend();
        GlStateManager.glLineWidth(lineWidth);
        fi.dy.masa.malilib.render.RenderUtils.color(1f, 1f, 1f, 1f);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);

        if (renderThrough)
        {
            GlStateManager.disableDepth();
        }

        this.getWorldRenderer().renderBlockOverlays();

        GlStateManager.enableDepth();
        GlStateManager.doPolygonOffset(0f, 0f);
        GlStateManager.disablePolygonOffset();
        GlStateManager.enableTexture2D();
        GlStateManager.popMatrix();
    }
}
 
Example 9
Source File: MaterialListHudRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void renderSlotHilights(GuiContainer gui)
{
    MaterialListBase materialList = DataManager.getMaterialList();

    if (materialList != null)
    {
        materialList.getHudRenderer().refreshList(2000L);
        List<MaterialListEntry> list = materialList.getMaterialsMissingOnly(false);

        if (list.isEmpty() == false)
        {
            HashMap<ItemType, MaterialListEntry> map = new HashMap<>();
            list.forEach((entry) -> map.put(entry.getItemType(), entry));
            List<Pair<Slot, Color4f>> hilightedSlots = getHilightedSlots(gui, map);

            if (hilightedSlots.isEmpty() == false)
            {
                GlStateManager.disableTexture2D();
                RenderUtils.setupBlend();
                int guiX = InventoryScreenUtils.getGuiPosX(gui);
                int guiY = InventoryScreenUtils.getGuiPosY(gui);

                for (Pair<Slot, Color4f> pair : hilightedSlots)
                {
                    Slot slot = pair.getLeft();
                    Color4f color = pair.getRight();
                    RenderUtils.drawOutlinedBox(guiX + slot.xPos, guiY + slot.yPos, 16, 16, color.intValue, color.intValue | 0xFF000000, 1f);
                }

                GlStateManager.enableTexture2D();
            }
        }
    }
}
 
Example 10
Source File: CustomCrosshairGraphics.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawFilledRectangle(int x1, int y1, int x2, int y2, final Color colour) {
    if (x1 < x2) {
        final int tempX = x1;
        x1 = x2;
        x2 = tempX;
    }
    if (y1 < y2) {
        final int tempY = y1;
        y1 = y2;
        y2 = tempY;
    }
    final Tessellator tessellator = Tessellator.getInstance();
    final WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GlStateManager
        .color(colour.getRed() / 255.0f, colour.getGreen() / 255.0f, colour.getBlue() / 255.0f,
            colour.getAlpha() / 255.0f);
    worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
    worldrenderer.pos(x1, y2, 0.0).endVertex();
    worldrenderer.pos(x2, y2, 0.0).endVertex();
    worldrenderer.pos(x2, y1, 0.0).endVertex();
    worldrenderer.pos(x1, y1, 0.0).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
Example 11
Source File: RenderEventService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRenderWorld(RenderWorldLastEvent event) {
  GlStateManager.pushMatrix();
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  GlStateManager.disableDepth();
  
  GlStateManager.glLineWidth(1.f);
  
  Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks());
  
  RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks());
  e.resetTranslation();
  MinecraftForge.EVENT_BUS.post(e);
  
  GlStateManager.glLineWidth(1.f);
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 12
Source File: Utils.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Draws a solid color rectangle with the specified coordinates and color (ARGB format). Args: x1, y1, x2, y2, color
 */
public void drawRect(double left, double top, double right, double bottom, int color) {
    if (left < right) {
        double i = left;
        left = right;
        right = i;
    }

    if (top < bottom) {
        double j = top;
        top = bottom;
        bottom = j;
    }

    float f3 = (float)(color >> 24 & 255) / 255.0F;
    float f = (float)(color >> 16 & 255) / 255.0F;
    float f1 = (float)(color >> 8 & 255) / 255.0F;
    float f2 = (float)(color & 255) / 255.0F;
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    GlStateManager.enableBlend();
    GlStateManager.disableTexture2D();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.color(f, f1, f2, f3);
    worldrenderer.begin(7, DefaultVertexFormats.POSITION);
    worldrenderer.pos(left, bottom, 0.0D).endVertex();
    worldrenderer.pos(right, bottom, 0.0D).endVertex();
    worldrenderer.pos(right, top, 0.0D).endVertex();
    worldrenderer.pos(left, top, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
Example 13
Source File: ClientEventHandler.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onWorldRender(RenderWorldLastEvent event){
    Tessellator t = Tessellator.getInstance();
    BufferBuilder b = t.getBuffer();

    EntityPlayer player = Minecraft.getMinecraft().player;
    if(!shouldRender()) return;

    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks();
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks();
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks();
    int dimensionID = player.world.provider.getDimension();
    GL11.glPushMatrix();
    GL11.glTranslated(-playerX, -playerY, -playerZ);

    GL11.glPointSize(10);

    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    b.setTranslation(0, 0, 0);

    NetworkVisualizationSettings visualizationSettings = player.isSneaking() ? SignalsConfig.client.networkVisualization.sneaking : SignalsConfig.client.networkVisualization.notSneaking;
    switch(visualizationSettings.renderType){
        case EDGES:
            edgeRenderer.render(dimensionID, b);
            break;
        case PATHS:
            pathRenderer.render(dimensionID, b);
            break;
        case SECTION:
            blockSectionRenderer.render(dimensionID, b);
            break;
    }
    //claimRenderer.render(b);
    if(visualizationSettings.renderDirectionality) {
        directionalityRenderer.render(dimensionID, b);
    }

    b.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

    List<NetworkStation<MCPos>> stations = RailNetworkManager.getClientInstance().getNetwork().railObjects.getStations();
    for(int i = 0; i < stations.size(); i++) {
        NetworkStation<MCPos> station1 = stations.get(i);
        if(station1.getPos().getDimID() != dimensionID) continue;
        for(int j = 0; j < i; j++) {
            NetworkStation<MCPos> station2 = stations.get(j);
            if(station2.getPos().getDimID() != dimensionID) continue;

            if(station1.stationName.equals(station2.stationName) && station1.getPos().getDimID() == station2.getPos().getDimID()) {
                drawBetween(b, station1.getPos().getPos(), station2.getPos().getPos(), 1, 0, 1, 0, 1);
            }
        }
    }

    t.draw();

    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();
    GL11.glPopMatrix();
}
 
Example 14
Source File: RenderUtils.java    From ForgeHax with MIT License 4 votes vote down vote up
public static void drawBox(
    Vec3d startPos, Vec3d endPos, int color, float width, boolean ignoreZ) {
  Tessellator tessellator = Tessellator.getInstance();
  BufferBuilder buffer = tessellator.getBuffer();
  
  Vec3d renderPos = EntityUtils.getInterpolatedPos(getLocalPlayer(), MC.getRenderPartialTicks());
  
  Vec3d min = startPos.subtract(renderPos);
  Vec3d max = endPos.subtract(renderPos);
  
  double minX = min.x, minY = min.y, minZ = min.z;
  double maxX = max.x, maxY = max.y, maxZ = max.z;
  
  float r = (float) (color >> 16 & 255) / 255.0F;
  float g = (float) (color >> 8 & 255) / 255.0F;
  float b = (float) (color & 255) / 255.0F;
  float a = (float) (color >> 24 & 255) / 255.0F;
  
  GlStateManager.pushMatrix();
  GlStateManager.disableTexture2D();
  GlStateManager.enableBlend();
  GlStateManager.disableAlpha();
  GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
  GlStateManager.shadeModel(GL11.GL_SMOOTH);
  GlStateManager.glLineWidth(width);
  
  if (ignoreZ) {
    GlStateManager.disableDepth();
  }
  
  GlStateManager.color(r, g, b, a);
  
  // GlStateManager.translate(startPos.xCoord, startPos.yCoord, startPos.zCoord);
  
  buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
  buffer.pos(minX, minY, minZ).endVertex();
  buffer.pos(maxX, minY, minZ).endVertex();
  buffer.pos(maxX, minY, maxZ).endVertex();
  buffer.pos(minX, minY, maxZ).endVertex();
  buffer.pos(minX, minY, minZ).endVertex();
  tessellator.draw();
  buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
  buffer.pos(minX, maxY, minZ).endVertex();
  buffer.pos(maxX, maxY, minZ).endVertex();
  buffer.pos(maxX, maxY, maxZ).endVertex();
  buffer.pos(minX, maxY, maxZ).endVertex();
  buffer.pos(minX, maxY, minZ).endVertex();
  tessellator.draw();
  buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
  buffer.pos(minX, minY, minZ).endVertex();
  buffer.pos(minX, maxY, minZ).endVertex();
  buffer.pos(maxX, minY, minZ).endVertex();
  buffer.pos(maxX, maxY, minZ).endVertex();
  buffer.pos(maxX, minY, maxZ).endVertex();
  buffer.pos(maxX, maxY, maxZ).endVertex();
  buffer.pos(minX, minY, maxZ).endVertex();
  buffer.pos(minX, maxY, maxZ).endVertex();
  tessellator.draw();
  
  GlStateManager.shadeModel(GL11.GL_FLAT);
  GlStateManager.disableBlend();
  GlStateManager.enableAlpha();
  GlStateManager.enableTexture2D();
  GlStateManager.enableDepth();
  GlStateManager.enableCull();
  GlStateManager.popMatrix();
}
 
Example 15
Source File: TextureHelper.java    From malmo with MIT License 4 votes vote down vote up
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
    // Adapted from the End sky renderer - just fill with solid colour.
    GlStateManager.disableFog();
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableTexture2D();
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();

    for (int i = 0; i < 6; ++i)
    {
        GlStateManager.pushMatrix();

        if (i == 1)
        {
            GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 2)
        {
            GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 3)
        {
            GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
        }

        if (i == 4)
        {
            GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
        }

        if (i == 5)
        {
            GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
        }

        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
        vertexbuffer.pos(-100.0D, -100.0D, -100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(-100.0D, -100.0D, 100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(100.0D, -100.0D, 100.0D).color(this.r, this.g, this.b, 255).endVertex();
        vertexbuffer.pos(100.0D, -100.0D, -100.0D).color(this.r, this.g, this.b, 255).endVertex();
        tessellator.draw();
        GlStateManager.popMatrix();
    }

    GlStateManager.depthMask(true);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
}
 
Example 16
Source File: Texture.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
public void render(float x, float y, float width, float height, float u, float v, float t, float s) {
    this.bind();
    GlStateManager.enableTexture2D();
    GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
    RenderUtil.drawTexture(x, y, width, height, 0, 0, 1, 1);
}
 
Example 17
Source File: TESRBarrel.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderFullnessBar(float fullness, double x, double y, double z, EnumFacing side, EnumFacing barrelFront)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);

    if (side == EnumFacing.UP || side == EnumFacing.DOWN)
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0);
        GlStateManager.rotate(90f * side.getYOffset(), 1, 0, 0);
    }
    else
    {
        GlStateManager.rotate(LABEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0);
    }

    GlStateManager.translate(-0.3, -0.43, -0.001);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();

    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);

    int r_b = 0x03;
    int g_b = 0x03;
    int b_b = 0x20;

    buffer.pos(  0,    0, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(  0, 0.08, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(0.6, 0.08, 0).color(r_b, g_b, b_b, 255).endVertex();
    buffer.pos(0.6,    0, 0).color(r_b, g_b, b_b, 255).endVertex();

    int r_f = 0x20;
    int g_f = 0x90;
    int b_f = 0xF0;
    float e = fullness * 0.57f;

    buffer.pos(0.585    , 0.065, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585    , 0.015, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585 - e, 0.015, -0.001).color(r_f, g_f, b_f, 255).endVertex();
    buffer.pos(0.585 - e, 0.065, -0.001).color(r_f, g_f, b_f, 255).endVertex();

    tessellator.draw();

    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();

    GlStateManager.popMatrix();
}
 
Example 18
Source File: GuiVertTextField.java    From pycode-minecraft with MIT License 4 votes vote down vote up
/**
 * Draws the current selection and a vertical line cursor in the text box.
 */
private void drawCursorVertical(int startX, int startY, int endX, int endY)
{
    if (startX < endX)
    {
        int i = startX;
        startX = endX;
        endX = i;
    }

    if (startY < endY)
    {
        int j = startY;
        startY = endY;
        endY = j;
    }

    if (endX > this.xPosition + this.width)
    {
        endX = this.xPosition + this.width;
    }

    if (startX > this.xPosition + this.width)
    {
        startX = this.xPosition + this.width;
    }

    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F);
    GlStateManager.disableTexture2D();
    GlStateManager.enableColorLogic();
    GlStateManager.colorLogicOp(GlStateManager.LogicOp.OR_REVERSE);
    vertexbuffer.begin(7, DefaultVertexFormats.POSITION);
    vertexbuffer.pos((double)startX, (double)endY, 0.0D).endVertex();
    vertexbuffer.pos((double)endX, (double)endY, 0.0D).endVertex();
    vertexbuffer.pos((double)endX, (double)startY, 0.0D).endVertex();
    vertexbuffer.pos((double)startX, (double)startY, 0.0D).endVertex();
    tessellator.draw();
    GlStateManager.disableColorLogic();
    GlStateManager.enableTexture2D();
}
 
Example 19
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderItemStack(ItemStack stack) {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.enableRescaleNormal();

	GlStateManager.pushMatrix();

	RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
	itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);

	GlStateManager.translate(0, 0, 150);

	FontRenderer font = stack.getItem().getFontRenderer(stack);
	if (font == null) font = Minecraft.getMinecraft().fontRenderer;

	if (font != null && stack.getCount() != 1) {
		GlStateManager.translate(0, 0, 5);
		GlStateManager.disableLighting();
		GlStateManager.disableBlend();
		font.drawStringWithShadow(stack.getCount() + "",
				17F - font.getStringWidth(stack.getCount() + ""),
				9F,
				0xFFFFFF);
		GlStateManager.enableDepth();
		GlStateManager.enableBlend();
		GlStateManager.translate(0, 0, -5);
	}

	if (stack.getItem().showDurabilityBar(stack)) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		GlStateManager.disableAlpha();
		GlStateManager.disableBlend();
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferbuilder = tessellator.getBuffer();
		double health = stack.getItem().getDurabilityForDisplay(stack);
		int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
		int i = Math.round(13.0F - (float) health * 13.0F);
		draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
		draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
		GlStateManager.enableBlend();
		GlStateManager.enableAlpha();
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}


	EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
	float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());

	if (f3 > 0.0F) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		Tessellator tessellator1 = Tessellator.getInstance();
		BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
		this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}

	GlStateManager.popMatrix();

	GlStateManager.enableLighting();
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableRescaleNormal();
}
 
Example 20
Source File: GuiComponentSideSelector.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void render(int offsetX, int offsetY, int mouseX, int mouseY) {
	if (isInInitialPosition == false || Mouse.isButtonDown(2)) {
		final Entity rve = parent.getMinecraft().getRenderViewEntity();
		trackball.setTransform(MathUtils.createEntityRotateMatrix(rve));
		isInInitialPosition = true;
	}

	final int width = getWidth();
	final int height = getWidth();
	// assumption: block is rendered in (0,0,0) - (1,1,1) coordinates
	GL11.glPushMatrix();
	GL11.glTranslatef(offsetX + x + width / 2, offsetY + y + height / 2, diameter);
	GL11.glScaled(scale, -scale, scale);
	trackball.update(mouseX - width, -(mouseY - height));

	parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	GlStateManager.enableTexture2D();

	if (te != null) TileEntityRendererDispatcher.instance.render(te, -0.5, -0.5, -0.5, 0.0F);

	parent.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	if (blockState != null) drawBlock();

	SidePicker picker = new SidePicker(0.5);

	List<Pair<Side, Integer>> selections = Lists.newArrayListWithCapacity(6 + 1);
	final HitCoord coord = picker.getNearestHit();
	if (coord != null) selections.add(Pair.of(coord.side, 0x444444));

	if (highlightSelectedSides) {
		for (EnumFacing dir : selectedSides)
			selections.add(Pair.of(Side.fromForgeDirection(dir), 0xCC0000));
	}

	if (selections != null) drawHighlight(selections);

	lastSideHovered = coord == null? null : coord.side.toForgeDirection();

	GL11.glPopMatrix();
}