List of usage examples for org.lwjgl.opengl GL11 glScissor
public static void glScissor(@NativeType("GLint") int x, @NativeType("GLint") int y, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height)
From source file:de.johni0702.minecraft.gui.MinecraftGuiRenderer.java
License:MIT License
@Override public void setDrawingArea(int x, int y, int width, int height) { // glScissor origin is bottom left corner whereas otherwise it's top left y = size.getScaledHeight() - y - height; int f = size.getScaleFactor(); GL11.glScissor(x * f, y * f, width * f, height * f); }
From source file:de.mineformers.gui.api.component.container.UIWindow.java
License:LGPL
@Override public void draw(int mouseX, int mouseY) { this.drawRectangle(screenX, screenY, 31, 1, 5, 5); this.drawRectangle(screenX + width - 5, screenY, 39, 1, 5, 5); this.drawRectangle(screenX + width - 5, screenY + height - 5, 39, 9, 5, 5); this.drawRectangle(screenX, screenY + height - 5, 31, 9, 5, 5); // Sides clockwise this.drawRectangleStretched(screenX + 5, screenY, 37, 1, width - 10, 5, 1, 5); this.drawRectangleStretched(screenX + width - 5, screenY + 5, 39, 7, 5, height - 10, 5, 1); this.drawRectangleStretched(screenX + 5, screenY + height - 5, 37, 9, width - 10, 5, 1, 5); this.drawRectangleStretched(screenX, screenY + 5, 31, 7, 5, height - 10, 5, 1); // Canvas/*w ww . j a v a 2 s .co m*/ this.drawRectangleStretched(screenX + 5, screenY + 5, 37, 7, width - 10, height - 10, 1, 1); int scale = RenderHelper.computeGuiScale(); if (layout != null) { GL11.glScissor((screenX + padding.left) * scale, mc.displayHeight - (screenY + height - padding.bottom) * scale, (width - padding.right - padding.left) * scale, (height - padding.bottom - padding.top) * scale); GL11.glEnable(GL11.GL_SCISSOR_TEST); layout.setScreenPos(screenX + padding.left, screenY + padding.top); layout.draw(mouseX, mouseY); GL11.glDisable(GL11.GL_SCISSOR_TEST); layout.drawTooltips(mouseX, mouseY); } int left = 0; int right = 0; for (UIInfoTab tab : infoTabs) { if (tab.getOrientation() == Orientation.HORIZONTAL_RIGHT) { tab.setScreenPos(screenX + width, screenY + 5 + right); right += tab.getHeight() + 2; } else { tab.setScreenPos(screenX - tab.getWidth(), screenY + 5 + left); left += tab.getHeight() + 2; } GL11.glColor4f(1, 1, 1, 1); tab.draw(mouseX, mouseY); } for (UIInfoTab tab : infoTabs) { if (tab.isClosedAndHovered(mouseX, mouseY)) { UITooltip tooltip = new UITooltip(); tooltip.addLine(tab.getTitle()); tooltip.draw(mouseX, mouseY); } } }
From source file:de.mineformers.gui.api.util.RenderHelper.java
License:LGPL
public static void drawRectangleXRepeated(ResourceLocation texture, int x, int y, float u, float v, float uvWidth, float uvHeight, int width, int height, int zLevel) { RenderHelper.bindTexture(texture);/*from w w w . ja va 2s .com*/ float f = 0.00390625F; float f1 = 0.00390625F; if (u % 1 != 0) f = 1; if (v % 1 != 0) f1 = 1; Tessellator tessellator = Tessellator.instance; boolean flipX = width < 0; if (flipX) width *= -1; int numX = (int) Math.ceil((float) width / uvWidth); int scale = RenderHelper.computeGuiScale(); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor((x) * scale, getMC().displayHeight - (y + height) * scale, width * scale, height * scale); for (int x2 = 0; x2 < numX; ++x2) { float xOffset = x2 * uvWidth; if (flipX) xOffset = width - (x2 + 1) * uvWidth; tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double) (x + xOffset), (double) (y + height), (double) zLevel, (double) ((float) (u) * f), (double) (v + uvHeight) * f1); tessellator.addVertexWithUV((double) (x + uvWidth + xOffset), (double) (y + height), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + uvWidth + xOffset), (double) (y), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v) * f1)); tessellator.addVertexWithUV((double) (x + xOffset), (double) (y), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v) * f1)); tessellator.draw(); } GL11.glDisable(GL11.GL_SCISSOR_TEST); }
From source file:de.mineformers.gui.api.util.RenderHelper.java
License:LGPL
public static void drawRectangleYRepeated(ResourceLocation texture, int x, int y, float u, float v, float uvWidth, float uvHeight, int width, int height, int zLevel) { RenderHelper.bindTexture(texture);//from w w w.j a v a2s. c om float f = 0.00390625F; float f1 = 0.00390625F; if (u % 1 != 0) f = 1; if (v % 1 != 0) f1 = 1; Tessellator tessellator = Tessellator.instance; boolean flipY = height < 0; if (flipY) height *= -1; int numY = (int) Math.ceil((float) height / uvHeight); int scale = RenderHelper.computeGuiScale(); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor((x) * scale, getMC().displayHeight - (y + height) * scale, width * scale, height * scale); for (int y2 = 0; y2 < numY; ++y2) { float yOffset = y2 * uvHeight; if (flipY) yOffset = height - (y2 + 1) * uvHeight; tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double) (x), (double) (y + uvHeight + yOffset), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + width), (double) (y + uvHeight + yOffset), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + width), (double) (y + yOffset), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v) * f1)); tessellator.addVertexWithUV((double) (x), (double) (y + yOffset), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v) * f1)); tessellator.draw(); } GL11.glDisable(GL11.GL_SCISSOR_TEST); }
From source file:de.mineformers.robots.client.gui.util.RenderHelper.java
License:LGPL
public static void drawRectangleXRepeated(ResourceLocation texture, int x, int y, float u, float v, float uvWidth, float uvHeight, int width, int height, int zLevel) { RenderHelper.bindTexture(texture);//from ww w .ja v a 2 s .com float f = 0.00390625F; float f1 = 0.00390625F; if ((u != 0 && u % 1 != 0)) f = 1; if ((v != 0 && v % 1 != 0)) f1 = 1; Tessellator tessellator = Tessellator.instance; boolean flipX = width < 0; if (flipX) width *= -1; int numX = (int) Math.ceil((float) width / uvWidth); int scale = RenderHelper.computeGuiScale(); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor((x) * scale, getMC().displayHeight - (y + height) * scale, width * scale, height * scale); for (int x2 = 0; x2 < numX; ++x2) { float xOffset = x2 * uvWidth; if (flipX) xOffset = width - (x2 + 1) * uvWidth; tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double) (x + xOffset), (double) (y + height), (double) zLevel, (double) ((float) (u) * f), (double) (v + uvHeight) * f1); tessellator.addVertexWithUV((double) (x + uvWidth + xOffset), (double) (y + height), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + uvWidth + xOffset), (double) (y), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v) * f1)); tessellator.addVertexWithUV((double) (x + xOffset), (double) (y), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v) * f1)); tessellator.draw(); } GL11.glDisable(GL11.GL_SCISSOR_TEST); }
From source file:de.mineformers.robots.client.gui.util.RenderHelper.java
License:LGPL
public static void drawRectangleYRepeated(ResourceLocation texture, int x, int y, float u, float v, float uvWidth, float uvHeight, int width, int height, int zLevel) { RenderHelper.bindTexture(texture);/*from w ww .j a v a 2 s . co m*/ float f = 0.00390625F; float f1 = 0.00390625F; if ((u != 0 && u % 1 != 0)) f = 1; if ((v != 0 && v % 1 != 0)) f1 = 1; Tessellator tessellator = Tessellator.instance; boolean flipY = height < 0; if (flipY) height *= -1; int numY = (int) Math.ceil((float) height / uvHeight); int scale = RenderHelper.computeGuiScale(); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor((x) * scale, getMC().displayHeight - (y + height) * scale, width * scale, height * scale); for (int y2 = 0; y2 < numY; ++y2) { float yOffset = y2 * uvHeight; if (flipY) yOffset = height - (y2 + 1) * uvHeight; tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double) (x), (double) (y + uvHeight + yOffset), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + width), (double) (y + uvHeight + yOffset), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v + uvHeight) * f1)); tessellator.addVertexWithUV((double) (x + width), (double) (y + yOffset), (double) zLevel, (double) ((float) (u + uvWidth) * f), (double) ((float) (v) * f1)); tessellator.addVertexWithUV((double) (x), (double) (y + yOffset), (double) zLevel, (double) ((float) (u) * f), (double) ((float) (v) * f1)); tessellator.draw(); } GL11.glDisable(GL11.GL_SCISSOR_TEST); }
From source file:de.sanandrew.core.manpack.util.client.helpers.GuiUtils.java
License:Creative Commons License
public static void doGlScissor(int x, int y, int width, int height) { Minecraft mc = Minecraft.getMinecraft(); int scaleFactor = 1; int k = mc.gameSettings.guiScale; if (k == 0) { k = 1000;// w ww. j a v a 2s. c o m } while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { ++scaleFactor; } GL11.glScissor(x * scaleFactor, mc.displayHeight - (y + height) * scaleFactor, width * scaleFactor, height * scaleFactor); }
From source file:de.sanandrew.mods.sanlib.lib.client.util.GuiUtils.java
License:Creative Commons License
/** * A wrapper method for {@link GL11#glScissor(int, int, int, int)} that corrects position and respects the GUI scaling of Minecraft.<br> * Unlike glScissor, the starting position of the scissor box is the top left corner instead of the bottom left corner. * @param x The X coordinate of the starting position for the scissor box. * @param y The Y coordinate of the starting position for the scissor box. * @param width The width of the scissor box. * @param height The height of the scissor box. *//* w ww .jav a 2 s.co m*/ public static void glScissor(int x, int y, int width, int height) { Minecraft mc = Minecraft.getMinecraft(); int scaleFactor = 1; int guiScale = mc.gameSettings.guiScale; if (guiScale == 0) { guiScale = 1000; } while (scaleFactor < guiScale && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { ++scaleFactor; } GL11.glScissor(x * scaleFactor, mc.displayHeight - (y + height) * scaleFactor, width * scaleFactor, height * scaleFactor); }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * The only method that you should implement by yourself. * * @see javax.media.openGL11.GLEventListener#display(javax.media.openGL11.GLAutoDrawable) *//*from w w w . j av a 2 s . c om*/ public void display() { GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (V3DCameraBinding binding : cameraList) { GL11.glViewport(binding.x, binding.y, binding.width, binding.height); //Clean Background I3dColor color = binding.camera.getBackgroundColor(); GL11.glClearColor(color.r, color.g, color.b, color.a); GL11.glScissor(binding.x, binding.y, binding.width, binding.height); GL11.glEnable(GL11.GL_SCISSOR_TEST); if (color.a == 1.0f) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); } else { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glOrtho(0, binding.width, 0, binding.height, -2000.0, 2000.0); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0, 0, 0); GL11.glVertex3f(binding.width, 0, 0); GL11.glVertex3f(binding.width, binding.height, 0); GL11.glVertex3f(0, binding.height, 0); GL11.glEnd(); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); } GL11.glDisable(GL11.GL_SCISSOR_TEST); binding.camera.display(binding.width, binding.height); GL11.glDisable(GL11.GL_DEPTH_TEST); // binding.getGui().display(); GL11.glEnable(GL11.GL_DEPTH_TEST); if (select && binding == focusCamera) { GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); //glu.gluPerspective(45.0f, h, 0.1, 2000.0); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); binding.camera.select(mouseX, mouseY); context.setMouseOverCameraBinding(binding); } } GL11.glFlush(); select = false; }
From source file:hellfirepvp.astralsorcery.client.gui.GuiHandTelescope.java
License:Open Source License
private Optional<Map<StarLocation, Rectangle>> drawCellEffect(int offsetX, int offsetY, int width, int height, float partialTicks, float transparency) { GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_BLEND);//from w ww . j a va 2 s . com Blending.DEFAULT.apply(); GL11.glDisable(GL11.GL_ALPHA_TEST); WorldSkyHandler handle = ConstellationSkyHandler.getInstance() .getWorldHandler(Minecraft.getMinecraft().world); int lastTracked = handle == null ? 5 : handle.lastRecordedDay; Random r = new Random(); RenderAstralSkybox.TEX_STAR_1.bind(); for (StarPosition stars : usedStars) { r.setSeed(stars.seed); GL11.glPushMatrix(); float brightness = 0.3F + (RenderConstellation.stdFlicker(ClientScheduler.getClientTick(), partialTicks, 10 + r.nextInt(20))) * 0.6F; brightness *= Minecraft.getMinecraft().world.getStarBrightness(partialTicks) * 2 * transparency; brightness *= (1F - Minecraft.getMinecraft().world.getRainStrength(partialTicks)); GL11.glColor4f(brightness, brightness, brightness, brightness); drawRect(MathHelper.floor(offsetX + stars.x), MathHelper.floor(offsetY + stars.y), 5, 5); GL11.glColor4f(1, 1, 1, 1); GL11.glPopMatrix(); } r.setSeed(lastTracked * 31); Map<StarLocation, Rectangle> rectangles = null; if (topFound != null) { zLevel += 1; float playerYaw = Minecraft.getMinecraft().player.rotationYaw % 360F; if (playerYaw < 0) { playerYaw += 360F; } if (playerYaw >= 180F) { playerYaw -= 360F; } float playerPitch = Minecraft.getMinecraft().player.rotationPitch; float diffYaw = playerYaw - selectedYaw; float diffPitch = playerPitch - selectedPitch; float sFactor = 35F; if ((Math.abs(diffYaw) <= sFactor || Math.abs(playerYaw + 360F) <= sFactor) && Math.abs(diffPitch) <= sFactor) { ScaledResolution res = new ScaledResolution(mc); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor((guiLeft + 5) * res.getScaleFactor(), (guiTop + 5) * res.getScaleFactor(), (guiWidth - 10) * res.getScaleFactor(), (guiHeight - 10) * res.getScaleFactor()); int wPart = ((int) (((float) width) * 0.1F)); int hPart = ((int) (((float) height) * 0.1F)); rectangles = RenderConstellation.renderConstellationIntoGUI(topFound, offsetX + wPart + MathHelper.floor((diffYaw / sFactor) * width), offsetY + hPart + MathHelper.floor((diffPitch / sFactor) * height), zLevel, width - (((int) (wPart * 1.5F))), height - (((int) (hPart * 1.5F))), 2, new RenderConstellation.BrightnessFunction() { @Override public float getBrightness() { return (0.3F + 0.7F * RenderConstellation.conCFlicker(ClientScheduler.getClientTick(), partialTicks, 5 + r.nextInt(15))) * transparency; } }, ResearchManager.clientProgress.hasConstellationDiscovered(topFound.getUnlocalizedName()), true); GL11.glDisable(GL11.GL_SCISSOR_TEST); } zLevel -= 1; } GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glPopAttrib(); return Optional.ofNullable(rectangles); }