Implemented linux swap control through GLX_SGI_swap_control

This commit is contained in:
Elias Naur 2004-01-03 08:09:17 +00:00
parent cfb462a29a
commit b5194bbb04
3 changed files with 30 additions and 14 deletions

View File

@ -87,6 +87,9 @@ glXWaitXPROC glXWaitX = NULL;
glXGetClientStringPROC glXGetClientString = NULL;
glXQueryServerStringPROC glXQueryServerString = NULL;
glXQueryExtensionsStringPROC glXQueryExtensionsString = NULL;
/* GLX_SGI_swap_control */
glXSwapIntervalSGIPROC glXSwapIntervalSGI = NULL;
#endif
#ifdef _AGL
@ -2538,6 +2541,15 @@ static void extgl_InitGLXSupportedExtensions(JNIEnv *env, jobject ext_set, Displ
{
extgl_Extensions.GLX_EXT_visual_info = GLXQueryExtension(env, ext_set, disp, screen, "GLX_EXT_visual_info");
extgl_Extensions.GLX_EXT_visual_rating = GLXQueryExtension(env, ext_set, disp, screen, "GLX_EXT_visual_rating");
extgl_Extensions.GLX_SGI_swap_control = GLXQueryExtension(env, ext_set, disp, screen, "GLX_SGI_swap_control");
}
static void extgl_InitGLXSGISwapControl(JNIEnv *env, jobject ext_set)
{
if (extgl_Extensions.GLX_SGI_swap_control != 1)
return;
glXSwapIntervalSGI = (glXSwapIntervalSGIPROC)extgl_GetProcAddress("glXSwapIntervalSGI");
EXTGL_SANITY_CHECK(env, ext_set, GLX_SGI_swap_control)
}
bool extgl_InitGLX(JNIEnv *env, jobject ext_set, Display *disp, int screen)
@ -2556,6 +2568,7 @@ bool extgl_InitGLX(JNIEnv *env, jobject ext_set, Display *disp, int screen)
if (major > 1 || (major == 1 && minor >= 3))
extgl_Extensions.GLX13 = true;
extgl_InitGLX13(env, ext_set);
extgl_InitGLXSGISwapControl(env, ext_set);
return true;
}
#endif

View File

@ -539,6 +539,11 @@ extern glXGetClientStringPROC glXGetClientString;
extern glXQueryServerStringPROC glXQueryServerString;
extern glXQueryExtensionsStringPROC glXQueryExtensionsString;
/* GLX_SGI_swap_control */
typedef void (APIENTRY * glXSwapIntervalSGIPROC)(int interval);
extern glXSwapIntervalSGIPROC glXSwapIntervalSGI;
#endif /* X11 */
#ifdef _AGL
@ -5535,6 +5540,7 @@ struct ExtensionTypes
bool GLX13;
bool GLX_EXT_visual_info;
bool GLX_EXT_visual_rating;
bool GLX_SGI_swap_control;
#endif /* X11 */
bool OpenGL12;

View File

@ -68,6 +68,7 @@ static int current_width;
static bool input_released;
static bool dirty;
static bool vsync_enabled;
static bool minimized;
static bool focused;
static bool closerequested;
@ -182,7 +183,7 @@ static void createWindow(JNIEnv* env, Display *disp, int screen, XVisualInfo *vi
focused = true;
minimized = false;
closerequested = false;
vsync_enabled = false;
Window root_win;
Window win;
XSetWindowAttributes attribs;
@ -556,25 +557,21 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused
return focused;
}
/*
* Class: org_lwjgl_opengl_Window
* Method: nIsVSyncEnabled
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled
(JNIEnv * env, jclass clazz)
{
// Always return false
return false;
return vsync_enabled;
}
/*
* Class: org_lwjgl_opengl_Window
* Method: nSetVSyncEnabled
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled
(JNIEnv * env, jclass clazz, jboolean sync)
{
// Do nothing on Linux
if (extgl_Extensions.GLX_SGI_swap_control) {
bool vsync = sync == JNI_TRUE ? true : false;
if (vsync != vsync_enabled) {
int interval = vsync ? 1 : 0;
glXSwapIntervalSGI(interval);
vsync_enabled = vsync;
}
}
}