Example usage for org.lwjgl.opengl GL11 GL_TRUE

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

Introduction

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

Prototype

int GL_TRUE

To view the source code for org.lwjgl.opengl GL11 GL_TRUE.

Click Source Link

Document

Boolean

Usage

From source file:java3dv3.Tutorial1.java

private void init() {
    // Setup an error callback. The default implementation
    // will print the error message in System.err.
    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    // Initialize GLFW. Most GLFW functions will not work before doing this.
    if (glfwInit() != GL11.GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }//  w  ww .jav a2 s.c  o m

    // Configure our window
    glfwDefaultWindowHints(); // optional, the current window hints are already the default
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

    int WIDTH = 500;
    int HEIGHT = 500;

    // Create the window
    window = glfwCreateWindow(WIDTH, HEIGHT, "Tutorial 1", NULL, NULL);
    if (window == NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
                glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
            }
        }
    });

    // Get the resolution of the primary monitor
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - WIDTH) / 2,
            (GLFWvidmode.height(vidmode) - HEIGHT) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(window);
}

From source file:java3dv3.Tutorial0.java

private void init() {
    // Setup an error callback. The default implementation
    // will print the error message in System.err.
    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    // Initialize GLFW. Most GLFW functions will not work before doing this.
    if (glfwInit() != GL11.GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }/*from   w w  w .j a  v  a2  s . c  o m*/

    // Configure our window
    glfwDefaultWindowHints(); // optional, the current window hints are already the default
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

    int WIDTH = 300;
    int HEIGHT = 300;

    // Create the window
    window = glfwCreateWindow(WIDTH, HEIGHT, "Tutorial 0", NULL, NULL);
    if (window == NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
                glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
            }
        }
    });

    // Get the resolution of the primary monitor
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - WIDTH) / 2,
            (GLFWvidmode.height(vidmode) - HEIGHT) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(window);
}

From source file:java3dv3.Tutorial2.java

private void init() {
    // Setup an error callback. The default implementation
    // will print the error message in System.err.
    glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

    // Initialize GLFW. Most GLFW functions will not work before doing this.
    if (glfwInit() != GL11.GL_TRUE) {
        throw new IllegalStateException("Unable to initialize GLFW");
    }/* w w  w .ja  v a  2 s .  c om*/

    // Configure our window
    glfwDefaultWindowHints(); // optional, the current window hints are already the default
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable

    int WIDTH = 500;
    int HEIGHT = 500;

    // Create the window
    window = glfwCreateWindow(WIDTH, HEIGHT, "Tutorial 2", NULL, NULL);
    if (window == NULL) {
        throw new RuntimeException("Failed to create the GLFW window");
    }

    // Setup a key callback. It will be called every time a key is pressed, repeated or released.
    glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) {
                glfwSetWindowShouldClose(window, GL_TRUE); // We will detect this in our rendering loop
            }
        }
    });

    // Get the resolution of the primary monitor
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    // Center our window
    glfwSetWindowPos(window, (GLFWvidmode.width(vidmode) - WIDTH) / 2,
            (GLFWvidmode.height(vidmode) - HEIGHT) / 2);

    // Make the OpenGL context current
    glfwMakeContextCurrent(window);
    // Enable v-sync
    glfwSwapInterval(1);

    // Make the window visible
    glfwShowWindow(window);
}

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

License:Open Source License

@Override
public boolean compilerShader(int shader, String source) {
    GL20.glShaderSource(shader, source);
    GL20.glCompileShader(shader);//from  w ww.jav a 2  s  . c o m
    return GL20.glGetShader(shader, GL20.GL_COMPILE_STATUS) == GL11.GL_TRUE;
}

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

License:Open Source License

@Override
public boolean linkProgram(int program) {
    GL20.glLinkProgram(program);//from ww w .j  av  a2  s .  co m
    return GL20.glGetProgram(program, GL20.GL_LINK_STATUS) == GL11.GL_TRUE;
}

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

