Skip to content

Commit 80ef896

Browse files
committed
disable VSync when target fps is over 60
1 parent f66e406 commit 80ef896

2 files changed

Lines changed: 29 additions & 16 deletions

File tree

java/libraries/lwjgl/src/processing/lwjgl/PLWJGL.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,20 @@ public Canvas getCanvas() {
109109
}
110110

111111

112-
protected void setFps(float fps) {
113-
if (!setFps || targetFps != fps) {
114-
if (60 < fps) {
115-
// Disables v-sync
116-
Display.setVSyncEnabled(false);
117-
Display.sync((int)fps);
118-
} else {
119-
Display.setVSyncEnabled(true);
120-
}
121-
targetFps = currentFps = fps;
122-
setFps = true;
123-
}
124-
}
112+
// protected void setFps(float fps) {
113+
// if (!setFps || targetFps != fps) {
114+
// if (60 < fps) {
115+
// // Disables v-sync
116+
// System.err.println("Disabling VSync");
117+
// Display.setVSyncEnabled(false);
118+
//// Display.sync((int)fps);
119+
// } else {
120+
// Display.setVSyncEnabled(true);
121+
// }
122+
// targetFps = currentFps = fps;
123+
// setFps = true;
124+
// }
125+
// }
125126

126127
/*
127128
protected void initSurface(int antialias) {

java/libraries/lwjgl/src/processing/lwjgl/PSurfaceLWJGL.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ public void setTitle(String title) {
204204

205205
@Override
206206
public void setVisible(boolean visible) {
207+
// Apparently not possible:
208+
// http://forum.lwjgl.org/index.php?topic=5388.0
209+
System.err.println("Sorry, cannot set visibility of window in OpenGL");
207210
}
208211

209212
@Override
@@ -328,14 +331,21 @@ public void setSmooth(int level) {
328331
@Override
329332
public void setFrameRate(float fps) {
330333
frameRateTarget = fps;
331-
// frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
334+
// frameRatePeriod = (long) (1000000000.0 / frameRateTarget);
335+
if (60 < fps) {
336+
// Disables v-sync
337+
System.err.println("Disabling VSync");
338+
Display.setVSyncEnabled(false);
339+
// Display.sync((int)fps);
340+
} else {
341+
Display.setVSyncEnabled(true);
342+
}
332343
}
333344

334345

335346
@Override
336347
public void requestFocus() {
337348
// TODO Auto-generated method stub
338-
339349
}
340350

341351

@@ -439,7 +449,8 @@ public void run() { // not good to make this synchronized, locks things up
439449
// System.err.println(mode.toString());
440450
// }
441451

442-
452+
System.err.println("DISPLAY PARENT: " + Display.getParent());
453+
443454
Display.setDisplayMode(new DisplayMode(sketchWidth, sketchHeight));
444455
System.err.println(sketchWidth + " " + sketchHeight);
445456
if (fullScreenRequested) {
@@ -569,6 +580,7 @@ public void setResizable(boolean resizable) {
569580
public void setVisible(boolean visible) {
570581
// Display.isVisible()
571582
// Display.setVisible(visible);
583+
System.err.println("Sorry, cannot set visibility of window in OpenGL");
572584
}
573585

574586
@Override

0 commit comments

Comments
 (0)