Guest User

Untitled

a guest
Dec 14th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. public void toggleFullscreen(){
  2. long newWindow;
  3. fullscreen = !fullscreen;
  4. if(fullscreen){
  5. newWindow = glfwCreateWindow(windowWidth, windowHeight, "Title", glfwGetPrimaryMonitor(), window.getWindowHandle());
  6. glfwMakeContextCurrent( newWindow );
  7. }else{
  8. newWindow = glfwCreateWindow(windowWidth, windowHeight, "Title", NULL, windowHandle());
  9. glfwMakeContextCurrent( newWindow );
  10. }
  11. glfwDestroyWindow(window.getWindowHandle());
  12. windowHandle = newWindow;
  13.  
  14. glfwMakeContextCurrent(windowHandle);
  15. glfwSwapInterval(1);
  16. glfwShowWindow(windowHandle);
  17. GLContext.createFromCurrent();
  18.  
  19. GL11.glEnable(GL11.GL_TEXTURE_2D);
  20. glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
  21.  
  22. GL11.glEnable(GL11.GL_BLEND);
  23. GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  24.  
  25. GL11.glViewport(0,0,windowWidth,windowHeight);
  26. GL11.glOrtho(0, windowWidth, windowHeight, 0, 1, -1);
  27. GL11.glMatrixMode(GL11.GL_MODELVIEW);
  28.  
  29. game.initInputPolling();
  30. }
  31.  
  32. public Window(int width, int height, String title, boolean fullScreen) {
  33. this.fullScreen = fullScreen;
  34. Window.height = height;
  35. Window.width = width;
  36.  
  37. if (!glfwInit()) {
  38. System.err.println("Failed to initialize GLFW");
  39. System.exit(1);
  40. }
  41. GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
  42.  
  43. window = glfwCreateWindow(fullScreen ? vidMode.width() : width, fullScreen ? vidMode.height() : height, title, fullScreen ? glfwGetPrimaryMonitor() : 0, 0);
  44.  
  45. if (!fullScreen) {
  46. glfwSetWindowPos(window, (vidMode.width() - width) / 2, (vidMode.height() - height) / 2);
  47. } else {
  48. this.width = vidMode.width();
  49. this.height = vidMode.height();
  50. }
  51.  
  52. glfwMakeContextCurrent(window);
  53.  
  54. createCapabilities();
  55. }
Add Comment
Please, Sign In to add comment