Added Sys setPriority support
This commit is contained in:
parent
0b4f524ff9
commit
43698ade7c
|
@ -152,6 +152,7 @@ public final class Game {
|
||||||
Keyboard.enableBuffer();
|
Keyboard.enableBuffer();
|
||||||
Mouse.create();
|
Mouse.create();
|
||||||
Sys.setTime(0);
|
Sys.setTime(0);
|
||||||
|
Sys.setProcessPriority(Sys.REALTIME_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.
|
||||||
gl.matrixMode(GL.PROJECTION);
|
gl.matrixMode(GL.PROJECTION);
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
|
|
||||||
Display * disp;
|
Display * disp;
|
||||||
int screen;
|
int screen;
|
||||||
|
int current_fullscreen;
|
||||||
Window win;
|
Window win;
|
||||||
XF86VidModeModeInfo **avail_modes;
|
XF86VidModeModeInfo **avail_modes;
|
||||||
XVisualInfo * vis_info;
|
XVisualInfo * vis_info;
|
||||||
|
@ -92,6 +93,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate(JNIEnv * env, jclass c
|
||||||
int attriblist[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_RED_SIZE, bpe, GLX_GREEN_SIZE, bpe, GLX_BLUE_SIZE, bpe, GLX_ALPHA_SIZE, bpe, None};
|
int attriblist[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_RED_SIZE, bpe, GLX_GREEN_SIZE, bpe, GLX_BLUE_SIZE, bpe, GLX_ALPHA_SIZE, bpe, None};
|
||||||
int num_modes, i;
|
int num_modes, i;
|
||||||
|
|
||||||
|
current_fullscreen = fullscreen;
|
||||||
disp = XOpenDisplay(NULL);
|
disp = XOpenDisplay(NULL);
|
||||||
if (disp == NULL) {
|
if (disp == NULL) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -159,13 +161,15 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate(JNIEnv * env, jclass c
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Display_nDestroy(JNIEnv * env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_Display_nDestroy(JNIEnv * env, jclass clazz) {
|
||||||
XDestroyWindow(disp, win);
|
XDestroyWindow(disp, win);
|
||||||
if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[0])) {
|
if (current_fullscreen) {
|
||||||
|
if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[0])) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("Could not switch mode\n");
|
printf("Could not switch mode\n");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
XFree(avail_modes);
|
||||||
}
|
}
|
||||||
XFree(vis_info);
|
XFree(vis_info);
|
||||||
XFree(avail_modes);
|
|
||||||
XCloseDisplay(disp);
|
XCloseDisplay(disp);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("Closed X connection\n");
|
printf("Closed X connection\n");
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include "org_lwjgl_Sys.h"
|
#include "org_lwjgl_Sys.h"
|
||||||
|
|
||||||
long int hires_timer_freq; // Hires timer frequency
|
long int hires_timer_freq; // Hires timer frequency
|
||||||
|
@ -128,29 +129,27 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
||||||
(JNIEnv * env, jclass clazz, jint priority)
|
(JNIEnv * env, jclass clazz, jint priority)
|
||||||
{
|
{
|
||||||
/* HANDLE me = GetCurrentProcess();
|
int linux_priority;
|
||||||
int win32priority;
|
|
||||||
|
|
||||||
switch (priority) {
|
switch (priority) {
|
||||||
case org_lwjgl_Sys_REALTIME_PRIORITY:
|
case org_lwjgl_Sys_REALTIME_PRIORITY:
|
||||||
win32priority = REALTIME_PRIORITY_CLASS;
|
linux_priority = -20;
|
||||||
break;
|
break;
|
||||||
case org_lwjgl_Sys_HIGH_PRIORITY:
|
case org_lwjgl_Sys_HIGH_PRIORITY:
|
||||||
win32priority = HIGH_PRIORITY_CLASS;
|
linux_priority = -10;
|
||||||
break;
|
break;
|
||||||
case org_lwjgl_Sys_NORMAL_PRIORITY:
|
case org_lwjgl_Sys_NORMAL_PRIORITY:
|
||||||
win32priority = NORMAL_PRIORITY_CLASS;
|
linux_priority = 0;
|
||||||
break;
|
break;
|
||||||
case org_lwjgl_Sys_LOW_PRIORITY:
|
case org_lwjgl_Sys_LOW_PRIORITY:
|
||||||
win32priority = IDLE_PRIORITY_CLASS;
|
linux_priority = 20;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetPriorityClass(me, win32priority)) {
|
if (setpriority(PRIO_PROCESS, 0, linux_priority) == -1) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
printf("Failed to set priority class.\n");
|
printf("Failed to set priority.\n");
|
||||||
#endif
|
#endif
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue