Java Code Examples for org.lwjgl.opengl.Display#setVSyncEnabled()
The following examples show how to use
org.lwjgl.opengl.Display#setVSyncEnabled() .
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 LowPolyWater with The Unlicense | 6 votes |
protected Window(Context context, WindowBuilder settings) { this.fpsCap = settings.getFpsCap(); try { getSuitableFullScreenModes(); DisplayMode resolution = getStartResolution(settings); Display.setInitialBackground(1, 1, 1); this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight(); setResolution(resolution, settings.isFullScreen()); if (settings.hasIcon()) { Display.setIcon(settings.getIcon()); } Display.setVSyncEnabled(settings.isvSync()); Display.setTitle(settings.getTitle()); Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs()); GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight()); } catch (LWJGLException e) { e.printStackTrace(); } }
Example 2
Source File: Graphics.java From AnyaBasic with MIT License | 6 votes |
public Graphics( int screenWidth, int screenHeight, int vsynch ) { super( screenWidth, screenHeight ); if( vsynch != 0) { Display.setVSyncEnabled( true ); } spriteFont = new SpriteFont( new ImageAtlas( new ImageTextureDataFont(), 32, 32, GL11.GL_NEAREST )); glowImages = new ImageAtlas( new ImageTextureDataGlowSprites(), GL11.GL_LINEAR, 0 ); }
Example 3
Source File: AppletGameContainer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Start the game container * * @throws Exception Failure to create display */ public void start() throws Exception { Display.setParent(displayParent); Display.setVSyncEnabled(true); try { createDisplay(); } catch (LWJGLException e) { e.printStackTrace(); // failed to create Display, apply workaround (sleep for 1 second) and try again Thread.sleep(1000); createDisplay(); } initGL(); displayParent.requestFocus(); container.runloop(); }
Example 4
Source File: GLProgram.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initializes the application in fullscreen mode. * * @param vsync Enables/disables the vertical-sync feature, where the rendering is in sync with the monitor's refresh rate. * With v-sync off, there is no framerate cap and the gameloop will run as fast as the hardware can handle. * A framerate can be set with the <code>setFPS(int fps)</code> method. */ public GLProgram(boolean vsync) { try { Display.setFullscreen(true); Display.setVSyncEnabled(vsync); } catch(Exception exc) { exc.printStackTrace(); } }
Example 5
Source File: TestUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Initialise the GL display * * @param width The width of the display * @param height The height of the display */ private void initGL(int width, int height) { try { Display.setDisplayMode(new DisplayMode(width,height)); Display.create(); Display.setVSyncEnabled(true); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearDepth(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,width,height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); }
Example 6
Source File: TwlTest.java From tablelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void main (String[] args) throws Exception { System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath()); Display.setTitle("TWL Examples"); Display.setDisplayMode(new DisplayMode(800, 600)); Display.setVSyncEnabled(true); Display.create(); new TwlTest(); }
Example 7
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 8
Source File: GameContainer.java From opsu with GNU General Public License v3.0 | 2 votes |
/** * Indicate whether the display should be synced to the * vertical refresh (stops tearing) * * @param vsync True if we want to sync to vertical refresh */ public void setVSync(boolean vsync) { this.vsync = vsync; Display.setVSyncEnabled(vsync); }
Example 9
Source File: GameContainer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Indicate whether the display should be synced to the * vertical refresh (stops tearing) * * @param vsync True if we want to sync to vertical refresh */ public void setVSync(boolean vsync) { this.vsync = vsync; Display.setVSyncEnabled(vsync); }