daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package alva.movableSquare.core;
  2.  
  3. import static org.lwjgl.glfw.GLFW.*;
  4. import static org.lwjgl.glfw.GLFW.GLFW_FALSE;
  5. import static org.lwjgl.glfw.GLFW.GLFW_SAMPLES;
  6. import static org.lwjgl.glfw.GLFW.GLFW_VERSION_MAJOR;
  7. import static org.lwjgl.glfw.GLFW.GLFW_VERSION_MINOR;
  8. import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
  9. import static org.lwjgl.glfw.GLFW.glfwDestroyWindow;
  10. import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
  11. import static org.lwjgl.glfw.GLFW.glfwInit;
  12. import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
  13. import static org.lwjgl.glfw.GLFW.glfwPollEvents;
  14. import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
  15. import static org.lwjgl.glfw.GLFW.glfwSwapInterval;
  16. import static org.lwjgl.glfw.GLFW.glfwWindowHint;
  17. import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
  18.  
  19. import org.lwjgl.opengl.GL;
  20. import org.lwjgl.opengl.GL11;
  21. import org.lwjgl.opengl.GL13;
  22.  
  23. public class Display {
  24.  
  25.     private static long identifier;
  26.  
  27.     private static int width, height, samples;
  28.     private static DisplayState state;
  29.     private static String title;
  30.  
  31.     public static void createDisplay(int width, int height, String title, DisplayState state, int samples) {
  32.         if (!glfwInit())
  33.             return;
  34.  
  35.         glfwWindowHint(GLFW_VERSION_MAJOR, 3);
  36.         glfwWindowHint(GLFW_VERSION_MINOR, 3);
  37.         glfwWindowHint(GLFW_SAMPLES, samples);
  38.  
  39.         if (state == DisplayState.WINDOWED) {
  40.             identifier = glfwCreateWindow(width, height, title, 0, 0);
  41.         } else if (state == DisplayState.BORDERLESS) {
  42.             glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
  43.             identifier = glfwCreateWindow(width, height, title, 0, 0);
  44.         } else if (state == DisplayState.FULLSCREEN) {
  45.             identifier = glfwCreateWindow(width, height, title, glfwGetPrimaryMonitor(), 0);
  46.         }
  47.  
  48.         glfwMakeContextCurrent(identifier);
  49.         GL.createCapabilities();
  50.  
  51.         glfwSwapInterval(0);
  52.        
  53.         GL11.glEnable(GL13.GL_MULTISAMPLE);
  54.  
  55.         Display.width = width;
  56.         Display.height = height;
  57.         Display.title = title;
  58.         Display.state = state;
  59.         Display.samples = samples;
  60.     }
  61.  
  62.     public static void updateDisplay() {
  63.         glfwPollEvents();
  64.         glfwSwapBuffers(identifier);
  65.     }
  66.  
  67.     public static void destroyDisplay() {
  68.         glfwDestroyWindow(identifier);
  69.     }
  70.  
  71.     public static int getWidth() {
  72.         return width;
  73.     }
  74.  
  75.     public static int getHeight() {
  76.         return height;
  77.     }
  78.  
  79.     public static int getSamples() {
  80.         return samples;
  81.     }
  82.  
  83.     public static DisplayState getState() {
  84.         return state;
  85.     }
  86.  
  87.     public static String getTitle() {
  88.         return title;
  89.     }
  90.  
  91.     public static boolean shouldClose() {
  92.         return glfwWindowShouldClose(identifier);
  93.     }
  94.  
  95.     public static long getIdentifier() {
  96.         return identifier;
  97.     }
  98.  
  99. }
RAW Paste Data
Top