Java Code Examples for org.lwjgl.glfw.GLFWVidMode#width()
The following examples show how to use
org.lwjgl.glfw.GLFWVidMode#width() .
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: Window.java From mars-sim with GNU General Public License v3.0 | 5 votes |
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 2
Source File: GlfwAPI.java From WraithEngine with Apache License 2.0 | 4 votes |
@Override public int[] getScreenSize() { GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); return new int[] {vidmode.width(), vidmode.height()}; }
Example 3
Source File: OpenGLWindow.java From caliko with MIT License | 4 votes |
public OpenGLWindow(int windowWidth, int windowHeight, float vertFoVDegs, float zNear, float zFar, float orthoExtent) { // Set properties and create the projection matrix mWindowWidth = windowWidth <= 0 ? 1 : windowWidth; mWindowHeight = windowHeight <= 0 ? 1 : windowHeight; mAspectRatio = (float)mWindowWidth / (float)mWindowHeight; mVertFoVDegs = vertFoVDegs; mZNear = zNear; mZFar = zFar; mOrthoExtent = orthoExtent; if (Application.use3dDemo) { mOrthographicProjection = false; mProjectionMatrix = Mat4f.createPerspectiveProjectionMatrix(mVertFoVDegs, mAspectRatio, mZNear, mZFar); } else { mOrthographicProjection = true; mProjectionMatrix = Mat4f.createOrthographicProjectionMatrix(-mOrthoExtent, mOrthoExtent, mOrthoExtent, -mOrthoExtent, mZNear, mZFar); } // Setup the error callback to output to System.err glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err)); // Initialize GLFW. Most GLFW functions will not work before doing this. if ( !glfwInit() ) { throw new IllegalStateException("Unable to initialize GLFW"); } // ----- Specify window hints ----- // Note: Window hints must be specified after glfwInit() (which resets them) and before glfwCreateWindow where the context is created. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Request OpenGL version 3.3 (the minimum we can get away with) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // We want a core profile without any deprecated functionality... //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // ...however we do NOT want a forward compatible profile as they've removed line widths! glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); // We want the window to be resizable glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE); // We want the window to be visible (false makes it hidden after creation) glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE); // We want the window to take focus on creation glfwWindowHint(GLFW_SAMPLES, 4); // Ask for 4x anti-aliasing (this doesn't mean we'll get it, though) // Create the window mWindowId = glfwCreateWindow(mWindowWidth, mWindowHeight, "LWJGL3 Test", NULL, NULL); if (mWindowId == NULL) { throw new RuntimeException("Failed to create the GLFW window"); } // Get the resolution of the primary monitor GLFWVidMode vidmode = glfwGetVideoMode( glfwGetPrimaryMonitor() ); int windowHorizOffset = (vidmode.width() - mWindowWidth) / 2; int windowVertOffset = (vidmode.height() - mWindowHeight) / 2; glfwSetWindowPos(mWindowId, windowHorizOffset, windowVertOffset); // Center our window glfwMakeContextCurrent(mWindowId); // Make the OpenGL context current glfwSwapInterval(1); // Swap buffers every frame (i.e. enable vSync) // This line is critical for LWJGL's interoperation with GLFW's OpenGL context, or any context that is managed externally. // LWJGL detects the context that is current in the current thread, creates the ContextCapabilities instance and makes // the OpenGL bindings available for use. glfwMakeContextCurrent(mWindowId); // Enumerate the capabilities of the current OpenGL context, loading forward compatible capabilities GL.createCapabilities(true); // Setup our keyboard, mouse and window resize callback functions setupCallbacks(); // ---------- OpenGL settings ----------- // Set the clear color glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Specify the size of the viewport. Params: xOrigin, yOrigin, width, height glViewport(0, 0, mWindowWidth, mWindowHeight); // Enable depth testing glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); // When we clear the depth buffer, we'll clear the entire buffer glClearDepth(1.0f); // Enable blending to use alpha channels // Note: blending must be enabled to use transparency / alpha values in our fragment shaders. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glfwShowWindow(mWindowId); // Make the window visible }
Example 4
Source File: GlfwAPI.java From WraithEngine with Apache License 2.0 | 4 votes |
@Override public int[] getScreenSize() { GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); return new int[] {vidmode.width(), vidmode.height()}; }