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

The following examples show how to use org.lwjgl.glfw.GLFW#glfwInit() . 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: GLFWContextCreator.java    From settlers-remake with MIT License 6 votes vote down vote up
public void async_init() {
	if(debug) {
		ec = GLFWErrorCallback.createPrint(System.err);
		GLFW.glfwSetErrorCallback(ec);
	}

	if(!GLFW.glfwInit()) throw new Error("glfwInit() failed!");

	GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, debug ? GLFW.GLFW_TRUE : GLFW.GLFW_DONT_CARE);
	GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 1);
	glfw_wnd = GLFW.glfwCreateWindow(width + 1, width + 1, "lwjgl-offscreen", 0, 0);
	GLFW.glfwMakeContextCurrent(glfw_wnd);
	GLFW.glfwSwapInterval(0);

	event_converter.registerCallbacks();
}
 
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: DesktopMini2DxGame.java    From mini2Dx with Apache License 2.0 5 votes vote down vote up
static void initializeGlfw() {
	if (errorCallback == null) {
		Lwjgl3NativesLoader.load();
		errorCallback = GLFWErrorCallback.createPrint(System.err);
		GLFW.glfwSetErrorCallback(errorCallback);
		GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE);
		if (!GLFW.glfwInit()) {
			throw new GdxRuntimeException("Unable to initialize GLFW");
		}
	}
}