Avoid passing GLX_SAMPLE* to glXChooseVisual if num_samples is zero

I think glXChooseVisual will return an error if GLX_SAMPLE* is present
even if we set it to False/0, so we might never get a context on old
hardware.
master
Graham 5 years ago
parent 4797bf6224
commit 6006f24027
  1. 24
      gl-natives/src/main/c/jaggl.c

@ -533,6 +533,7 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_choosePixelFormat1(JNIEnv *env, jc
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
bool double_buffered = i == 0; bool double_buffered = i == 0;
int attribs[] = { int attribs[] = {
GLX_RGBA, GLX_RGBA,
GLX_RED_SIZE, GLX_RED_SIZE,
@ -545,13 +546,26 @@ JNIEXPORT jboolean JNICALL Java_jaggl_context_choosePixelFormat1(JNIEnv *env, jc
alpha_bits, alpha_bits,
GLX_DEPTH_SIZE, GLX_DEPTH_SIZE,
24, 24,
GLX_SAMPLE_BUFFERS, None, /* for GLX_DOUBLEBUFFER */
num_samples ? True : False, None, /* for GLX_SAMPLE_BUFFERS */
GLX_SAMPLES, None, /* for True */
num_samples, None, /* for GLX_SAMPLES */
double_buffered ? GLX_DOUBLEBUFFER : None, None, /* for num_samples */
None None
}; };
int j = 11;
if (double_buffered) {
attribs[j++] = GLX_DOUBLEBUFFER;
}
if (num_samples) {
attribs[j++] = GLX_SAMPLE_BUFFERS;
attribs[j++] = True;
attribs[j++] = GLX_SAMPLES;
attribs[j++] = num_samples;
}
jaggl_visual_info = glXChooseVisual(jaggl_display, DefaultScreen(jaggl_display), attribs); jaggl_visual_info = glXChooseVisual(jaggl_display, DefaultScreen(jaggl_display), attribs);
if (jaggl_visual_info) { if (jaggl_visual_info) {
jaggl_double_buffered = double_buffered; jaggl_double_buffered = double_buffered;

Loading…
Cancel
Save