[client] major restructure of platform specific code

This commit is contained in:
Geoffrey McRae
2021-01-15 20:30:03 +11:00
parent 062c4e32cb
commit 27a38294ea
23 changed files with 2120 additions and 2078 deletions

View File

@@ -17,8 +17,5 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*/
// returns the maximum number of multisamples supported by the system
int sysinfo_gfx_max_multisample();
// returns the page size
long sysinfo_getPageSize();
long sysinfo_getPageSize();

View File

@@ -18,53 +18,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <unistd.h>
#include <GL/glx.h>
int sysinfo_gfx_max_multisample(void)
{
Display * dpy = XOpenDisplay(NULL);
if (!dpy)
return -1;
XVisualInfo queryTemplate;
queryTemplate.screen = 0;
int visualCount;
int maxSamples = -1;
XVisualInfo * visuals = XGetVisualInfo(dpy, VisualScreenMask, &queryTemplate, &visualCount);
for (int i = 0; i < visualCount; i++)
{
XVisualInfo * visual = &visuals[i];
int res, supportsGL;
// Some GLX visuals do not use GL, and these must be ignored in our search.
if ((res = glXGetConfig(dpy, visual, GLX_USE_GL, &supportsGL)) != 0 || !supportsGL)
continue;
int sampleBuffers, samples;
if ((res = glXGetConfig(dpy, visual, GLX_SAMPLE_BUFFERS, &sampleBuffers)) != 0)
continue;
// Will be 1 if this visual supports multisampling
if (sampleBuffers != 1)
continue;
if ((res = glXGetConfig(dpy, visual, GLX_SAMPLES, &samples)) != 0)
continue;
// Track the largest number of samples supported
if (samples > maxSamples)
maxSamples = samples;
}
XCloseDisplay(dpy);
return maxSamples;
}
long sysinfo_getPageSize(void)
{
return sysconf(_SC_PAGESIZE);
}
}