Search in sources :

Example 1 with GL11.glTexParameteri

use of org.lwjgl.opengl.GL11.glTexParameteri in project LogisticsPipes by RS485.

the class GuiRequestTable method drawGuiContainerBackgroundLayer.

@Override
public void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    for (GuiButton sycleButton : sycleButtons) {
        sycleButton.visible = _table.targetType != null;
    }
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right - (showRequest ? 0 : 105), bottom, zLevel, true);
    drawRect(guiLeft + 162, guiTop + 23, guiLeft + 182, guiTop + 43, Color.BLACK);
    drawRect(guiLeft + 164, guiTop + 25, guiLeft + 180, guiTop + 41, Color.DARKER_GREY);
    if (showRequest) {
        mc.fontRenderer.drawString(_title, guiLeft + 180 + mc.fontRenderer.getStringWidth(_title) / 2, guiTop + 6, 0x404040);
        itemDisplay.renderPageNumber(right - 47, guiTop + 6);
        if (buttonList.get(9) instanceof GuiCheckBox && ((GuiCheckBox) buttonList.get(9)).getState()) {
            mc.fontRenderer.drawString("Popup", guiLeft + 225, bottom - 56, 0x404040);
        } else {
            mc.fontRenderer.drawString("Popup", guiLeft + 225, bottom - 56, Color.getValue(Color.GREY));
        }
        itemDisplay.renderAmount(right - 103, bottom - 24, getStackAmount());
        //SearchInput
        search.renderSearchBar();
        itemDisplay.renderSortMode(right - 103, bottom - 52);
        itemDisplay.renderItemArea(zLevel);
    }
    for (int x = 0; x < 9; x++) {
        for (int y = 0; y < 3; y++) {
            GuiGraphics.drawSlotBackground(mc, guiLeft + (x * 18) + 19, guiTop + (y * 18) + 79);
        }
    }
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            GuiGraphics.drawSlotBackground(mc, guiLeft + (x * 18) + 19, guiTop + (y * 18) + 14);
        }
    }
    mc.fontRenderer.drawString("Sort:", guiLeft + 136, guiTop + 55, 0xffffff);
    GuiGraphics.drawSlotBackground(mc, guiLeft + 100, guiTop + 32);
    GuiGraphics.drawSlotBackground(mc, guiLeft + 163, guiTop + 50);
    drawRect(guiLeft + 75, guiTop + 38, guiLeft + 95, guiTop + 43, Color.DARKER_GREY);
    for (int a = 0; a < 10; a++) {
        drawRect(guiLeft + 97 - a, guiTop + 40 - a, guiLeft + 98 - a, guiTop + 41 + a, Color.DARKER_GREY);
    }
    for (int a = 0; a < 15; a++) {
        drawRect(guiLeft + 164 + a, guiTop + 51 + a, guiLeft + 166 + a, guiTop + 53 + a, Color.DARKER_GREY);
        drawRect(guiLeft + 164 + a, guiTop + 65 - a, guiLeft + 166 + a, guiTop + 67 - a, Color.DARKER_GREY);
    }
    GuiGraphics.drawPlayerInventoryBackground(mc, guiLeft + 20, guiTop + 150);
    for (final Entry<Integer, Pair<IResource, LinkedLogisticsOrderList>> entry : _table.watchedRequests.entrySet()) {
        if (!handledExtention.get(entry.getKey())) {
            handledExtention.set(entry.getKey());
            extentionControllerLeft.addExtention(new GuiExtention() {

                private Map<Pair<Integer, Integer>, IOrderInfoProvider> ordererPosition = new HashMap<>();

                private int height;

                private int width = 4;

                private GuiButton localControlledButton;

                @SuppressWarnings("unchecked")
                @Override
                public void renderForground(int left, int top) {
                    if (!_table.watchedRequests.containsKey(entry.getKey())) {
                        extentionControllerLeft.removeExtention(this);
                        if (isFullyExtended() && localControlledButton != null) {
                            buttonList.remove(localControlledButton);
                            localControlledButton = null;
                            orderIdForButton = -1;
                        }
                        return;
                    }
                    ordererPosition.clear();
                    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
                    GL11.glEnable(GL11.GL_LIGHTING);
                    GL11.glEnable(GL11.GL_DEPTH_TEST);
                    RenderHelper.enableGUIStandardItemLighting();
                    ItemStack stack = null;
                    IResource resource = entry.getValue().getValue1();
                    String s = null;
                    if (resource != null) {
                        stack = resource.getDisplayItem().makeNormalStack();
                        GuiScreen.itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, getMC().renderEngine, stack, left + 5, top + 5);
                        GuiScreen.itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, getMC().renderEngine, stack, left + 5, top + 5, "");
                        s = StringUtils.getFormatedStackSize(stack.stackSize, false);
                    } else {
                        s = "List";
                    }
                    GL11.glDisable(GL11.GL_LIGHTING);
                    GL11.glDisable(GL11.GL_DEPTH_TEST);
                    GuiScreen.itemRender.zLevel = 0.0F;
                    // Draw number
                    mc.fontRenderer.drawStringWithShadow(s, left + 22 - mc.fontRenderer.getStringWidth(s), top + 14, 16777215);
                    if (isFullyExtended()) {
                        if (localControlledButton == null || orderIdForButton != entry.getKey()) {
                            if (localControlledButton != null) {
                                buttonList.remove(localControlledButton);
                            }
                            localControlledButton = new SmallGuiButton(100, guiLeft - 35, guiTop + 10, 30, 10, "more");
                            buttonList.add(localControlledButton);
                            orderIdForButton = entry.getKey();
                        }
                        List<IOrderInfoProvider> list = entry.getValue().getValue2().getList();
                        calculateSize(left, top, list);
                        String ident = "ID: " + Integer.toString(entry.getKey());
                        mc.fontRenderer.drawStringWithShadow(ident, left + 25, top + 7, 16777215);
                        int x = left + 6;
                        int y = top + 25;
                        for (IOrderInfoProvider order : list) {
                            stack = order.getAsDisplayItem().makeNormalStack();
                            if (stack.stackSize <= 0) {
                                continue;
                            }
                            GL11.glEnable(GL11.GL_LIGHTING);
                            GL11.glEnable(GL11.GL_DEPTH_TEST);
                            RenderHelper.enableGUIStandardItemLighting();
                            GuiScreen.itemRender.renderItemAndEffectIntoGUI(mc.fontRenderer, getMC().renderEngine, stack, x, y);
                            GuiScreen.itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, getMC().renderEngine, stack, x, y, "");
                            s = StringUtils.getFormatedStackSize(stack.stackSize, false);
                            GL11.glDisable(GL11.GL_LIGHTING);
                            GL11.glDisable(GL11.GL_DEPTH_TEST);
                            GuiScreen.itemRender.zLevel = 0.0F;
                            // Draw number
                            mc.fontRenderer.drawStringWithShadow(s, x + 17 - mc.fontRenderer.getStringWidth(s), y + 9, 16777215);
                            ordererPosition.put(new Pair<>(x, y), order);
                            x += 18;
                            if (x > left + getFinalWidth() - 18) {
                                x = left + 6;
                                y += 18;
                            }
                        }
                    } else if (isExtending()) {
                        List<IOrderInfoProvider> list = entry.getValue().getValue2().getList();
                        calculateSize(left, top, list);
                    }
                    if (!isFullyExtended() && localControlledButton != null) {
                        buttonList.remove(localControlledButton);
                        localControlledButton = null;
                        orderIdForButton = -1;
                    }
                    RenderHelper.disableStandardItemLighting();
                }

                private void calculateSize(int left, int top, List<IOrderInfoProvider> list) {
                    int x = left + 6;
                    int y = 50;
                    int line = 1;
                    width = 4;
                    for (IOrderInfoProvider order : list) {
                        ItemStack stack = order.getAsDisplayItem().makeNormalStack();
                        if (stack.stackSize <= 0) {
                            continue;
                        }
                        if (line++ % (4 * 4) == 0) {
                            width++;
                        }
                    }
                    for (IOrderInfoProvider order : list) {
                        ItemStack stack = order.getAsDisplayItem().makeNormalStack();
                        if (stack.stackSize <= 0) {
                            continue;
                        }
                        x += 18;
                        if (x > left + getFinalWidth() - 18) {
                            x = left + 6;
                            y += 18;
                        }
                    }
                    height = y;
                    if (x == left + 6) {
                        height -= 18;
                    }
                }

                @Override
                public int getFinalWidth() {
                    return Math.max(85, width * 18 + 8);
                }

                @Override
                public int getFinalHeight() {
                    return Math.max(50, height);
                }

                @Override
                public void handleMouseOverAt(int xPos, int yPos) {
                    if (isFullyExtended()) {
                        ordererPosition.keySet().stream().filter(key -> xPos >= key.getValue1() && xPos < key.getValue1() + 18 && yPos >= key.getValue2() && yPos < key.getValue2() + 18).forEach(key -> {
                            IOrderInfoProvider order = ordererPosition.get(key);
                            List<String> list = new ArrayList<>();
                            list.add(ChatColor.BLUE + "Request Type: " + ChatColor.YELLOW + order.getType().name());
                            list.add(ChatColor.BLUE + "Send to Router ID: " + ChatColor.YELLOW + order.getRouterId());
                            GuiGraphics.displayItemToolTip(new Object[] { xPos - 10, yPos, order.getAsDisplayItem().makeNormalStack(), true, list }, zLevel, guiLeft, guiTop, false);
                        });
                    } else {
                        List<String> list = new ArrayList<>();
                        list.add(ChatColor.BLUE + "Request ID: " + ChatColor.YELLOW + entry.getKey());
                        GuiGraphics.displayItemToolTip(new Object[] { xPos - 10, yPos, entry.getValue().getValue1().getDisplayItem().makeNormalStack(), true, list }, zLevel, guiLeft, guiTop, false);
                    }
                }
            });
        }
    }
    super.renderExtentions();
}
Also used : OpenGlHelper(net.minecraft.client.renderer.OpenGlHelper) CraftingCycleRecipe(logisticspipes.network.packets.block.CraftingCycleRecipe) IOrderInfoProvider(logisticspipes.routing.order.IOrderInfoProvider) LogisticsPipes(logisticspipes.LogisticsPipes) IItemSearch(logisticspipes.utils.gui.IItemSearch) GuiCheckBox(logisticspipes.utils.gui.GuiCheckBox) Keyboard(org.lwjgl.input.Keyboard) MainProxy(logisticspipes.proxy.MainProxy) SmallGuiButton(logisticspipes.utils.gui.SmallGuiButton) GuiExtention(logisticspipes.utils.gui.extention.GuiExtention) Configs(logisticspipes.config.Configs) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) ItemDisplay(logisticspipes.utils.gui.ItemDisplay) RequestMonitorPopup(logisticspipes.gui.popup.RequestMonitorPopup) Locale(java.util.Locale) Map(java.util.Map) GuiRequestPopup(logisticspipes.gui.popup.GuiRequestPopup) RenderHelper(net.minecraft.client.renderer.RenderHelper) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) GL12(org.lwjgl.opengl.GL12) GL11(org.lwjgl.opengl.GL11) RequestSubmitListPacket(logisticspipes.network.packets.orderer.RequestSubmitListPacket) OrdererRefreshRequestPacket(logisticspipes.network.packets.orderer.OrdererRefreshRequestPacket) ChainAddArrayList(logisticspipes.utils.ChainAddArrayList) LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) GuiButton(net.minecraft.client.gui.GuiButton) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) EnchantmentHelper(net.minecraft.enchantment.EnchantmentHelper) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) DummyContainer(logisticspipes.utils.gui.DummyContainer) Enchantment(net.minecraft.enchantment.Enchantment) ISpecialItemRenderer(logisticspipes.interfaces.ISpecialItemRenderer) HashMap(java.util.HashMap) Color(logisticspipes.utils.Color) RequestSubmitPacket(logisticspipes.network.packets.orderer.RequestSubmitPacket) StringUtils(logisticspipes.utils.string.StringUtils) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) RequestComponentPacket(logisticspipes.network.packets.orderer.RequestComponentPacket) GuiDiskPopup(logisticspipes.gui.popup.GuiDiskPopup) SearchBar(logisticspipes.utils.gui.SearchBar) DiskRequestConectPacket(logisticspipes.network.packets.orderer.DiskRequestConectPacket) ISubGuiControler(logisticspipes.utils.gui.ISubGuiControler) ChatColor(logisticspipes.utils.string.ChatColor) Iterator(java.util.Iterator) IChainAddList(logisticspipes.interfaces.IChainAddList) IResource(logisticspipes.request.resources.IResource) IDiskProvider(logisticspipes.interfaces.IDiskProvider) GuiScreen(net.minecraft.client.gui.GuiScreen) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ClearCraftingGridPacket(logisticspipes.network.packets.block.ClearCraftingGridPacket) BitSet(java.util.BitSet) GuiGraphics(logisticspipes.utils.gui.GuiGraphics) HashMap(java.util.HashMap) IOrderInfoProvider(logisticspipes.routing.order.IOrderInfoProvider) SmallGuiButton(logisticspipes.utils.gui.SmallGuiButton) GuiButton(net.minecraft.client.gui.GuiButton) SmallGuiButton(logisticspipes.utils.gui.SmallGuiButton) GuiCheckBox(logisticspipes.utils.gui.GuiCheckBox) GuiExtention(logisticspipes.utils.gui.extention.GuiExtention) ChainAddArrayList(logisticspipes.utils.ChainAddArrayList) LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) List(java.util.List) ArrayList(java.util.ArrayList) IChainAddList(logisticspipes.interfaces.IChainAddList) ItemStack(net.minecraft.item.ItemStack) IResource(logisticspipes.request.resources.IResource) Pair(logisticspipes.utils.tuples.Pair)

