When programming in LWJGL, Display.setVsyncEnabled(true) seems to have no effect on tearing in fullscreen mode. Here is my code where I create the Display
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| public static void loadOpenGL(int width, int height, int fps) { if(!openGLLoaded) { Stage.width = width; Stage.height = height; Stage.fps = fps; try { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i=0;i<modes.length;i++) { DisplayMode current = modes[i]; System.out.println(current.getWidth() + "x" + current.getHeight() + "x" + current.getBitsPerPixel() + " " + current.getFrequency() + "Hz"); } Display.setTitle(title); Display.setDisplayMode(new DisplayMode(Stage.width, Stage.height)); Display.setDisplayMode(modes[19]); Display.setFullscreen(true); Display.setVSyncEnabled(true); Display.create(); } catch(LWJGLException e) { e.printStackTrace(); } GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glLoadIdentity(); GL11.glOrtho(0, Stage.width, Stage.height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor3f(1, 1, 1); Resources.init(); openGLLoaded = true; } } |
Here is my update method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| private static void run() { root = new ListContainer(); Stage.room.enter(Stage.root); long lastFrame; while(!Display.isCloseRequested() && !isCloseRequested) { lastFrame = getTime(); int delta = fps * 1000; if(Display.isActive()) { rendersNext = true; if(clears) GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
root.render(); delta = (int)(getTime() - lastFrame); Stage.room.update(delta);
} Display.update(); Music.poll(delta); SoundStore.get().poll(0); } Display.destroy(); AL.destroy(); }
|
The application DOES go into fullscreen mode, but there is terrible tearing going on despite the fact that I've enabled VSync. Am I missing something here?