Skip to content

Instantly share code, notes, and snippets.

@whitequark whitequark/glinfo.c
Last active Mar 25, 2018

Embed
What would you like to do?
gcc -lGL -lX11 glinfo.c -o glinfo && ./glinfo
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
Display *dpy = XOpenDisplay(NULL);
if(!dpy) {
puts("cannot XOpenDisplay");
return 1;
}
int scrnum = DefaultScreen(dpy);
Window root = RootWindow(dpy, scrnum);
int attrib[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None
};
XVisualInfo *visinfo = glXChooseVisual(dpy, scrnum, attrib);
if(!visinfo) {
puts("cannot get an RGB, double-buffered visual");
return 1;
}
XSetWindowAttributes attr;
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
Window win = XCreateWindow(dpy, root, 0, 0, 100, 100,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
GLXContext ctx = glXCreateContext(dpy, visinfo, NULL, True);
if(!ctx) {
puts("cannot glXCreateContext");
return 1;
}
glXMakeCurrent(dpy, win, ctx);
int max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
printf("glGetIntegerv(GL_MAX_TEXTURE_SIZE) = %d\n", max_texture_size);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.