Last active
March 25, 2018 13:42
-
-
Save whitequark/27831e23414a1f44b47c9341ffff7cde to your computer and use it in GitHub Desktop.
gcc -lGL -lX11 glinfo.c -o glinfo && ./glinfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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