Example usage for org.lwjgl.opengl GL11 glScissor

List of usage examples for org.lwjgl.opengl GL11 glScissor

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glScissor.

Prototype

public static void glScissor(@NativeType("GLint") int x, @NativeType("GLint") int y,
        @NativeType("GLsizei") int width, @NativeType("GLsizei") int height) 

Source Link

Document

Defines the scissor rectangle for all viewports.

Usage

From source file:hellfirepvp.astralsorcery.client.gui.GuiJournalProgression.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    GL11.glPushMatrix();//from  www.j av  a 2  s  .co  m
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    int cleanedX = mouseX - guiLeft;
    int cleanedY = mouseY - guiTop;

    if (Mouse.isButtonDown(0) && progressionRenderer.realRenderBox.isInBox(cleanedX, cleanedY)) {
        if (dragging) {
            progressionRenderer.moveMouse(-(cleanedX - bufX), -(cleanedY - bufY));
        } else {
            bufX = cleanedX;
            bufY = cleanedY;
            dragging = true;
        }
    } else {
        progressionRenderer.applyMovedMouseOffset();
        dragging = false;
    }

    //Zooming stuff.
    int dWheelChange = Mouse.getDWheel();
    if (dWheelChange < 0) {
        progressionRenderer.handleZoomOut();
    }
    if (dWheelChange > 0) {
        progressionRenderer.handleZoomIn();
    }

    ScaledResolution res = new ScaledResolution(mc);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((guiLeft + 27) * res.getScaleFactor(), (guiTop + 27) * res.getScaleFactor(),
            (guiWidth - 54) * res.getScaleFactor(), (guiHeight - 54) * res.getScaleFactor());
    progressionRenderer.drawProgressionPart(zLevel);
    GL11.glDisable(GL11.GL_SCISSOR_TEST);

    drawDefault(textureResShell);

    Rectangle guiStar = null;
    if (!ResearchManager.clientProgress.wasOnceAttuned()) {
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        guiStar = IGuiRenderablePage.GUI_INTERFACE.drawInfoStar(guiLeft + guiWidth - 39, guiTop + 23, zLevel,
                15, partialTicks);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    zLevel += 150;
    drawMouseHighlight(zLevel, getCurrentMousePoint(), guiStar);
    zLevel -= 150;

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java

License:Open Source License

/**
 * Active the scissors mode to limit the render area.
 * /*  w  ww .  j a va 2 s.  c o m*/
 * @param x the x coordinate of the location of the render area
 * @param y the y coordinate of the location of the render area
 * @param width the width of the scissor area
 * @param height the height of the scissor area
 * @see illarion.graphics.RenderDisplay#setAreaLimit(int, int, int, int)
 */
@Override
public void setAreaLimit(final int x, final int y, final int width, final int height) {
    final Rectangle newRect = Rectangle.getInstance();
    final Rectangle newRectRaw = Rectangle.getInstance();

    newRect.set(x, y, width, height);
    newRectRaw.set(x, y, width, height);

    if (areaLimits.isEmpty()) {
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
    } else {
        newRect.intersect(areaLimits.getLast());
    }
    GL11.glPushMatrix();
    GL11.glScissor(newRect.getLeft(), newRect.getBottom(), newRect.getWidth(), newRect.getHeight());

    if (!areaLimits.isEmpty()) {
        final Rectangle lastRect = areaLimitsRaw.getLast();
        GL11.glTranslatef(newRectRaw.getX() - lastRect.getX(), newRectRaw.getY() - lastRect.getY(), 0);
    } else {
        GL11.glTranslatef(newRectRaw.getX(), newRectRaw.getY(), 0);
    }
    areaLimits.addLast(newRect);
    areaLimitsRaw.addLast(newRectRaw);
}

From source file:illarion.graphics.lwjgl.RenderDisplayLWJGL.java

License:Open Source License

/**
 * Disable the scissors mode that limits the render area.
 * //from  w w  w  .jav a2 s  . c o  m
 * @see illarion.graphics.RenderDisplay#unsetAreaLimit()
 */
@Override
public void unsetAreaLimit() {
    areaLimits.removeLast().recycle();
    areaLimitsRaw.removeLast().recycle();

    if (areaLimits.isEmpty()) {
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    } else {
        final Rectangle lastRect = areaLimits.getLast();
        GL11.glScissor(lastRect.getLeft(), lastRect.getBottom(), lastRect.getWidth(), lastRect.getHeight());
    }
    GL11.glPopMatrix();
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glScissor(int x, int y, int width, int height) {
    GL11.glScissor(x, y, width, height);
}

From source file:jake2.desktop.LWJGLAdapter.java

License:Open Source License

@Override
public void glScissor(int x, int y, int width, int height) {
    GL11.glScissor(x, y, width, height);
}

From source file:joazlazer.mods.amc.client.gui.GuiScrollingList.java

License:Open Source License

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();

    boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth && mouseY >= this.top
            && mouseY <= this.bottom;
    int listLength = this.getSize();
    int scrollBarWidth = 6;
    int scrollBarRight = this.left + this.listWidth;
    int scrollBarLeft = scrollBarRight - scrollBarWidth;
    int entryLeft = this.left;
    int entryRight = scrollBarLeft - 1;
    int viewHeight = this.bottom - this.top;
    int border = 4;

    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            if (isHovering) {
                int mouseListY = mouseY - this.top - this.headerHeight + (int) this.scrollDistance - border;
                int slotIndex = mouseListY / this.slotHeight;

                if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0
                        && slotIndex < listLength) {
                    this.elementClicked(slotIndex, slotIndex == this.selectedIndex
                            && System.currentTimeMillis() - this.lastClickTime < 250L);
                    this.selectedIndex = slotIndex;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0) {
                    this.clickHeader(mouseX - entryLeft,
                            mouseY - this.top + (int) this.scrollDistance - border);
                }//from  ww w. j  ava 2s. c o m

                if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight) {
                    this.scrollFactor = -1.0F;
                    int scrollHeight = this.getContentHeight() - viewHeight - border;
                    if (scrollHeight < 1)
                        scrollHeight = 1;

                    int var13 = (int) ((float) (viewHeight * viewHeight) / (float) this.getContentHeight());

                    if (var13 < 32)
                        var13 = 32;
                    if (var13 > viewHeight - border * 2)
                        var13 = viewHeight - border * 2;

                    this.scrollFactor /= (float) (viewHeight - var13) / (float) scrollHeight;
                } else {
                    this.scrollFactor = 1.0F;
                }

                this.initialMouseClickY = mouseY;
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        this.initialMouseClickY = -1.0F;
    }

    this.applyScrollLimits();

    Tessellator tess = Tessellator.getInstance();
    BufferBuilder worldr = tess.getBuffer();

    ScaledResolution res = new ScaledResolution(client);
    double scaleW = client.displayWidth / res.getScaledWidth_double();
    double scaleH = client.displayHeight / res.getScaledHeight_double();
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((int) (left * scaleW), (int) (client.displayHeight - (bottom * scaleH)),
            (int) (listWidth * scaleW), (int) (viewHeight * scaleH));

    if (this.client.world != null) {

    } else // Draw dark dirt background
    {
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        this.client.renderEngine.bindTexture(Gui.OPTIONS_BACKGROUND);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float scale = 32.0F;
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(this.left, this.bottom, 0.0D)
                .tex(this.left / scale, (this.bottom + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.bottom, 0.0D)
                .tex(this.right / scale, (this.bottom + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.top, 0.0D)
                .tex(this.right / scale, (this.top + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.left, this.top, 0.0D)
                .tex(this.left / scale, (this.top + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        tess.draw();
    }

    int baseY = this.top + border - (int) this.scrollDistance;

    if (this.hasHeader) {
        this.drawHeader(entryRight, baseY, tess);
    }

    for (int slotIdx = 0; slotIdx < listLength; ++slotIdx) {
        int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight;
        int slotBuffer = this.slotHeight - border;

        if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top) {
            if (this.highlightSelected && this.isSelected(slotIdx)) {
                int min = this.left;
                int max = entryRight;
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                GlStateManager.disableTexture2D();
                worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
                worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
                worldr.pos(min, slotTop + slotBuffer + 2, 0).tex(0, 1).color(0x80, 0x80, 0x80, 0xFF)
                        .endVertex();
                worldr.pos(max, slotTop + slotBuffer + 2, 0).tex(1, 1).color(0x80, 0x80, 0x80, 0xFF)
                        .endVertex();
                worldr.pos(max, slotTop - 2, 0).tex(1, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min, slotTop - 2, 0).tex(0, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop + slotBuffer + 1, 0).tex(0, 1).color(0x00, 0x00, 0x00, 0xFF)
                        .endVertex();
                worldr.pos(max - 1, slotTop + slotBuffer + 1, 0).tex(1, 1).color(0x00, 0x00, 0x00, 0xFF)
                        .endVertex();
                worldr.pos(max - 1, slotTop - 1, 0).tex(1, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop - 1, 0).tex(0, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                tess.draw();
                GlStateManager.enableTexture2D();
            }

            this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess);
        }
    }

    GlStateManager.disableDepth();

    int extraHeight = (this.getContentHeight() + border) - viewHeight;
    if (extraHeight > 0) {
        int height = (viewHeight * viewHeight) / this.getContentHeight();

        if (height < 32)
            height = 32;

        if (height > viewHeight - border * 2)
            height = viewHeight - border * 2;

        int barTop = (int) this.scrollDistance * (viewHeight - height) / extraHeight + this.top;
        if (barTop < this.top) {
            barTop = this.top;
        }

        GlStateManager.disableTexture2D();
        GlStateManager.enableAlpha();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, this.bottom, 0.0D).tex(0.0D, 1.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, this.bottom, 0.0D).tex(1.0D, 1.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, this.top, 0.0D).tex(1.0D, 0.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, this.top, 0.0D).tex(0.0D, 0.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height, 0.0D).tex(0.0D, 1.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, barTop + height, 0.0D).tex(1.0D, 1.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, barTop, 0.0D).tex(1.0D, 0.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height - 1, 0.0D).tex(0.0D, 1.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight - 1, barTop + height - 1, 0.0D).tex(1.0D, 1.0D)
                .color(scrollBarFillColor.getRed(), scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(),
                        scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight - 1, barTop, 0.0D).tex(1.0D, 0.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        tess.draw();
    }

    this.drawScreen(mouseX, mouseY);
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.disableBlend();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
}

From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java

License:Open Source License

@Override
public void setScissor(int x, int y, int width, int height) {
    GL11.glScissor(x, y, width, height);
}

From source file:kihira.foxlib.client.RenderHelper.java

License:Open Source License

public static void startGlScissor(int x, int y, int width, int height) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution reso = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

    double scaleW = (double) mc.displayWidth / reso.getScaledWidth_double();
    double scaleH = (double) mc.displayHeight / reso.getScaledHeight_double();

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((int) Math.floor((double) x * scaleW),
            (int) Math.floor((double) mc.displayHeight - ((double) (y + height) * scaleH)),
            (int) Math.floor((double) (x + width) * scaleW) - (int) Math.floor((double) x * scaleW),
            (int) Math.floor((double) mc.displayHeight - ((double) y * scaleH))
                    - (int) Math.floor((double) mc.displayHeight - ((double) (y + height) * scaleH))); //starts from lower left corner (minecraft starts from upper left)
}

From source file:kuake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_SetupFrame/*from w  w  w  .java 2s .  co m*/
 */
void R_SetupFrame() {
    r_framecount++;

    //   build the transformation matrix for the given view angles
    Math3D.VectorCopy(r_newrefdef.vieworg, r_origin);

    Math3D.AngleVectors(r_newrefdef.viewangles, vpn, vright, vup);

    //   current viewcluster
    mleaf_t leaf;
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) {
        r_oldviewcluster = r_viewcluster;
        r_oldviewcluster2 = r_viewcluster2;
        leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
        r_viewcluster = r_viewcluster2 = leaf.cluster;

        // check above and below so crossing solid water doesn't draw wrong
        if (leaf.contents == 0) { // look down a bit
            Math3D.VectorCopy(r_origin, temp);
            temp[2] -= 16;
            leaf = Mod_PointInLeaf(temp, r_worldmodel);
            if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
                r_viewcluster2 = leaf.cluster;
        } else { // look up a bit
            Math3D.VectorCopy(r_origin, temp);
            temp[2] += 16;
            leaf = Mod_PointInLeaf(temp, r_worldmodel);
            if ((leaf.contents & Defines.CONTENTS_SOLID) == 0 && (leaf.cluster != r_viewcluster2))
                r_viewcluster2 = leaf.cluster;
        }
    }

    for (int i = 0; i < 4; i++)
        v_blend[i] = r_newrefdef.blend[i];

    c_brush_polys = 0;
    c_alias_polys = 0;

    // clear out the portion of the screen that the NOWORLDMODEL defines
    if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) {
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
        GL11.glScissor(r_newrefdef.x, vid.height - r_newrefdef.height - r_newrefdef.y, r_newrefdef.width,
                r_newrefdef.height);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glClearColor(1.0f, 0.0f, 0.5f, 0.5f);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
}

From source file:net.malisis.core.client.gui.GuiRenderer.java

License:Open Source License

/**
 * Starts clipping an area to prevent drawing outside of it.
 *
 * @param area the area/*from  w w w .ja v a2 s.  c  o  m*/
 */
public void startClipping(ClipArea area) {
    if (area.noClip || area.width() <= 0 || area.height() <= 0)
        return;

    GL11.glPushAttrib(GL11.GL_SCISSOR_BIT);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);

    int f = ignoreScale ? 1 : scaleFactor;
    int x = area.x * f;
    int y = displayHeight - (area.y + area.height()) * f;
    int w = area.width() * f;
    int h = area.height() * f;
    ;
    GL11.glScissor(x, y, w, h);
}