Java Code Examples for org.lwjgl.glfw.GLFW#glfwWindowShouldClose()

The following examples show how to use org.lwjgl.glfw.GLFW#glfwWindowShouldClose() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelloWorldManual.java    From LWJGUI with MIT License 6 votes vote down vote up
public static void main(String[] args) {
	if ( !glfwInit() )
		throw new IllegalStateException("Unable to initialize GLFW");

	// Create a standard opengl 3.2 window. You can do this yourself.
	long window = LWJGUIUtil.createOpenGLCoreWindow("Hello World", WIDTH, HEIGHT, true, false);

	// Initialize lwjgui for this window
	Window lwjguiWindow = WindowManager.generateWindow(window);
	lwjguiWindow.show();
	
	// Add some components
	addComponents(lwjguiWindow.getScene());
	
	// Game Loop
	while (!GLFW.glfwWindowShouldClose(window)) {
		// Render GUI
		lwjguiWindow.render();
		lwjguiWindow.updateDisplay(0);
		WindowManager.update();
	}
	// Clear global window resources
	WindowManager.dispose();
	// Stop GLFW
	glfwTerminate();
}
 
Example 2
Source File: Window.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void destroy() {
	input.destroy();
	sizeCallback.free();
	GLFW.glfwWindowShouldClose(window);
	GLFW.glfwDestroyWindow(window);
	GLFW.glfwTerminate();
}
 
Example 3
Source File: HelloWorldManualNoUtil.java    From LWJGUI with MIT License 4 votes vote down vote up
public static void main(String[] args) {
	if ( !glfwInit() )
		throw new IllegalStateException("Unable to initialize GLFW");

	// Configure GLFW
	glfwDefaultWindowHints();
	glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
	glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
	glfwWindowHint(GLFW_FLOATING, GL_FALSE);
	
	// Create the window
	long handle = glfwCreateWindow(WIDTH, HEIGHT, "Hello World", NULL, NULL);
	if ( handle == NULL )
		throw new RuntimeException("Failed to create the GLFW window");
	
	// Finalize window
	glfwMakeContextCurrent(handle);
	GL.createCapabilities();
	
	// Initialize LWJGUI for this window
	Window window = WindowManager.generateWindow(handle);
	
	// Add some components
	StackPane pane = new StackPane();
	pane.getChildren().add(new Label("Hello World!"));
	window.setScene(new Scene(pane, WIDTH, HEIGHT));
	
	// Show Window
	window.show();
	
	// Game Loop
	while (!GLFW.glfwWindowShouldClose(handle)) {
		// Set context
		GLFW.glfwMakeContextCurrent(handle);
		
		// Tick window manager for any input or windowing commands
		WindowManager.update();
		
		// Render UI
		window.render();
		
		// Swap buffers
		glfwSwapBuffers(handle);
	}
	// Clear global window resources
	WindowManager.dispose();
	// Stop GLFW
	glfwTerminate();
}
 
Example 4
Source File: OpenGLExampleManual.java    From LWJGUI with MIT License 4 votes vote down vote up
public static void main(String[] args) {
	// Restarts the JVM if necessary on the first thread to ensure Mac compatibility 
	if (LWJGUIUtil.restartJVMOnFirstThread(true, args))
		return;
	
	// Initialize GLFW
	if ( !glfwInit() )
		throw new IllegalStateException("Unable to initialize GLFW");

	// Create a standard opengl 3.2 window. You can do this yourself.
	long handle = LWJGUIUtil.createOpenGLCoreWindow("Hello World", WIDTH, HEIGHT, true, false);
	
	// Initialize lwjgui for this window
	Window window = WindowManager.generateWindow(handle);
	window.setWindowAutoClear(false); // We must call glClear ourselves.
	window.show(); // Display window if it's invisible.
	
	// Add some components
	addComponents(window.getScene());
	
	// Initialize OpenGL information
	initializeOpenGL();
	
	// Game Loop
	while (!GLFW.glfwWindowShouldClose(handle)) {
		// Tick window manager for any input or windowing commands
		WindowManager.update();

		// Clear back buffer
		glClearColor(0,0,0,1);
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
		
		// Render OpenGL
		renderOpenGL();
		
		// Render GUI
		window.render();
		
		// Swap buffers
		GLFW.glfwSwapBuffers(handle);
	}

	// Clear global window resources
	WindowManager.dispose();
	// Stop GLFW
	glfwTerminate();
}
 
Example 5
Source File: Window.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public boolean shouldClose() {
	return GLFW.glfwWindowShouldClose(window);
}
 
Example 6
Source File: Lwjgl3Mini2DxWindow.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
boolean shouldClose() {
	return GLFW.glfwWindowShouldClose(windowHandle);
}