Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void toggleFullscreen(){
- long newWindow;
- fullscreen = !fullscreen;
- if(fullscreen){
- newWindow = glfwCreateWindow(windowWidth, windowHeight, "Title", glfwGetPrimaryMonitor(), window.getWindowHandle());
- glfwMakeContextCurrent( newWindow );
- }else{
- newWindow = glfwCreateWindow(windowWidth, windowHeight, "Title", NULL, windowHandle());
- glfwMakeContextCurrent( newWindow );
- }
- glfwDestroyWindow(window.getWindowHandle());
- windowHandle = newWindow;
- glfwMakeContextCurrent(windowHandle);
- glfwSwapInterval(1);
- glfwShowWindow(windowHandle);
- GLContext.createFromCurrent();
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glViewport(0,0,windowWidth,windowHeight);
- GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- game.initInputPolling();
- }
- public Window(int width, int height, String title, boolean fullScreen) {
- this.fullScreen = fullScreen;
- Window.height = height;
- Window.width = width;
- if (!glfwInit()) {
- System.err.println("Failed to initialize GLFW");
- System.exit(1);
- }
- GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
- window = glfwCreateWindow(fullScreen ? vidMode.width() : width, fullScreen ? vidMode.height() : height, title, fullScreen ? glfwGetPrimaryMonitor() : 0, 0);
- if (!fullScreen) {
- glfwSetWindowPos(window, (vidMode.width() - width) / 2, (vidMode.height() - height) / 2);
- } else {
- this.width = vidMode.width();
- this.height = vidMode.height();
- }
- glfwMakeContextCurrent(window);
- createCapabilities();
- }
Add Comment
Please, Sign In to add comment