Example usage for org.lwjgl.opengl GL11 glViewport

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

Introduction

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

Prototype

public static void glViewport(@NativeType("GLint") int x, @NativeType("GLint") int y,
        @NativeType("GLsizei") int w, @NativeType("GLsizei") int h) 

Source Link

Document

Specifies the viewport transformation parameters for all viewports.

Usage

From source file:se.angergard.engine.graphics.FrameBuffer.java

License:Apache License

public void end() {
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
}

From source file:shadowmage.ancient_framework.client.gui.elements.GuiScrollableAreaSimple.java

License:Open Source License

public void setupViewport() {
    GL11.glPushMatrix();/*from   www .  j a  v  a 2 s .co  m*/
    ScaledResolution scaledRes = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    int guiScale = scaledRes.getScaleFactor();
    //  float vAspect = (float)this.mc.displayWidth/(float)this.mc.displayHeight;
    float w = this.width * guiScale;
    float h = height * guiScale;
    float x = guiLeft * guiScale + renderPosX * guiScale;
    float y = guiTop * guiScale + parentGui.getYSize() * guiScale - h - renderPosY * guiScale;
    float scaleY = (float) mc.displayHeight / h;
    float scaleX = (float) mc.displayWidth / w;
    GL11.glViewport((int) x, (int) y, (int) w, (int) h);
    GL11.glScalef(scaleX, scaleY, 1);
}

From source file:shadowmage.ancient_framework.client.gui.elements.GuiScrollableAreaSimple.java

License:Open Source License

public void resetViewPort() {
    GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
    GL11.glPopMatrix();
}

From source file:shadowmage.ancient_warfare.client.gui.elements.GuiScrollableAreaSimple.java

License:Open Source License

public void setupViewport() {
    GL11.glPushMatrix();// w  w  w. j ava  2s.  com
    ScaledResolution scaledRes = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    int guiScale = scaledRes.getScaleFactor();
    float vAspect = (float) this.mc.displayWidth / (float) this.mc.displayHeight;
    float w = this.width * guiScale;
    float h = height * guiScale;
    float x = guiLeft * guiScale + renderPosX * guiScale;
    float y = guiTop * guiScale + parentGui.getYSize() * guiScale - h - renderPosY * guiScale;
    float scaleY = (float) mc.displayHeight / h;
    float scaleX = (float) mc.displayWidth / w;
    GL11.glViewport((int) x, (int) y, (int) w, (int) h);
    GL11.glScalef(scaleX, scaleY, 1);
}

From source file:Src.Framework.Window.java

public void initGL() {
    //Make the OpenGL context curent
    glfwMakeContextCurrent(windowHandle);
    // Enable v-sync
    glfwSwapInterval(1);//from   w  w  w.  ja  va  2 s .c  om
    // Make the window visible
    glfwShowWindow(windowHandle);
    //sets up OpenGL Bindings for use
    GLContext.createFromCurrent();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    //set the clear color
    glClearColor(0.0f, 1.0f, 0.0f, 0.0f);

    // enable alpha blending
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, windowWidth, windowHeight);
    GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

}

From source file:src.graphics.common.Viewport.java

License:Open Source License

/**  Called immediately prior to sprite rendering, setting up exact OpenGL
  *  viewport bounds://from   w  w  w . j  a  va  2 s  .c o m
  */
public void applyView() {
    GL11.glViewport((int) viewBounds.xpos(), (int) viewBounds.ypos(), (int) viewBounds.xdim(),
            (int) viewBounds.ydim());
}

From source file:taiga.code.opengl.GraphicsSystem.java

License:Open Source License

/**
 * Starting point for the graphics thread.
 *//*from   w ww  . j av  a 2 s . co  m*/
@Override
public void run() {
    //this will create the window and graphics context.
    reset = true;
    running = true;

    try {
        do {
            //create the window if needed.
            if (reset) {
                log.log(Level.INFO, CREATING_WINDOW);

                createWindow();
                reset = false;

                //make sure to notify when resetting is complete
                synchronized (this) {
                    this.notifyAll();
                }
            }

            if (Display.wasResized()) {
                GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
                fireWindowResized();
            }

            //abstract methods for the implementing class to hook into
            update();
            render();

            if (target_fps <= 0)
                Display.update();
            else
                Display.sync(target_fps);

        } while (running && !Display.isCloseRequested());

        log.log(Level.INFO, "Closing main window.");
    } catch (LWJGLException ex) {
        log.log(Level.SEVERE, UNHANDLED_EX, ex);
    } finally {
        running = false;
        Display.destroy();

        fireWindowClosed();
    }
}

From source file:tectonicus.rasteriser.lwjgl.LwjglRasteriser.java

License:BSD License

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

From source file:thebounzer.org.lwgldemo.glutils.OpenGLDisplay.java

License:Open Source License

public static void init(int width, int height, String title) {
    // Setup an OpenGL context with API version 3.2
    try {//from w  w  w  .java 2  s  .  c om
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
                .withProfileCore(true);

        Display.setDisplayMode(new DisplayMode(width, height));
        Display.setTitle(title);
        Display.create(pixelFormat, contextAtrributes);

        GL11.glViewport(0, 0, width, height);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}

From source file:thebounzer.org.lwgldemo.OglBook.java

License:Open Source License

public void setupOpenGL() {
    OpenGLDisplay.init(WIDTH, HEIGHT, TITLE);
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, WIDTH, HEIGHT);
}