Skip to content

Commit

Permalink
Support GL canvas without multisample support
Browse files Browse the repository at this point in the history
  • Loading branch information
olehkuznetsov committed Dec 19, 2024
1 parent 6f587a5 commit 3705bf6
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions gapic/src/platform/linux/com/google/gapid/glcanvas/GlCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ private static long chooseConfig(GLXCapabilities glxCaps, long display) {
set(attr, GLX.GLX_GREEN_SIZE, 8);
set(attr, GLX.GLX_BLUE_SIZE, 8);
set(attr, GLX.GLX_DEPTH_SIZE, 24);
if (glxCaps.GLX14 || glxCaps.GLX_ARB_multisample) {
set(attr, GLX14.GLX_SAMPLE_BUFFERS, 1);
set(attr, GLX14.GLX_SAMPLES, 4);
}
set(attr, X11.None, X11.None);

((Buffer)attr).flip(); // cast is there to work with JDK9.
Expand All @@ -140,10 +136,23 @@ private static long chooseConfig(GLXCapabilities glxCaps, long display) {
LOG.log(SEVERE, "glXChooseFBConfig returned no matching configs");
return -1;
}

long config = configs.get(0);
long selectedConfig = configs.get(0);
if (glxCaps.GLX14 || glxCaps.GLX_ARB_multisample) {
int sampleBuffers[] = new int[1];
int samples[] = new int[1];
for(int i = 0; i < configs.limit(); ++i) {
long config = configs.get(i);
GLX13.glXGetFBConfigAttrib(display, config, GLX14.GLX_SAMPLE_BUFFERS, sampleBuffers);
GLX13.glXGetFBConfigAttrib(display, config, GLX14.GLX_SAMPLES, samples);
if(sampleBuffers[0] > 0 && samples[0] == 4) {
// Found config with 4 samples supported
selectedConfig = config;
break;
}
}
}
X11.XFree(configs);
return config;
return selectedConfig;
}
}

Expand Down

0 comments on commit 3705bf6

Please sign in to comment.