Created
May 18, 2016 16:30
-
-
Save stuartwakefield/9a3abc7b8e7499acb2c157b6ff78dd41 to your computer and use it in GitHub Desktop.
Basic single monitor setup with OpenGL 3.2 forward compatibility and core profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Window { | |
private final Long id; | |
public Window(Long id) { | |
this.id = id; | |
} | |
public void destroy() { | |
GLFW.glfwDestroyWindow(this.id); | |
} | |
public static Window create(Integer width, Integer height, String title) { | |
if (GLFW.glfwInit() == GLFW.GLFW_FALSE) | |
throw new IllegalStateException("Could not initialize GLFW"); | |
GLFW.glfwDefaultWindowHints(); | |
// Turn on multisample anti-aliasing | |
GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, 4); | |
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE); | |
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_FALSE); | |
// OpenGL 3.2 with forward compatibility and core profile | |
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3); | |
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2); | |
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE); | |
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE); | |
Integer monitor = 0; | |
Integer share = 0; | |
Long id = GLFW.glfwCreateWindow(width, height, title, monitor, share); | |
return new Window(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment