mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
Linux: Handle different GLX capabilities on different screens
This commit is contained in:
parent
165084e12d
commit
bdcb68a582
9 changed files with 277 additions and 259 deletions
|
|
@ -48,7 +48,7 @@
|
|||
#include "Window.h"
|
||||
|
||||
typedef struct {
|
||||
bool glx13;
|
||||
GLXExtensions extension_flags;
|
||||
GLXContext context;
|
||||
} X11Context;
|
||||
|
||||
|
|
@ -58,8 +58,8 @@ static bool checkContext(JNIEnv *env, Display *display, GLXContext context) {
|
|||
return false;
|
||||
}
|
||||
jboolean allow_software_acceleration = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");
|
||||
if (!allow_software_acceleration && glXIsDirect(display, context) == False) {
|
||||
glXDestroyContext(display, context);
|
||||
if (!allow_software_acceleration && _glXIsDirect(display, context) == False) {
|
||||
_glXDestroyContext(display, context);
|
||||
throwException(env, "Could not create a direct GLX context");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -70,11 +70,10 @@ static void createContextGLX13(JNIEnv *env, X11PeerInfo *peer_info, X11Context *
|
|||
GLXFBConfig *config = getFBConfigFromPeerInfo(env, peer_info);
|
||||
if (config == NULL)
|
||||
return;
|
||||
GLXContext context = glXCreateNewContext(peer_info->display, *config, GLX_RGBA_TYPE, shared_context, True);
|
||||
GLXContext context = _glXCreateNewContext(peer_info->display, *config, GLX_RGBA_TYPE, shared_context, True);
|
||||
XFree(config);
|
||||
if (!checkContext(env, peer_info->display, context))
|
||||
return;
|
||||
context_info->glx13 = true;
|
||||
context_info->context = context;
|
||||
}
|
||||
|
||||
|
|
@ -82,20 +81,20 @@ static void createContextGLX(JNIEnv *env, X11PeerInfo *peer_info, X11Context *co
|
|||
XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
|
||||
if (vis_info == NULL)
|
||||
return;
|
||||
GLXContext context = glXCreateContext(peer_info->display, vis_info, shared_context, True);
|
||||
GLXContext context = _glXCreateContext(peer_info->display, vis_info, shared_context, True);
|
||||
XFree(vis_info);
|
||||
if (!checkContext(env, peer_info->display, context))
|
||||
return;
|
||||
context_info->glx13 = false;
|
||||
context_info->context = context;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSetVSync
|
||||
(JNIEnv *env, jclass clazz, jboolean sync)
|
||||
(JNIEnv *env, jclass clazz, jobject context_handle, jboolean sync)
|
||||
{
|
||||
if (extension_flags.GLX_SGI_swap_control) {
|
||||
X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
|
||||
if (context_info->extension_flags.GLX_SGI_swap_control) {
|
||||
int interval = sync == JNI_TRUE ? 1 : 0;
|
||||
glXSwapIntervalSGI(interval);
|
||||
_glXSwapIntervalSGI(interval);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +107,8 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCrea
|
|||
}
|
||||
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
|
||||
X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
|
||||
|
||||
if (!extgl_InitGLX(peer_info->display, peer_info->screen)) {
|
||||
GLXExtensions extension_flags;
|
||||
if (!extgl_InitGLX(peer_info->display, peer_info->screen, &extension_flags)) {
|
||||
throwException(env, "Could not initialize GLX");
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -123,6 +122,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nCrea
|
|||
} else {
|
||||
createContextGLX(env, peer_info, context_info, shared_context);
|
||||
}
|
||||
context_info->extension_flags = extension_flags;
|
||||
return context_handle;
|
||||
}
|
||||
|
||||
|
|
@ -130,17 +130,17 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nDestroy
|
|||
(JNIEnv *env, jclass clazz, jobject peer_handle, jobject context_handle) {
|
||||
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_handle);
|
||||
X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
|
||||
glXDestroyContext(peer_info->display, context_info->context);
|
||||
_glXDestroyContext(peer_info->display, context_info->context);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nReleaseCurrentContext
|
||||
(JNIEnv *env , jclass clazz, jobject peer_info_handle) {
|
||||
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
|
||||
Bool result;
|
||||
if (extension_flags.GLX13) {
|
||||
result = glXMakeContextCurrent(peer_info->display, None, None, NULL);
|
||||
if (peer_info->glx13) {
|
||||
result = _glXMakeContextCurrent(peer_info->display, None, None, NULL);
|
||||
} else {
|
||||
result = glXMakeCurrent(peer_info->display, None, NULL);
|
||||
result = _glXMakeCurrent(peer_info->display, None, NULL);
|
||||
}
|
||||
if (!result)
|
||||
throwException(env, "Could not release current context");
|
||||
|
|
@ -151,10 +151,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCur
|
|||
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
|
||||
X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
|
||||
Bool result;
|
||||
if (context_info->glx13) {
|
||||
result = glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context);
|
||||
if (peer_info->glx13) {
|
||||
result = _glXMakeContextCurrent(peer_info->display, peer_info->drawable, peer_info->drawable, context_info->context);
|
||||
} else {
|
||||
result = glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context);
|
||||
result = _glXMakeCurrent(peer_info->display, peer_info->drawable, context_info->context);
|
||||
}
|
||||
if (!result)
|
||||
throwException(env, "Could not make context current");
|
||||
|
|
@ -163,11 +163,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nMakeCur
|
|||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nIsCurrent
|
||||
(JNIEnv *env, jclass clazz, jobject context_handle) {
|
||||
X11Context *context_info = (*env)->GetDirectBufferAddress(env, context_handle);
|
||||
return context_info->context == glXGetCurrentContext();
|
||||
return context_info->context == _glXGetCurrentContext();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxContextImplementation_nSwapBuffers
|
||||
(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
|
||||
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
|
||||
glXSwapBuffers(peer_info->display, peer_info->drawable);
|
||||
_glXSwapBuffers(peer_info->display, peer_info->drawable);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue