-
Notifications
You must be signed in to change notification settings - Fork 1
/
panda_parser.cpp
63 lines (51 loc) · 1.54 KB
/
panda_parser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <panda_parser.h>
#include <kdebug.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
// OpenGL includes
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glx.h>
void PandaParser::getGlStrings()
{
GLXContext ctx;
char *displayName = NULL;
int scrnum = 0;
const int attribSingle[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
const int attribDouble[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
Display *dpy = XOpenDisplay(displayName);
unsigned long mask;
XVisualInfo *visinfo;
Window root, win;
XSetWindowAttributes attr;
root = DefaultRootWindow(dpy);
visinfo = glXChooseVisual(dpy, scrnum, const_cast<int*>(attribSingle));
if (!visinfo) {
visinfo = glXChooseVisual(dpy, scrnum, const_cast<int*>(attribDouble));
if (!visinfo) {
kDebug() << "Error: couldn't find RGB GLX visual\n";
return ;
}
}
attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow(dpy, root, 0, 0, 600, 600, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
ctx = glXCreateContext( dpy, visinfo, NULL, GL_TRUE);
if (glXMakeCurrent(dpy, win, ctx)) {
glVendor = (const char *) glGetString(GL_VENDOR);
glRenderer = (const char *) glGetString(GL_RENDERER);
glVersion = (const char *) glGetString(GL_VERSION);
}
}