Example 2 with GL11.glTexParameteri

use of org.lwjgl.opengl.GL11.glTexParameteri in project LogisticsPipes by RS485.

the class RenderTickHandler method renderWorldLast.

//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
    if (LogisticsRenderPipe.config.isUseNewRenderer()) {
        if (displayPipeGhost()) {
            Minecraft mc = Minecraft.getMinecraft();
            EntityPlayer player = mc.thePlayer;
            MovingObjectPosition box = mc.objectMouseOver;
            if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
                ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
                CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
                int i = box.blockX;
                int j = box.blockY;
                int k = box.blockZ;
                World world = player.getEntityWorld();
                int side = box.sideHit;
                Block worldBlock = world.getBlock(i, j, k);
                if (worldBlock == Blocks.snow) {
                    side = 1;
                } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
                    if (side == 0) {
                        j--;
                    }
                    if (side == 1) {
                        j++;
                    }
                    if (side == 2) {
                        k--;
                    }
                    if (side == 3) {
                        k++;
                    }
                    if (side == 4) {
                        i--;
                    }
                    if (side == 5) {
                        i++;
                    }
                }
                double xCoord = i;
                double yCoord = j;
                double zCoord = k;
                boolean isFreeSpace = true;
                ITubeOrientation orientation = null;
                if (pipe instanceof CoreMultiBlockPipe) {
                    CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
                    DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
                    globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
                    LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
                    orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
                    if (orientation != null) {
                        orientation.rotatePositions(positions);
                        positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
                        globalPos.addToAll(orientation.getOffset());
                        for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
                            if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
                                TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
                                boolean canPlace = false;
                                if (tile instanceof LogisticsTileGenericSubMultiBlock) {
                                    if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
                                        canPlace = true;
                                    }
                                }
                                if (!canPlace) {
                                    isFreeSpace = false;
                                    break;
                                }
                            }
                        }
                    } else {
                        return;
                    }
                } else {
                    if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
                        isFreeSpace = false;
                    }
                }
                if (isFreeSpace) {
                    GL11.glPushMatrix();
                    double x;
                    double y;
                    double z;
                    if (orientation != null) {
                        x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    } else {
                        x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
                        y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
                        z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
                    }
                    GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
                    GL11.glEnable(GL11.GL_BLEND);
                    //GL11.glDepthMask(false);
                    GL11.glDisable(GL11.GL_TEXTURE_2D);
                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                    mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
                    Tessellator tess = Tessellator.instance;
                    CCRenderState.reset();
                    CCRenderState.useNormals = true;
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glEnable(GL11.GL_TEXTURE_2D);
                    CCRenderState.alphaOverride = 0x50;
                    CCRenderState.useNormals = true;
                    CCRenderState.hasBrightness = false;
                    CCRenderState.startDrawing();
                    pipe.getHighlightRenderer().renderHighlight(orientation);
                    tess.draw();
                    CCRenderState.alphaOverride = 0xff;
                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glDepthMask(true);
                    GL11.glPopMatrix();
                }
            }
        }
    }
}
Also used : ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) EventPriority(cpw.mods.fml.common.eventhandler.EventPriority) Blocks(net.minecraft.init.Blocks) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) LogisticsPipes(logisticspipes.LogisticsPipes) ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) RenderWorldLastEvent(net.minecraftforge.client.event.RenderWorldLastEvent) RenderTickEvent(cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) Minecraft(net.minecraft.client.Minecraft) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) ClientViewController(logisticspipes.routing.debug.ClientViewController) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) Core(tv.twitch.Core) GL11(org.lwjgl.opengl.GL11) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) CCRenderState(codechicken.lib.render.CCRenderState) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) CoordinateUtils(network.rs485.logisticspipes.world.CoordinateUtils) Phase(cpw.mods.fml.common.gameevent.TickEvent.Phase) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectType(net.minecraft.util.MovingObjectPosition.MovingObjectType) Tessellator(net.minecraft.client.renderer.Tessellator) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) ResourceLocation(net.minecraft.util.ResourceLocation) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Minecraft(net.minecraft.client.Minecraft) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) LPPositionSet(logisticspipes.utils.LPPositionSet) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with GL11.glTexParameteri