License:Open Source License

@Override
public boolean validateProgram(int program) {
    GL20.glValidateProgram(program);/*  w  w  w .  j  ava2  s .c o m*/
    return GL20.glGetProgram(program, GL20.GL_VALIDATE_STATUS) == GL11.GL_TRUE;
}

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

License:Open Source License

@Override
public void setPixelTransfer(int parameter, boolean value) {
    GL11.glPixelTransferi(pixelTransferToGL[parameter], value ? GL11.GL_TRUE : GL11.GL_FALSE);
}

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * Returns true if the shader compiled successfully
 * @param shaderID//from   www . ja va  2 s.  c  o  m
 * @return true if the shader compiled successfully
 */
private boolean compiledSuccessfully(int shaderID) {
    if (has_opengl2) {
        return GL20.glGetShader(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_TRUE;
    } else if (has_arb) {
        return ARBShaderObjects.glGetObjectParameterfARB(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_TRUE;
    }
    return false;
}

From source file:lwjgl.test.Gears.java

License:Open Source License

@Override
protected void init() {
    glfwSetErrorCallback(errorfun = errorCallbackPrint(System.err));
    if (glfwInit() != GL11.GL_TRUE)
        throw new IllegalStateException("Unable to initialize glfw");

    glfwDefaultWindowHints();//from   w  w  w  .  jav  a 2 s. com
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);

    keyfun = new GLFWKeyCallback() {
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if (action != GLFW_RELEASE)
                return;

            switch (key) {
            case GLFW_KEY_ESCAPE:
                glfwSetWindowShouldClose(window, GL_TRUE);
                break;
            case GLFW_KEY_F:
                if (glfwGetWindowMonitor(window) == NULL)
                    toggleMode = true;
                break;
            case GLFW_KEY_W:
                if (glfwGetWindowMonitor(window) != NULL)
                    toggleMode = false;
                break;
            case GLFW_KEY_G:
                glfwSetInputMode(window, GLFW_CURSOR,
                        glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_NORMAL ? GLFW_CURSOR_DISABLED
                                : GLFW_CURSOR_NORMAL);
                break;
            }
        }
    };

    createWindow(false);
}

From source file:me.sunchiro.game.engine.gl.Graphic.java

License:Open Source License

public void createWindow(int width, int height, String name) {
    this.width = width;
    this.height = height;
    glfwSetErrorCallback(errorCallback = Callbacks.errorCallbackPrint(System.err));
    if (glfwInit() != GL11.GL_TRUE)
        throw new IllegalStateException("Unable to initialize GLFW");
    glfwDefaultWindowHints(); // optional, the current window hints are
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay
    // hidden/*from  ww w  . j a va  2 s.c  o  m*/
    glfwWindowHint(GLFW_RESIZABLE, GL11.GL_TRUE); // the window will be
    // resizable
    window = glfwCreateWindow(width, height, name, NULL, NULL);
    if (window == NULL)
        throw new RuntimeException("Failed to create the GLFW window");
    // glfwSetKeyCallback(window,this.keyCallback = keyCallback);
    glfwSetWindowSizeCallback(window, resizeCallback());
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    glfwSetWindowPos(window, (vidmode.asIntBuffer().get(0) - width) / 2,
            (vidmode.asIntBuffer().get(1) - height) / 2);
    glfwMakeContextCurrent(window);
    Graphic.instance = this;
    glfwSwapInterval(1);
    GL.createCapabilities();
    setCapabilities();

    glfwShowWindow(window);

    // Setup an XNA like background color
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);

    GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0);
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, width, height);
    matBuff = BufferUtils.createFloatBuffer(16);
    vaoId = GL30.glGenVertexArrays();
    vboiId = GL15.glGenBuffers();
    vboId = GL15.glGenBuffers();
    tid_charmap = texManager.loadTexture("textures/charmap.png", GL13.GL_TEXTURE0);
    shader.setupShader();
    // testQuad();

}