Added Sys setPriority support

This commit is contained in:
Elias Naur 2002-11-16 20:10:42 +00:00
parent 0b4f524ff9
commit 43698ade7c
3 changed files with 17 additions and 13 deletions

View File

@ -152,6 +152,7 @@ public final class Game {
Keyboard.enableBuffer();
Mouse.create();
Sys.setTime(0);
Sys.setProcessPriority(Sys.REALTIME_PRIORITY);
System.out.println("Timer resolution: " + Sys.getTimerResolution());
// Go into orthographic projection mode.
gl.matrixMode(GL.PROJECTION);

View File

@ -54,6 +54,7 @@
Display * disp;
int screen;
int current_fullscreen;
Window win;
XF86VidModeModeInfo **avail_modes;
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 num_modes, i;
current_fullscreen = fullscreen;
disp = XOpenDisplay(NULL);
if (disp == NULL) {
#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) {
XDestroyWindow(disp, win);
if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[0])) {
if (current_fullscreen) {
if (!XF86VidModeSwitchToMode(disp, screen, avail_modes[0])) {
#ifdef _DEBUG
printf("Could not switch mode\n");
printf("Could not switch mode\n");
#endif
}
XFree(avail_modes);
}
XFree(vis_info);
XFree(avail_modes);
XCloseDisplay(disp);
#ifdef _DEBUG
printf("Closed X connection\n");

View File

@ -40,6 +40,7 @@
*/
#include <sys/time.h>
#include <sys/resource.h>
#include "org_lwjgl_Sys.h"
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
(JNIEnv * env, jclass clazz, jint priority)
{
/* HANDLE me = GetCurrentProcess();
int win32priority;
int linux_priority;
switch (priority) {
case org_lwjgl_Sys_REALTIME_PRIORITY:
win32priority = REALTIME_PRIORITY_CLASS;
linux_priority = -20;
break;
case org_lwjgl_Sys_HIGH_PRIORITY:
win32priority = HIGH_PRIORITY_CLASS;
linux_priority = -10;
break;
case org_lwjgl_Sys_NORMAL_PRIORITY:
win32priority = NORMAL_PRIORITY_CLASS;
linux_priority = 0;
break;
case org_lwjgl_Sys_LOW_PRIORITY:
win32priority = IDLE_PRIORITY_CLASS;
linux_priority = 20;
break;
default:
return;
}
if (!SetPriorityClass(me, win32priority)) {
if (setpriority(PRIO_PROCESS, 0, linux_priority) == -1) {
#ifdef _DEBUG
printf("Failed to set priority class.\n");
printf("Failed to set priority.\n");
#endif
}*/
}
}