use of org.lwjgl.opengl.GL11.glTexParameteri in project BuildCraft by BuildCraft.

the class AdvDebuggerQuarry method render.

@Override
public void render(EntityPlayer player, float partialTicks) {
    TileQuarry tile = tileReference.get();
    if (tile == null || !tile.frameBox.isInitialized()) {
        return;
    }
    List<ChunkPos> chunkPoses = new ArrayList<>(ChunkLoaderManager.getChunksToLoad(tile));
    chunkPoses.sort(Comparator.comparingDouble(chunkPos -> -player.getPositionEyes(partialTicks).distanceTo(new Vec3d(chunkPos.getXStart() + 0.5 + (chunkPos.getXEnd() - chunkPos.getXStart()) / 2, player.getPositionEyes(partialTicks).y, chunkPos.getZStart() + 0.5 + (chunkPos.getZEnd() - chunkPos.getZStart()) / 2))));
    GlStateManager.enableBlend();
    BufferBuilder bb = Tessellator.getInstance().getBuffer();
    bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (ChunkPos chunkPos : chunkPoses) {
        DebugRenderHelper.renderAABB(bb, new AxisAlignedBB(chunkPos.getXStart() + 0.5D, tile.frameBox.min().getY() + 0.5D, chunkPos.getZStart() + 0.5D, chunkPos.getXEnd() + 0.5D, tile.frameBox.max().getY() + 0.5D, chunkPos.getZEnd() + 0.5D), COLOUR_CHUNK);
    }
    Tessellator.getInstance().draw();
    GlStateManager.disableBlend();
}
Also used : DebugRenderHelper(buildcraft.lib.debug.DebugRenderHelper) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) GlStateManager(net.minecraft.client.renderer.GlStateManager) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ChunkPos(net.minecraft.util.math.ChunkPos) ChunkLoaderManager(buildcraft.lib.chunkload.ChunkLoaderManager) DetachedRenderer(buildcraft.lib.client.render.DetachedRenderer) ArrayList(java.util.ArrayList) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) List(java.util.List) Tessellator(net.minecraft.client.renderer.Tessellator) Vec3d(net.minecraft.util.math.Vec3d) TileQuarry(buildcraft.builders.tile.TileQuarry) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GL11(org.lwjgl.opengl.GL11) WeakReference(java.lang.ref.WeakReference) Comparator(java.util.Comparator) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) ArrayList(java.util.ArrayList) ChunkPos(net.minecraft.util.math.ChunkPos) TileQuarry(buildcraft.builders.tile.TileQuarry) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with GL11.glTexParameteri

