Java Code Examples for org.lwjgl.opengl.Display#getHeight()
The following examples show how to use
org.lwjgl.opengl.Display#getHeight() .
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: Example3_14.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) { width = 100; height = 100 / aspect; } else { width = 100 * aspect; height = 100; } glOrtho(-width, width, -height, height, 1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 2
Source File: Example3_10.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 3
Source File: Example2_2.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 1, -1); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 4
Source File: Example3_6.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 5
Source File: Example3_2.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 6
Source File: Example3_5.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 7
Source File: Example3_7.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 8
Source File: Example3_3.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 9
Source File: Example3_13.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 10
Source File: WindowParamsPersistingApplicationWrapper.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
private void saveWindowParams() { int width = Display.getWidth(); int height = Display.getHeight(); int x = Display.getX(); int y = Display.getY(); //FIXME For some reason actual window position shifted by 6 pixels on Windows (by 12 at y when maximized). if (LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS) { x += 6; y += 6; } Preferences prefs = Gdx.app.getPreferences("window_params.xml"); prefs.putInteger("x", x); prefs.putInteger("y", y); prefs.putInteger("width", width); prefs.putInteger("height", height); prefs.flush(); }
Example 11
Source File: Example3_11.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void resized() { int w = Display.getWidth(), h = Display.getHeight(); if(h == 0) h = 1; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = (float)w / h; if(w <= h) glOrtho(-100, 100, -100 / aspect, 100 / aspect, 100, -100); else glOrtho(-100 * aspect, 100 * aspect, -100, 100, 100, -100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
Example 12
Source File: DefaultController.java From Slyther with MIT License | 6 votes |
@Override public void update(SlytherClient client) { ClientSnake player = client.player; accelerating = Mouse.isButtonDown(0) || Mouse.isButtonDown(1); int mouseX = Mouse.getX() - (Display.getWidth() / 2); int mouseY = (Display.getHeight() - Mouse.getY()) - (Display.getHeight() / 2); if (mouseX != lastMouseX || mouseY != lastMouseY) { lastMouseX = mouseX; lastMouseY = mouseY; int dist = mouseX * mouseX + mouseY * mouseY; if (dist > 256) { targetAngle = (float) Math.atan2(mouseY, mouseX); player.eyeAngle = targetAngle; } else { targetAngle = player.wantedAngle; } } }
Example 13
Source File: VideoHook.java From malmo with MIT License | 6 votes |
/** * Resizes the window and the Minecraft rendering if necessary. Set renderWidth and renderHeight first. */ private void resizeIfNeeded() { // resize the window if we need to int oldRenderWidth = Display.getWidth(); int oldRenderHeight = Display.getHeight(); if( this.renderWidth == oldRenderWidth && this.renderHeight == oldRenderHeight ) return; try { int old_x = Display.getX(); int old_y = Display.getY(); Display.setLocation(old_x, old_y); Display.setDisplayMode(new DisplayMode(this.renderWidth, this.renderHeight)); System.out.println("Resized the window"); } catch (LWJGLException e) { System.out.println("Failed to resize the window!"); e.printStackTrace(); } forceResize(this.renderWidth, this.renderHeight); }
Example 14
Source File: DrawModelTest.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void resize() { //final int range = 100; glViewport(0, 0, Display.getWidth(), Display.getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect = Display.getWidth() / Display.getHeight(); gluPerspective(25.0f, aspect, 1.0f, 300.0f); //glOrtho(-range, range, -range*Display.getHeight()/Display.getWidth(), range*Display.getHeight()/Display.getWidth(), -range, range); glMatrixMode(GL_MODELVIEW); glTranslatef(0,0, -50); }
Example 15
Source File: SlytherClient.java From Slyther with MIT License | 5 votes |
private void setupDisplay() { int width = Display.getWidth(); int height = Display.getHeight(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glScissor(0, 0, width, height); GL11.glViewport(0, 0, width, height); renderHandler.init(); }
Example 16
Source File: Camera.java From LowPolyWater with The Unlicense | 5 votes |
private static Matrix4f createProjectionMatrix() { Matrix4f projectionMatrix = new Matrix4f(); float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight(); float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f)))); float x_scale = y_scale / aspectRatio; float frustum_length = FAR_PLANE - NEAR_PLANE; projectionMatrix.m00 = x_scale; projectionMatrix.m11 = y_scale; projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length); projectionMatrix.m23 = -1; projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length); projectionMatrix.m33 = 0; return projectionMatrix; }
Example 17
Source File: GLRenderer.java From amcgala with Educational Community License v2.0 | 4 votes |
@Override public int getHeight() { return Display.getHeight(); }
Example 18
Source File: ClientProxy.java From Fullscreen-Windowed-Minecraft with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void toggleFullScreen(boolean goFullScreen, int desiredMonitor) { //Set value if it isn't set already. if(System.getProperty("org.lwjgl.opengl.Window.undecorated") == null){ System.setProperty("org.lwjgl.opengl.Window.undecorated", "false"); } //If we're in actual fullscreen right now, then we need to fix that. if(Display.isFullscreen()) { fullscreen = true; } String expectedState = goFullScreen ? "true":"false"; // If all state is valid, there is nothing to do and we just exit. if(fullscreen == goFullScreen && !Display.isFullscreen()//Display in fullscreen mode: Change required && System.getProperty("org.lwjgl.opengl.Window.undecorated") == expectedState // Window not in expected state ) return; //Save our current display parameters Rectangle currentCoordinates = new Rectangle(Display.getX(), Display.getY(), Display.getWidth(), Display.getHeight()); if(goFullScreen && !Display.isFullscreen()) _savedWindowedBounds = currentCoordinates; //Changing this property and causing a Display update will cause LWJGL to add/remove decorations (borderless). System.setProperty("org.lwjgl.opengl.Window.undecorated",expectedState); //Get the fullscreen dimensions for the appropriate screen. Rectangle screenBounds = getAppropriateScreenBounds(currentCoordinates, desiredMonitor); //This is the new bounds we have to apply. Rectangle newBounds = goFullScreen ? screenBounds : _savedWindowedBounds; if(newBounds == null) newBounds = screenBounds; if(goFullScreen == false && ClientProxy.fullscreen == false) { newBounds = currentCoordinates; _savedWindowedBounds = currentCoordinates; } try { fullscreen = goFullScreen; client.fullscreen = fullscreen; if( client.gameSettings.fullScreen != fullscreen) { client.gameSettings.fullScreen = fullscreen; client.gameSettings.saveOptions(); } Display.setFullscreen(false); Display.setResizable(!goFullScreen); Display.setDisplayMode(new DisplayMode((int) newBounds.getWidth(), (int) newBounds.getHeight())); Display.setLocation(newBounds.x, newBounds.y); client.resize((int) newBounds.getWidth(), (int) newBounds.getHeight()); Display.setVSyncEnabled(client.gameSettings.enableVsync); client.updateDisplay(); } catch (LWJGLException e) { e.printStackTrace(); } }
Example 19
Source File: Configuration.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * @author http://wiki.lwjgl.org/index.php?title=Taking_Screen_Shots */ public void takeScreenShot() { // TODO: get a decent place for this // create the screenshot directory if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) { bubNotifs.sendf( BUB_RED, "Failed to create screenshot directory at '%s'.", screenshotDir.getAbsolutePath() ); return; } // create file name SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss"); final String fileName = String.format("screenshot_%s.%s", date.format(new Date()), OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase()); final File file = new File(screenshotDir, fileName); SoundController.playSound(SoundEffect.SHUTTER); // copy the screen to file final int width = Display.getWidth(); final int height = Display.getHeight(); final int bpp = 3; // assuming a 32-bit display with a byte each for red, green, blue, and alpha final ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * bpp); GL11.glReadBuffer(GL11.GL_FRONT); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer); new Thread() { @Override public void run() { try { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int i = (x + (width * y)) * bpp; int r = buffer.get(i) & 0xFF; int g = buffer.get(i + 1) & 0xFF; int b = buffer.get(i + 2) & 0xFF; image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); } } ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file); bubNotifs.send(BUB_PURPLE, "Created " + fileName); } catch (Exception e) { Log.error("Could not take screenshot", e); bubNotifs.send( BUB_PURPLE, "Failed to take a screenshot. See log file for details" ); } } }.start(); }
Example 20
Source File: GLProgram.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns the height of the window. * * @return The height of the window. */ public int getHeight() { return Display.getHeight(); }