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

The following examples show how to use org.lwjgl.glfw.GLFW#glfwSetWindowPos() . 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: LWJGUIUtil.java    From LWJGUI with MIT License 5 votes vote down vote up
private static long createOpenGLWindow(String name, int width, int height, boolean resizable, boolean ontop, boolean modernOpenGL, boolean vsync) {
	// Configure GLFW
	glfwDefaultWindowHints();
	glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
	glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);

	// Hints
	hints(modernOpenGL);
	glfwWindowHint(GLFW.GLFW_FLOATING, ontop?GL_TRUE:GL_FALSE);
	glfwWindowHint(GLFW.GLFW_RESIZABLE, resizable?GL_TRUE:GL_FALSE);

	// Create the window
	long window = glfwCreateWindow(width, height, name, NULL, NULL);
	if ( window == NULL )
		throw new RuntimeException("Failed to create the GLFW window");

	// Finalize window
	glfwMakeContextCurrent(window);
	glfwSwapInterval(vsync ? 1 : 0);

	// Get the resolution of the primary monitor
	GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());

	// Center the window
	GLFW.glfwSetWindowPos(
			window,
			(vidmode.width() - width) / 2,
			(vidmode.height() - height) / 2
			);

	// Create context
	GL.createCapabilities();
	
	System.out.println("Creating opengl window: " + glGetString(GL_VERSION));

	return window;
}
 
Example 2
Source File: Window.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void create() {
	if (!GLFW.glfwInit()) {
		System.err.println("ERROR: GLFW wasn't initializied");
		return;
	}
	
	input = new Input();
	window = GLFW.glfwCreateWindow(width, height, title, isFullscreen ? GLFW.glfwGetPrimaryMonitor() : 0, 0);
	
	if (window == 0) {
		System.err.println("ERROR: Window wasn't created");
		return;
	}
	
	GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
	windowPosX[0] = (videoMode.width() - width) / 2;
	windowPosY[0] = (videoMode.height() - height) / 2;
	GLFW.glfwSetWindowPos(window, windowPosX[0], windowPosY[0]);
	GLFW.glfwMakeContextCurrent(window);
	GL.createCapabilities();
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	
	createCallbacks();
	
	GLFW.glfwShowWindow(window);
	
	GLFW.glfwSwapInterval(1);
	
	time = System.currentTimeMillis();
	
	System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION));
}
 
Example 3
Source File: Lwjgl3Mini2DxWindow.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
/** Sets the position of the window in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public void setPosition(int x, int y) {
	GLFW.glfwSetWindowPos(windowHandle, x, y);
}