mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
New vsync code
This commit is contained in:
parent
b6390ef976
commit
2714842095
10 changed files with 117 additions and 72 deletions
|
|
@ -1407,24 +1407,6 @@ public abstract class GL extends CoreGL14 implements GLConstants {
|
|||
|
||||
// public static native int wglGetPbufferDCARB(int hPbuffer);
|
||||
|
||||
/* public static native boolean wglGetPixelFormatAttribfvARB(
|
||||
int hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
int nAttributes,
|
||||
int piAttributes,
|
||||
int pfValues);
|
||||
|
||||
public static native boolean wglGetPixelFormatAttribivARB(
|
||||
int hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
int nAttributes,
|
||||
int piAttributes,
|
||||
int piValues);
|
||||
*/
|
||||
public static native int wglGetSwapIntervalEXT();
|
||||
|
||||
/* public static native boolean wglMakeContextCurrentARB(
|
||||
int hDrawDC,
|
||||
int hReadDC,
|
||||
|
|
@ -1441,29 +1423,7 @@ public abstract class GL extends CoreGL14 implements GLConstants {
|
|||
int hPbuffer,
|
||||
int iBuffer);
|
||||
|
||||
/* public static native boolean wglRestoreBufferRegionARB(
|
||||
Buffer hRegion,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int xSrc,
|
||||
int ySrc);
|
||||
|
||||
public static native boolean wglSaveBufferRegionARB(
|
||||
Buffer hRegion,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
*/
|
||||
/* public static native boolean wglSetPbufferAttribARB(
|
||||
int hPbuffer,
|
||||
int piAttribList);
|
||||
*/
|
||||
public static native boolean wglSwapIntervalEXT(int interval);
|
||||
|
||||
public static native void glWindowPos2fARB(float x, float y);
|
||||
public static native void glWindowPos2fARB(float x, float y);
|
||||
|
||||
public static native void glWindowPos2iARB(int x, int y);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.lwjgl.Display;
|
|||
import org.lwjgl.Sys;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class Window {
|
||||
|
||||
|
|
@ -54,8 +53,9 @@ public final class Window {
|
|||
* I have posted a bug report to apple regarding the behaviour.
|
||||
*
|
||||
*/
|
||||
if (Display.getPlatform() == Display.PLATFORM_AGL)
|
||||
if (Display.getPlatform() == Display.PLATFORM_AGL) {
|
||||
MacOSX.initMacOSX();
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether the window is currently created, ie. has a native peer */
|
||||
|
|
@ -93,6 +93,9 @@ public final class Window {
|
|||
|
||||
/** Fullscreen */
|
||||
private static boolean fullscreen;
|
||||
|
||||
/** Vsync */
|
||||
private static boolean vsync;
|
||||
|
||||
/** Tracks VBO state for the window context */
|
||||
private static VBOTracker vbo_tracker;
|
||||
|
|
@ -364,4 +367,35 @@ public final class Window {
|
|||
* to handle window close requests, moves, paints, etc.
|
||||
*/
|
||||
public static native void update();
|
||||
|
||||
/**
|
||||
* Determines to the best of the platform's ability whether monitor vysnc is enabled on
|
||||
* this window. The failsafe assumption is that when vsync cannot be determined, this
|
||||
* method returns false, and you should rely on using a hires timer to throttle your
|
||||
* framerate rather than relying on monitor sync (even if monitor sync is actually working).
|
||||
* Therefore you can guarantee that if we return true from this method that we're pretty
|
||||
* certain vsync is enabled.
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isVSyncEnabled() {
|
||||
assert isCreated() : "Cannot determine sync of uncreated window";
|
||||
return nIsVSyncEnabled();
|
||||
}
|
||||
|
||||
private static native boolean nIsVSyncEnabled();
|
||||
|
||||
/**
|
||||
* Enable or disable vertical monitor synchronization. This call is a best-attempt at changing
|
||||
* the vertical refresh synchronization of the monitor, and is not guaranteed to be successful.
|
||||
* To check whether the call <em>might</em> have been successful, call isVSyncEnabled().
|
||||
* @param sync true to synchronize; false to ignore synchronization
|
||||
*/
|
||||
public static void setVSyncEnabled(boolean sync) {
|
||||
assert isCreated() : "Cannot set sync of uncreated window";
|
||||
nSetVSyncEnabled(sync);
|
||||
}
|
||||
|
||||
private static native boolean nSetVSyncEnabled(boolean sync);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,9 +338,7 @@ public class HWCursorTest {
|
|||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
//sync frame (only works on windows)
|
||||
if (GLCaps.WGL_EXT_swap_control) {
|
||||
GL.wglSwapIntervalEXT(1);
|
||||
}
|
||||
Window.setVSyncEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -315,9 +315,7 @@ public class FullScreenWindowedTest {
|
|||
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
//sync frame (only works on windows)
|
||||
if (GLCaps.WGL_EXT_swap_control) {
|
||||
GL.wglSwapIntervalEXT(1);
|
||||
}
|
||||
Window.setVSyncEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -386,9 +386,8 @@ public class PbufferTest {
|
|||
*/
|
||||
private void glInit() {
|
||||
//sync frame (only works on windows)
|
||||
if (GLCaps.WGL_EXT_swap_control) {
|
||||
GL.wglSwapIntervalEXT(1);
|
||||
}
|
||||
Window.setVSyncEnabled(true);
|
||||
|
||||
GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
|
||||
GL.glEnable(GL.GL_TEXTURE_2D);
|
||||
// Create shared texture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue