Removed Sys.setTime(), Sys.getPlatform()
Changed Sys.getTime() Added Display.sync()
This commit is contained in:
parent
3bb53392f6
commit
b697fb3ecf
|
@ -60,19 +60,8 @@ public final class Display {
|
||||||
/** Whether or not the display has been requested to shutdown by the user */
|
/** Whether or not the display has been requested to shutdown by the user */
|
||||||
private static boolean closeRequested = false;
|
private static boolean closeRequested = false;
|
||||||
|
|
||||||
/*
|
/** Timer for sync() */
|
||||||
* Platforms. This will let you determine which platform you are running
|
private static long timeNow, timeThen;
|
||||||
* on, which is handy to know for some GL context calls.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Windows platform */
|
|
||||||
public static final int PLATFORM_WGL = 0;
|
|
||||||
|
|
||||||
/** GLX (Linux/Unix) platform */
|
|
||||||
public static final int PLATFORM_GLX = 1;
|
|
||||||
|
|
||||||
/** MacOSX platform */
|
|
||||||
public static final int PLATFORM_AGL = 2;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Sys.initialize();
|
Sys.initialize();
|
||||||
|
@ -177,16 +166,6 @@ public final class Display {
|
||||||
return mode.freq;
|
return mode.freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the operating system windowing platform. This will be one of the
|
|
||||||
* constants defined above. There is no "unknown" platform; a native library port
|
|
||||||
* has to provide a unique platform number for this mechanism to work. If the LWJGL
|
|
||||||
* is ported to, say, QNX, we will have a PLATFORM_QNX at the ready.
|
|
||||||
*
|
|
||||||
* @return the windowing system
|
|
||||||
*/
|
|
||||||
public static native int getPlatform();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the display configuration to the specified gamma, brightness and contrast.
|
* Set the display configuration to the specified gamma, brightness and contrast.
|
||||||
* The configuration changes will be reset when resetDisplayMode is called.
|
* The configuration changes will be reset when resetDisplayMode is called.
|
||||||
|
@ -251,4 +230,20 @@ public final class Display {
|
||||||
*/
|
*/
|
||||||
public static native String getVersion();
|
public static native String getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronize the display to a capped frame rate.
|
||||||
|
* @param frameTime The desired frame time in seconds
|
||||||
|
*/
|
||||||
|
public static void sync(float frameRate) {
|
||||||
|
timeNow = Sys.getTime();
|
||||||
|
System.out.println(Sys.getTimerResolution());
|
||||||
|
System.out.println(timeNow+" "+timeThen+" "+((float) (timeNow - timeThen) / (float) Sys.getTimerResolution()));
|
||||||
|
while (timeNow > timeThen && (float) (timeNow - timeThen) / (float) Sys.getTimerResolution() < frameRate) {
|
||||||
|
// This is a system-friendly way of allowing other stuff to use CPU if it wants to
|
||||||
|
Thread.yield();
|
||||||
|
timeNow = Sys.getTime();
|
||||||
|
}
|
||||||
|
timeThen = timeNow;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public final class Sys {
|
||||||
/** The native library name */
|
/** The native library name */
|
||||||
private static String LIBRARY_NAME = "lwjgl";
|
private static String LIBRARY_NAME = "lwjgl";
|
||||||
|
|
||||||
/** The platform being executed on */
|
/** The platform adapter class name */
|
||||||
private static String PLATFORM;
|
private static String PLATFORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,13 +131,8 @@ public final class Sys {
|
||||||
throw new LinkageError("Version mismatch: jar version is '" + VERSION +
|
throw new LinkageError("Version mismatch: jar version is '" + VERSION +
|
||||||
"', native libary version is '" + native_version + "'");
|
"', native libary version is '" + native_version + "'");
|
||||||
setDebug(DEBUG);
|
setDebug(DEBUG);
|
||||||
setTime(0);
|
|
||||||
|
|
||||||
// check platform name, and default to awt
|
PLATFORM = System.getProperty("org.lwjgl.Sys.platform", "org.lwjgl.SwingAdapter");
|
||||||
PLATFORM = System.getProperty("org.lwjgl.Sys.platform");
|
|
||||||
if(PLATFORM == null) {
|
|
||||||
PLATFORM = "org.lwjgl.SwingAdapter";
|
|
||||||
}
|
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -173,20 +168,14 @@ public final class Sys {
|
||||||
/**
|
/**
|
||||||
* Gets the current value of the hires timer, in ticks. When the Sys class is first loaded
|
* Gets the current value of the hires timer, in ticks. When the Sys class is first loaded
|
||||||
* the hires timer is reset to 0. If no hires timer is present then this method will always
|
* the hires timer is reset to 0. If no hires timer is present then this method will always
|
||||||
* return whatever value the timer was last set to.
|
* return 0.<p><strong>NOTEZ BIEN</strong> that the hires timer WILL wrap around.
|
||||||
*
|
*
|
||||||
* @return the current hires time, in ticks.
|
* @return the current hires time, in ticks (always >= 0)
|
||||||
*/
|
*/
|
||||||
public static native long getTime();
|
public static long getTime() {
|
||||||
|
return ngetTime() & 0x7FFFFFFFFFFFFFFFL;
|
||||||
/**
|
}
|
||||||
* Sets the hires timer to a new time, specified in ticks.
|
private static native long ngetTime();
|
||||||
*
|
|
||||||
* @param time The new time, in ticks
|
|
||||||
* @see #getTime()
|
|
||||||
* @see #getTimerResolution()
|
|
||||||
*/
|
|
||||||
public static native void setTime(long time);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the process priority in a system independent way. Because of the various
|
* Set the process priority in a system independent way. Because of the various
|
||||||
|
|
|
@ -109,18 +109,9 @@ public class Game {
|
||||||
finished = true;
|
finished = true;
|
||||||
} else if (Window.isActive()) {
|
} else if (Window.isActive()) {
|
||||||
// The window is in the foreground, so we should play the game
|
// The window is in the foreground, so we should play the game
|
||||||
long timeThen = Sys.getTime();
|
|
||||||
logic();
|
logic();
|
||||||
render();
|
render();
|
||||||
// Stabilise the framerate if we haven't got vsync
|
org.lwjgl.Display.sync(FRAMETIME);
|
||||||
if (!Window.isVSyncEnabled()) {
|
|
||||||
long timeNow = Sys.getTime();
|
|
||||||
while ((float) (timeNow - timeThen) / (float) Sys.getTimerResolution() < FRAMETIME) {
|
|
||||||
// This is a system-friendly way of allowing other stuff to use CPU if it wants to
|
|
||||||
Thread.yield();
|
|
||||||
timeNow = Sys.getTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// The window is not in the foreground, so we can allow other stuff to run and
|
// The window is not in the foreground, so we can allow other stuff to run and
|
||||||
// infrequently update
|
// infrequently update
|
||||||
|
|
|
@ -36,9 +36,8 @@ import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
import org.lwjgl.Display;
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -108,14 +107,8 @@ public class Cursor {
|
||||||
// Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
|
// Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
|
||||||
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
|
||||||
|
|
||||||
switch(Display.getPlatform()) {
|
String osName = System.getProperty("os.name", "");
|
||||||
case Display.PLATFORM_GLX:
|
if (osName.startsWith("Win")) {
|
||||||
// create our cursor elements
|
|
||||||
cursors = new CursorElement[1];
|
|
||||||
cursors[0] = new CursorElement();
|
|
||||||
cursors[0].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1);
|
|
||||||
break;
|
|
||||||
case Display.PLATFORM_WGL:
|
|
||||||
// create our cursor elements
|
// create our cursor elements
|
||||||
cursors = new CursorElement[numImages];
|
cursors = new CursorElement[numImages];
|
||||||
for(int i=0; i<numImages; i++) {
|
for(int i=0; i<numImages; i++) {
|
||||||
|
@ -127,9 +120,12 @@ public class Cursor {
|
||||||
// offset to next image
|
// offset to next image
|
||||||
images_copy.position(width*height*(i+1));
|
images_copy.position(width*height*(i+1));
|
||||||
}
|
}
|
||||||
break;
|
} else if (osName.startsWith("Lin")) {
|
||||||
case Display.PLATFORM_AGL:
|
// create our cursor elements
|
||||||
break;
|
cursors = new CursorElement[1];
|
||||||
|
cursors[0] = new CursorElement();
|
||||||
|
cursors[0].cursorHandle = nCreateCursor(width, height, xHotspot, yHotspot, numImages, images_copy, images_copy.position(), delays, delays != null ? delays.position() : -1);
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,9 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.Display;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.opengl.Window;
|
import org.lwjgl.opengl.Window;
|
||||||
import org.lwjgl.LWJGLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -568,7 +567,7 @@ public class Mouse {
|
||||||
* shouldn't be called otherwise
|
* shouldn't be called otherwise
|
||||||
*/
|
*/
|
||||||
public static void updateCursor() {
|
public static void updateCursor() {
|
||||||
if (Display.getPlatform() == Display.PLATFORM_WGL && currentCursor != null && currentCursor.hasTimedOut()) {
|
if (System.getProperty("os.name").startsWith("Win") && currentCursor != null && currentCursor.hasTimedOut()) {
|
||||||
currentCursor.nextCursor();
|
currentCursor.nextCursor();
|
||||||
try {
|
try {
|
||||||
setNativeCursor(currentCursor);
|
setNativeCursor(currentCursor);
|
||||||
|
|
|
@ -35,9 +35,8 @@ import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.lwjgl.Display;
|
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
|
import org.lwjgl.Sys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
|
@ -141,18 +140,15 @@ public abstract class AL {
|
||||||
String seperator = System.getProperty("path.separator");
|
String seperator = System.getProperty("path.separator");
|
||||||
String jwsLibname;
|
String jwsLibname;
|
||||||
|
|
||||||
switch (Display.getPlatform()) {
|
String osName = System.getProperty("os.name");
|
||||||
case Display.PLATFORM_WGL:
|
if (osName.startsWith("Win")) {
|
||||||
jwsLibname = "lwjglaudio";
|
jwsLibname = "lwjglaudio";
|
||||||
break;
|
} else if (osName.startsWith("Lin")) {
|
||||||
case Display.PLATFORM_GLX:
|
|
||||||
jwsLibname = "openal";
|
jwsLibname = "openal";
|
||||||
break;
|
} else if (osName.startsWith("Mac")) {
|
||||||
case Display.PLATFORM_AGL:
|
|
||||||
jwsLibname = "openal";
|
jwsLibname = "openal";
|
||||||
break;
|
} else {
|
||||||
default:
|
throw new LWJGLException("Unknown platform: "+osName);
|
||||||
throw new LWJGLException("Unknown platform");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String jwsPath = getPathFromJWS(jwsLibname);
|
String jwsPath = getPathFromJWS(jwsLibname);
|
||||||
|
|
|
@ -510,23 +510,6 @@ public final class Window {
|
||||||
*/
|
*/
|
||||||
private static native void nUpdate();
|
private static native void nUpdate();
|
||||||
|
|
||||||
/**
|
|
||||||
* 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() {
|
|
||||||
if (!isCreated())
|
|
||||||
throw new IllegalStateException("Cannot determine vsync state of uncreated window");
|
|
||||||
return nIsVSyncEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static native boolean nIsVSyncEnabled();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable vertical monitor synchronization. This call is a best-attempt at changing
|
* 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.
|
* the vertical refresh synchronization of the monitor, and is not guaranteed to be successful.
|
||||||
|
|
|
@ -67,7 +67,6 @@ public class DisplayTest {
|
||||||
System.out.println("==== Test Current ====");
|
System.out.println("==== Test Current ====");
|
||||||
|
|
||||||
System.out.println("Info about current:");
|
System.out.println("Info about current:");
|
||||||
System.out.println("Platform: " + getNameForPlatform());
|
|
||||||
System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion());
|
System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion());
|
||||||
System.out.println("Resolution: " +
|
System.out.println("Resolution: " +
|
||||||
Display.getWidth() + "x" +
|
Display.getWidth() + "x" +
|
||||||
|
@ -228,24 +227,6 @@ public class DisplayTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a String representation of the platform
|
|
||||||
*
|
|
||||||
* @return String representation of the platform
|
|
||||||
*/
|
|
||||||
private String getNameForPlatform() {
|
|
||||||
switch (Display.getPlatform()) {
|
|
||||||
case Display.PLATFORM_WGL:
|
|
||||||
return "WGL";
|
|
||||||
case Display.PLATFORM_GLX:
|
|
||||||
return "GLX";
|
|
||||||
case Display.PLATFORM_AGL:
|
|
||||||
return "AGL";
|
|
||||||
default:
|
|
||||||
return "Unknown platform";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the Sys class, and serves as basic usage test
|
* Tests the Sys class, and serves as basic usage test
|
||||||
*
|
*
|
||||||
|
|
|
@ -148,7 +148,6 @@ public final class Game {
|
||||||
*/
|
*/
|
||||||
private static void init()
|
private static void init()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Sys.setTime(0);
|
|
||||||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
||||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
||||||
System.out.println("Number of texture units: " + Util.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS));
|
System.out.println("Number of texture units: " + Util.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS));
|
||||||
|
|
|
@ -196,8 +196,7 @@ public final class VBOIndexTest {
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
private static void init() throws Exception {
|
private static void init() throws Exception {
|
||||||
Sys.setTime(0);
|
|
||||||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
|
||||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
||||||
// Go into orthographic projection mode.
|
// Go into orthographic projection mode.
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
|
|
|
@ -176,8 +176,6 @@ public final class VBOTest {
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
private static void init() throws Exception {
|
private static void init() throws Exception {
|
||||||
Sys.setTime(0);
|
|
||||||
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
|
|
||||||
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
System.out.println("Timer resolution: " + Sys.getTimerResolution());
|
||||||
// Go into orthographic projection mode.
|
// Go into orthographic projection mode.
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||||
|
|
|
@ -45,20 +45,12 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: getTime
|
* Method: ngetTime
|
||||||
* Signature: ()J
|
* Signature: ()J
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTime
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
(JNIEnv *, jclass);
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setTime
|
|
||||||
* Signature: (J)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
|
||||||
(JNIEnv *, jclass, jlong);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: setProcessPriority
|
* Method: setProcessPriority
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2002 Light Weight Java Game Library Project
|
* Copyright (c) 2002 Light Weight Java Game Library Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -238,10 +237,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getPlatform(JNIEnv * env, jclass clazz) {
|
|
||||||
return org_lwjgl_Display_PLATFORM_GLX;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getGammaRampLength(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getGammaRampLength(JNIEnv *env, jclass clazz) {
|
||||||
return gamma_ramp_length;
|
return gamma_ramp_length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@
|
||||||
#include "org_lwjgl_Sys.h"
|
#include "org_lwjgl_Sys.h"
|
||||||
#include "common_tools.h"
|
#include "common_tools.h"
|
||||||
|
|
||||||
static long int hires_timer_freq; // Hires timer frequency
|
|
||||||
static long int hires_timer_start; // Hires timer start
|
|
||||||
static long int hires_timer; // Hires timer current time
|
static long int hires_timer; // Hires timer current time
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,7 +55,8 @@ static long int hires_timer; // Hires timer current time
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
return hires_timer_freq;
|
// Constant on linux
|
||||||
|
return 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long queryTime(void) {
|
static long queryTime(void) {
|
||||||
|
@ -76,29 +75,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebug(JNIEnv *env, jclass clazz, jb
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: getTime
|
* Method: ngetTime
|
||||||
* Signature: ()J
|
* Signature: ()J
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTime
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
hires_timer = queryTime();
|
hires_timer = queryTime();
|
||||||
hires_timer -= hires_timer_start;
|
return (jlong) hires_timer;
|
||||||
return hires_timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setTime
|
|
||||||
* Signature: (J)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
|
||||||
(JNIEnv * env, jclass clazz, jlong startTime)
|
|
||||||
{
|
|
||||||
hires_timer_start = queryTime();
|
|
||||||
// We don't have a real resolution so assume highest possible
|
|
||||||
hires_timer_freq = 1000000;
|
|
||||||
hires_timer_start -= startTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -613,12 +613,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsActive
|
||||||
return focused ? JNI_TRUE : JNI_FALSE;
|
return focused ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled
|
|
||||||
(JNIEnv * env, jclass clazz)
|
|
||||||
{
|
|
||||||
return vsync_enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled
|
||||||
(JNIEnv * env, jclass clazz, jboolean sync)
|
(JNIEnv * env, jclass clazz, jboolean sync)
|
||||||
{
|
{
|
||||||
|
|
|
@ -189,9 +189,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes(
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getPlatform(JNIEnv * env, jclass clazz) {
|
|
||||||
return org_lwjgl_Display_PLATFORM_AGL;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getGammaRampLength(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getGammaRampLength(JNIEnv *env, jclass clazz) {
|
||||||
return GAMMARAMP_LENGTH;
|
return GAMMARAMP_LENGTH;
|
||||||
|
|
|
@ -46,9 +46,7 @@
|
||||||
#include "org_lwjgl_Sys.h"
|
#include "org_lwjgl_Sys.h"
|
||||||
#include "common_tools.h"
|
#include "common_tools.h"
|
||||||
|
|
||||||
long int hires_timer_freq; // Hires timer frequency
|
static long int hires_timer; // Hires timer current time
|
||||||
long int hires_timer_start; // Hires timer start
|
|
||||||
long int hires_timer; // Hires timer current time
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
|
@ -58,7 +56,8 @@ long int hires_timer; // Hires timer current time
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
return hires_timer_freq;
|
// Constant on MacOS
|
||||||
|
return 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long queryTime(void) {
|
static long queryTime(void) {
|
||||||
|
@ -77,34 +76,20 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebug(JNIEnv *env, jclass clazz, jb
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: getTime
|
* Method: ngetTime
|
||||||
* Signature: ()J
|
* Signature: ()J
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTime
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
hires_timer = queryTime();
|
hires_timer = queryTime();
|
||||||
hires_timer -= hires_timer_start;
|
return (jlong) hires_timer;
|
||||||
return hires_timer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env, jclass clazz) {
|
||||||
return getVersionString(env);
|
return getVersionString(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setTime
|
|
||||||
* Signature: (J)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
|
||||||
(JNIEnv * env, jclass clazz, jlong startTime)
|
|
||||||
{
|
|
||||||
hires_timer_start = queryTime();
|
|
||||||
// We don't have a real resolution so assume highest possible
|
|
||||||
hires_timer_freq = 1000000;
|
|
||||||
hires_timer_start -= startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
|
|
|
@ -185,10 +185,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized(JNIEnv *env
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled(JNIEnv *env, jclass clazz) {
|
|
||||||
return vsync_enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVisible(JNIEnv *env, jclass clazz) {
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVisible(JNIEnv *env, jclass clazz) {
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,8 @@
|
||||||
// Handle to the application's window
|
// Handle to the application's window
|
||||||
extern HWND hwnd;
|
extern HWND hwnd;
|
||||||
|
|
||||||
unsigned __int64 hires_timer_freq; // Hires timer frequency
|
unsigned __int64 hires_timer_freq = 0; // Hires timer frequency
|
||||||
unsigned __int64 hires_timer_start; // Hires timer start
|
unsigned __int64 hires_timer = 0; // Hires timer current time
|
||||||
unsigned __int64 hires_timer; // Hires timer current time
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
|
@ -58,7 +57,8 @@ unsigned __int64 hires_timer; // Hires timer current time
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
return hires_timer_freq;
|
QueryPerformanceFrequency((LARGE_INTEGER*) &hires_timer_freq);
|
||||||
|
return (jlong) hires_timer_freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebug(JNIEnv *env, jclass clazz, jboolean enabled) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebug(JNIEnv *env, jclass clazz, jboolean enabled) {
|
||||||
|
@ -71,28 +71,14 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: getTime
|
* Method: ngetTime
|
||||||
* Signature: ()J
|
* Signature: ()J
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTime
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
(JNIEnv * env, jclass clazz)
|
(JNIEnv * env, jclass clazz)
|
||||||
{
|
{
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &hires_timer);
|
QueryPerformanceCounter((LARGE_INTEGER*) &hires_timer);
|
||||||
hires_timer -= hires_timer_start;
|
return (jlong) hires_timer;
|
||||||
return hires_timer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setTime
|
|
||||||
* Signature: (J)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
|
||||||
(JNIEnv * env, jclass clazz, jlong startTime)
|
|
||||||
{
|
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER*) &hires_timer_freq);
|
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*) &hires_timer_start);
|
|
||||||
hires_timer_start -= startTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -58,7 +58,6 @@ extern HINSTANCE dll_handle; // Handle to the LWJGL dll
|
||||||
RECT clientSize;
|
RECT clientSize;
|
||||||
|
|
||||||
static bool closerequested;
|
static bool closerequested;
|
||||||
static jboolean vsync;
|
|
||||||
static jboolean allowSoftwareOpenGL; // Whether to allow software opengl
|
static jboolean allowSoftwareOpenGL; // Whether to allow software opengl
|
||||||
|
|
||||||
//CAS: commented these out as no longer used
|
//CAS: commented these out as no longer used
|
||||||
|
@ -471,7 +470,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
isFullScreen = fullscreen == JNI_TRUE;
|
isFullScreen = fullscreen == JNI_TRUE;
|
||||||
isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
|
isUndecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
|
||||||
vsync = JNI_FALSE;
|
|
||||||
|
|
||||||
// Speacial option for allowing software opengl
|
// Speacial option for allowing software opengl
|
||||||
allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Window.allowSoftwareOpenGL");
|
allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Window.allowSoftwareOpenGL");
|
||||||
|
@ -586,17 +584,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsActive
|
||||||
return isFocused;
|
return isFocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_opengl_Window
|
|
||||||
* Method: nIsVSyncEnabled
|
|
||||||
* Signature: ()Z
|
|
||||||
*/
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled
|
|
||||||
(JNIEnv * env, jclass clazz)
|
|
||||||
{
|
|
||||||
return vsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Window
|
* Class: org_lwjgl_opengl_Window
|
||||||
* Method: nSetVSyncEnabled
|
* Method: nSetVSyncEnabled
|
||||||
|
@ -611,7 +598,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled
|
||||||
} else {
|
} else {
|
||||||
wglSwapIntervalEXT(0);
|
wglSwapIntervalEXT(0);
|
||||||
}
|
}
|
||||||
vsync = sync;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue