List of usage examples for org.lwjgl.opengl GL11 GL_TRUE
int GL_TRUE
To view the source code for org.lwjgl.opengl GL11 GL_TRUE.
Click Source Link
From source file:Src.Framework.Window.java
public void create() { //Initialize GLFW. Most GLFW functions will not work before doing this. if (glfwInit() != GL11.GL_TRUE) { throw new IllegalStateException("Unable to initialize GLFW"); }/*ww w . j a v a 2 s.com*/ //not visible after creation. Will set to visible once ready. glfwWindowHint(GLFW_VISIBLE, GL_FALSE); //window set to be resizable glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); //create window windowHandle = glfwCreateWindow(windowWidth, windowHeight, "Jovian", NULL, NULL); if (windowHandle == NULL) { throw new RuntimeException("Failed to create the GLFW window"); } //initialize OpenGL initGL(); }
From source file:Tutorials.Tutorial0.java
private void initGL() { // 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 www . ja v a2s . 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); // This line is critical for LWJGL's interoperation with GLFW's // OpenGL context, or any context that is managed externally. // LWJGL detects the context that is current in the current thread, // creates the ContextCapabilities instance and makes the OpenGL // bindings available for use. GLContext.createFromCurrent(); // Set the clear color glClearColor(0.0f, 1.0f, 1.0f, 0.0f); }
From source file:Tutorials.Tutorial1.java
private void initGL() { // 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 a2s .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); // This line is critical for LWJGL's interoperation with GLFW's // OpenGL context, or any context that is managed externally. // LWJGL detects the context that is current in the current thread, // creates the ContextCapabilities instance and makes the OpenGL // bindings available for use. GLContext.createFromCurrent(); // Set the clear color glClearColor(1.0f, 1.0f, 1.0f, 0.0f); }
From source file:Tutorials.Tutorial2.java
private void initGL() { // 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 va2 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 // 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); // This line is critical for LWJGL's interoperation with GLFW's // OpenGL context, or any context that is managed externally. // LWJGL detects the context that is current in the current thread, // creates the ContextCapabilities instance and makes the OpenGL // bindings available for use. GLContext.createFromCurrent(); // Set the clear color glClearColor(1.0f, 1.0f, 1.0f, 0.0f); }
From source file:wrath.client.ClientUtils.java
License:Open Source License
/** * Converts a primitive Java boolean to the LWJGL version of the boolean. * Mostly a convenience method.//from w w w .j a v a2 s . c o m * @param bool The primitive Java boolean value. * @return Returns the LWJGL version of the boolean. */ public static int getOpenGLBoolean(boolean bool) { if (bool) return GL11.GL_TRUE; else return GL11.GL_FALSE; }
From source file:wrath.client.Game.java
License:Open Source License
/** * Private loop (main game loop).//from w w w.ja va2s. co m */ private void loop() { // FPS counter. int afpsCount = 0; int fpsCount = 0; //Input Checking int inpCount = 0; double checksPerSec = gameConfig.getDouble("PersistentInputChecksPerSecond", 0.0); if (checksPerSec > TPS || checksPerSec < 1) checksPerSec = TPS; final double INPUT_CHECK_TICKS = TPS / checksPerSec; //Timings long last = System.nanoTime(); final double conv = 1000000000.0 / TPS; double delta = 0.0; long now; while (isRunning && (!winManager.windowOpen || GLFW.glfwWindowShouldClose(winManager.window) != GL11.GL_TRUE)) { now = System.nanoTime(); delta += (now - last) / conv; last = now; //Tick occurs while (delta >= 1) { onTickPreprocessor(); //Persistent input management if (INPUT_CHECK_TICKS == 1 || inpCount >= INPUT_CHECK_TICKS) { inpManager.onPersistentInput(); inpCount -= INPUT_CHECK_TICKS; } else inpCount++; //FPS Counter if (winManager.windowOpen) if (fpsCount >= TPS) { afpsCount++; renManager.fps = renManager.fpsBuf; renManager.avgFps = renManager.totalFramesRendered / afpsCount; renManager.fpsBuf = 0; fpsCount -= TPS; } else fpsCount++; delta--; } renManager.render(); } stop(); stopImpl(); }
From source file:wrath.client.Game.java
License:Open Source License
/** * Method that is used to load the game and all of it's resources. * @param args Arguments, usually from the main method (entry point). */// ww w . ja v a 2 s . c o m public void start(String[] args) { gameLogger.println( "Launching '" + TITLE + "' Client v." + VERSION + " with LWJGL v." + Version.getVersion() + "!"); //Initialize GLFW and OpenGL GLFW.glfwSetErrorCallback((errStr = new GLFWErrorCallback() { @Override public void invoke(int error, long description) { System.err.println("GLFW hit ERROR ID '" + error + "' with message '" + description + "'!"); } })); if (GLFW.glfwInit() != GL11.GL_TRUE) { System.err.println("Could not initialize GLFW! Unknown Error!"); ClientUtils.throwInternalError("Failed to initialize GLFW!", false); stopImpl(); } //Interpret command-line arguments. for (String a : args) { String[] b = a.split("=", 2); if (b.length <= 1) continue; gameConfig.setProperty(b[0], b[1]); gameLogger.println("Set property '" + b[0] + "' to value '" + b[1] + "'!"); } //Auto-loads Java Plugins from specified directory. if (gameConfig.getBoolean("AutoLoadJavaPlugins", true)) { Object[] list = JarLoader.loadPluginsDirectory( new File(gameConfig.getString("AutoLoadJavaPluginsDirectory", "etc/plugins"))); for (Object obj : list) evManager.getGameEventHandler().onLoadJavaPlugin(obj); if (list.length != 0) gameLogger.println("Loaded " + list.length + " plugins from the directory '" + gameConfig.getString("AutoLoadJavaPluginsDirectory", "etc/plugins") + "'!"); } isRunning = true; winManager.openWindow(); evManager.getGameEventHandler().onGameOpen(); inpManager.loadKeys(); loop(); }
From source file:zsawyer.mods.stereoscopic3d.DebugUtil.java
License:Open Source License
public static void printStencilMap() { try {// w ww . j a v a2 s . c o m Minecraft mc = FMLClientHandler.instance().getClient(); int stencilWidth = mc.displayWidth; int stencilHeight = mc.displayHeight; IntBuffer stencilMap = ByteBuffer.allocateDirect(stencilWidth * stencilHeight * 4).asIntBuffer(); stencilMap.rewind(); // stencilMap.order(ByteOrder.nativeOrder()); GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, GL11.GL_TRUE); GL11.glReadPixels(0, 0, stencilWidth, stencilHeight, GL11.GL_STENCIL_INDEX, GL11.GL_INT, stencilMap); checkGLError(); stencilMap.rewind(); PrintWriter out = new PrintWriter("stencilMap.bitmap"); int yPos = 0; while (stencilMap.hasRemaining()) { // int c = Math.abs(stencilMap.get()) % 10; int c = stencilMap.get(); out.print((c & 1)); if (yPos >= stencilWidth - 1) { out.println(""); yPos = -1; } yPos++; } out.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:zsawyer.mods.stereoscopic3d.renderers.StencilingRenderer.java
License:Open Source License
protected boolean isReinitRequired() { stencilMap.rewind();//from ww w .j a va2s .co m GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, GL11.GL_TRUE); GL11.glReadPixels(0, 0, stencilTestWidth, stencilTestHeight, GL11.GL_STENCIL_INDEX, GL11.GL_INT, stencilMap); DebugUtil.checkGLError(); return stencilMap.get(0) != 1; }