use of org.lwjgl.opengl.GL11.glTexParameteri in project LogisticsPipes by RS485.

the class OpenGLDebugger method updateNiceToHave.

private static void updateNiceToHave() {
    OpenGLDebugger.niceToHave = new HashMap<>();
    int crawlerVersion = 11;
    boolean almostEnd = false;
    boolean end = false;
    while (!end) {
        String packageGL = String.format("%s%d", "GL", crawlerVersion);
        String nextGL = String.format("%s.%s", "org.lwjgl.opengl", packageGL);
        try {
            crawlerVersion++;
            Class glClass = GL11.class.getClassLoader().loadClass(nextGL);
            com.google.common.reflect.Reflection.initialize(glClass);
            almostEnd = false;
            for (Field f : glClass.getDeclaredFields()) {
                try {
                    if (!f.getType().equals(int.class)) {
                        continue;
                    }
                    int id = f.getInt(null);
                    String nice = f.getName();
                    if (nice.endsWith("BIT")) {
                        continue;
                    }
                    // All the things that are being replaced are not that bad
                    if (OpenGLDebugger.niceToHave.containsKey(id) && !OpenGLDebugger.niceToHave.get(id).equals(nice)) {
                        System.out.printf("NiceToHave: ID %d exists. Replacing %s with %s!!%n", id, OpenGLDebugger.niceToHave.remove(id), nice);
                    }
                    OpenGLDebugger.niceToHave.put(id, String.format("%s.%s", packageGL, nice));
                } catch (IllegalArgumentException e) {
                    System.out.printf("NiceToHave: Illegal Argument!%nNiceToHave: %s%n", e);
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    System.out.printf("NiceToHave: Illegal Access!%nNiceToHave: %s%n", e);
                    e.printStackTrace();
                }
            }
        } catch (ClassNotFoundException e) {
            if (almostEnd) {
                end = true;
            } else {
                almostEnd = true;
                crawlerVersion = (crawlerVersion / 10 + 1) * 10;
            }
        }
    }
}
Also used : JTextField(javax.swing.JTextField) Field(java.lang.reflect.Field) GL11(org.lwjgl.opengl.GL11)

