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:a1.Render2D.java

License:Open Source License

static public void PushScissor(Rect s) {
    if (current_scissor == null)
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
    Rect NewRect;//from  w w w.  j  ava2s .  co m
    if (current_scissor == null)
        NewRect = CompareScissorRects(s, s);
    else
        NewRect = CompareScissorRects(s, current_scissor);

    scissors.push(current_scissor);
    current_scissor = NewRect;
    GL11.glScissor(NewRect.x, Config.getScreenHeight() - NewRect.y - NewRect.h, NewRect.w, NewRect.h);
    //GL11.glScissor(s.x, Config.ScreenHeight-s.y-s.h, s.w, s.h);
}

From source file:a1.Render2D.java

License:Open Source License

static public void PopScissor() {
    if (scissors.size() < 1)
        return;/*from w w w .j a va  2 s  . c  o  m*/
    current_scissor = scissors.pop();
    if (current_scissor != null)
        GL11.glScissor(current_scissor.x, current_scissor.y, current_scissor.w, current_scissor.h);
    else
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
}

From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java

License:Apache License

/**
 * {@inheritDoc}/*  w w  w. j a  v a2 s  .  c  om*/
 */
@Override
public void glScissor(int x1, int y1, int x2, int y2) {
    GL11.glScissor(x1, y1, x2, y2);
}

From source file:code.elix_x.excore.utils.client.gui.elements.GuiElement.java

License:Apache License

public static void scisors(Rectangle element) {
    GL11.glScissor(toScreen(element.getX()), toScreen(screenHeight() - element.getY() - element.getHeight()),
            toScreen(element.getWidth()), toScreen(element.getHeight()));
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void clearBuffers(final int buffers, final boolean strict) {

    int clear = 0;

    if ((buffers & Renderer.BUFFER_COLOR) != 0) {
        clear |= GL11.GL_COLOR_BUFFER_BIT;
    }/* ww  w . j ava 2s  . c o m*/

    if ((buffers & Renderer.BUFFER_DEPTH) != 0) {
        clear |= GL11.GL_DEPTH_BUFFER_BIT;

        // make sure no funny business is going on in the z before clearing.
        if (defaultStateList.containsKey(RenderState.StateType.ZBuffer)) {
            defaultStateList.get(RenderState.StateType.ZBuffer).setNeedsRefresh(true);
            doApplyState(defaultStateList.get(RenderState.StateType.ZBuffer));
        }
    }

    if ((buffers & Renderer.BUFFER_STENCIL) != 0) {
        clear |= GL11.GL_STENCIL_BUFFER_BIT;

        GL11.glClearStencil(_stencilClearValue);
        GL11.glStencilMask(~0);
        GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
    }

    if ((buffers & Renderer.BUFFER_ACCUMULATION) != 0) {
        clear |= GL11.GL_ACCUM_BUFFER_BIT;
    }

    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord record = context.getRendererRecord();

    if (strict) {
        // grab our camera to get width and height info.
        final Camera cam = Camera.getCurrentCamera();

        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(0, 0, cam.getWidth(), cam.getHeight());
        record.setClippingTestEnabled(true);
    }

    GL11.glClear(clear);

    if (strict) {
        // put us back.
        LwjglRendererUtil.applyScissors(record);
    }
}

From source file:com.ardor3d.scene.state.lwjgl.util.LwjglRendererUtil.java

License:Open Source License

public static void applyScissors(final RendererRecord rendRecord) {
    final Stack<ReadOnlyRectangle2> clips = rendRecord.getScissorClips();

    if (clips.size() > 0) {
        final Rectangle2 init = Rectangle2.fetchTempInstance();
        init.set(-1, -1, -1, -1);/*from   ww w.  j ava 2 s  .  c o m*/
        ReadOnlyRectangle2 r;
        boolean first = true;
        for (int i = clips.size(); --i >= 0;) {
            r = clips.get(i);

            if (r == null) {
                break;
            }
            if (first) {
                init.set(r);
                first = false;
            } else {
                init.intersect(r, init);
            }
            if (init.getWidth() <= 0 || init.getHeight() <= 0) {
                init.setWidth(0);
                init.setHeight(0);
                break;
            }
        }

        if (init.getWidth() == -1) {
            setClippingEnabled(rendRecord, false);
        } else {
            setClippingEnabled(rendRecord, true);
            GL11.glScissor(init.getX(), init.getY(), init.getWidth(), init.getHeight());
        }
        Rectangle2.releaseTempInstance(init);
    } else {
        // no clips, so disable
        setClippingEnabled(rendRecord, false);
    }
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

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

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

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

From source file:com.fireball1725.firelib.guimaker.GuiMakerGuiContainer.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void scissorCut(int x, int y, int w, int h) {
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
    int scale = scaledResolution.getScaleFactor();

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(x * scale, y * scale, w * scale, h * scale);
}

From source file:com.gameminers.mav.component.TextField.java

License:Open Source License

@Override
public void doRender() {
    if (viewPos > str.length()) {
        viewPos = str.length();/*ww  w.  j av a2  s.c  om*/
    } else if (viewPos < 0) {
        viewPos = 0;
    }
    frames++;
    float[] fg = RenderState.getColor(0.8f);
    float[] bg = RenderState.getColor(0.3f);
    Rendering.drawRectangle(0, 0, 16, 16, 1, 0, 0, 0, 0);
    Rendering.drawRectangle(0, 0, width, height, fg[0], fg[1], fg[2], 1.0f, 0f);
    Rendering.drawRectangle(2, 2, width - 4, height - 4, bg[0], bg[1], bg[2], 1.0f, 0f);

    // roughly ported from Glass Pane
    if (cursorPos < 0) {
        cursorPos = 0;
    } else if (cursorPos > content.length()) {
        cursorPos = content.length();
    }
    String trimmedText = Fonts.trimStringToWidth(str.substring(viewPos), Fonts.base[1], width - 24);
    int trimmedLength = trimmedText.length();
    if (cursorPos > viewPos + trimmedLength) {
        viewPos = cursorPos - trimmedLength;
    } else if (cursorPos < viewPos) {
        viewPos = cursorPos;
    }
    int len = Fonts.base[1].getWidth(trimmedText);
    int mod = (int) (len >= width - 16 ? len - (width - 16) : 0);
    if (viewPos == 0) {
        mod = 0;
    }
    if (focused) {
        Rendering.drawRectangle(
                (8 - mod) + Fonts.base[1].getWidth(
                        trimmedText.substring(0, Math.min(trimmedLength, Math.max(0, cursorPos - viewPos)))),
                6, 2, height - 12, 1, 1, 1, (1.0f - ((frames % 25) / 40f)) / (Display.isActive() ? 1f : 4f),
                0.2f);
    }
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((int) x + 8, Display.getHeight() - (int) (y + height), (int) width - 16, (int) height);
    Fonts.base[1].drawString(8 - mod, 1, trimmedText);
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
}