Example 5 with GL11.glTexParameteri

use of org.lwjgl.opengl.GL11.glTexParameteri in project chunkstories by Hugobros3.

the class GLFWGameWindow method displaySplashScreen.

@SuppressWarnings("unused")
private void displaySplashScreen() throws IOException {
    int texture = glGenTextures();
    InputStream is = getClass().getResourceAsStream("/splash.png");
    PNGDecoder decoder = new PNGDecoder(is);
    int width = decoder.getWidth();
    int height = decoder.getHeight();
    ByteBuffer temp = ByteBuffer.allocateDirect(4 * width * height);
    decoder.decode(temp, width * 4, Format.RGBA);
    is.close();
    // ChunkStoriesLogger.getInstance().log("decoded " + width + " by " + height + " pixels (" + name + ")", ChunkStoriesLogger.LogType.RENDERING, ChunkStoriesLogger.LogLevel.DEBUG);
    temp.flip();
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) temp);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    int shaderProgramId = glCreateProgram();
    int vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
    int fragShaderId = glCreateShader(GL_FRAGMENT_SHADER);
    String vertexSource = "#version 330\n\n\nin vec3 vertexIn;\nout vec2 texCoord;\nuniform float ratio;\n\nvoid main()\n{\ngl_Position = vec4(vertexIn.x*ratio, vertexIn.y, 0.0, 1.0);\ntexCoord = vertexIn.xy*0.5+0.5;\n}";
    String fragSource = "#version 330\nuniform sampler2D diffuseTexture;\n\nin vec2 texCoord;\nout vec4 fragColor;\n\nvoid main()\n{\nfragColor = texture(diffuseTexture, vec2(texCoord.x, 1.0-texCoord.y));\n}\n";
    // System.out.println(vertexSource);
    // System.out.println(fragSource);
    glShaderSource(vertexShaderId, vertexSource);
    glCompileShader(vertexShaderId);
    glBindFragDataLocation(shaderProgramId, 0, "fragColor");
    glShaderSource(fragShaderId, fragSource);
    glCompileShader(fragShaderId);
    glAttachShader(shaderProgramId, vertexShaderId);
    glAttachShader(shaderProgramId, fragShaderId);
    glLinkProgram(shaderProgramId);
    glUseProgram(shaderProgramId);
    int uniformLocation = glGetUniformLocation(shaderProgramId, "diffuseTexture");
    // glUniform2f(uniformLocation, ((Vector2fc)uniformData).x(), ((Vector2fc)uniformData).y());
    glUniform1i(uniformLocation, (Integer) 0);
    float ratio = (float) windowHeight / windowWidth;
    uniformLocation = glGetUniformLocation(shaderProgramId, "ratio");
    glUniform1f(uniformLocation, ratio);
    glValidateProgram(shaderProgramId);
    FloatBuffer fsQuadBuffer = BufferUtils.createFloatBuffer(6 * 2);
    fsQuadBuffer.put(new float[] { 1f, 1f, -1f, -1f, 1f, -1f, 1f, 1f, -1f, 1f, -1f, -1f });
    fsQuadBuffer.flip();
    int vertexBuffer = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, (FloatBuffer) fsQuadBuffer, GL_STATIC_DRAW);
    int location = glGetAttribLocation(shaderProgramId, "vertexIn");
    glEnableVertexAttribArray(location);
    glVertexAttribPointer(location, 2, GL_FLOAT, false, 0, 0L);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    // while(1 - Math.floor(1) == 0 && !glfwWindowShouldClose(glfwWindowHandle))
    {
        glClearColor(0.25f, 0.25f, 0.25f, 1f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        // Draw happens here
        glDrawArrays(GL_TRIANGLES, 0, 6);
        glfwSwapBuffers(glfwWindowHandle);
        glfwPollEvents();
    }
    glDisable(GL_BLEND);
    glDisableVertexAttribArray(location);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glDeleteBuffers(vertexBuffer);
    glBindTexture(GL_TEXTURE_2D, 0);
    glDeleteTextures(texture);
    glUseProgram(0);
    glDeleteProgram(shaderProgramId);
    glDeleteShader(vertexShaderId);
    glDeleteShader(fragShaderId);
    glClearColor(0.0f, 0.0f, 0.0f, 1f);
}
Also used : PNGDecoder(de.matthiasmann.twl.utils.PNGDecoder) InputStream(java.io.InputStream) FloatBuffer(java.nio.FloatBuffer) GL11.glGetString(org.lwjgl.opengl.GL11.glGetString) ByteBuffer(java.nio.ByteBuffer) GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.glfwWindowHint)

Aggregations

GL11 (org.lwjgl.opengl.GL11)6 List (java.util.List)4 ArrayList (java.util.ArrayList)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 IOException (java.io.IOException)2 ByteBuffer (java.nio.ByteBuffer)2 FloatBuffer (java.nio.FloatBuffer)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 LogisticsPipes (logisticspipes.LogisticsPipes)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 ItemStack (net.minecraft.item.ItemStack)2 TileQuarry (buildcraft.builders.tile.TileQuarry)1 BCCoreItems (buildcraft.core.BCCoreItems)1 ItemPaintbrush_BC8 (buildcraft.core.item.ItemPaintbrush_BC8)1 ChunkLoaderManager (buildcraft.lib.chunkload.ChunkLoaderManager)1 DetachedRenderer (buildcraft.lib.client.render.DetachedRenderer)1 DebugRenderHelper (buildcraft.lib.debug.DebugRenderHelper)1 GuiBC8 (buildcraft.lib.gui.GuiBC8)1