MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / init

Method init

client/GLFrame.cpp:56–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55
56void GLFrame::init(void)
57{
58 XVisualInfo *v = NULL;
59
60 try
61 {
62 pf = pf_get(PF_RGB);
63 XWindowAttributes xwa;
64 memset(&xwa, 0, sizeof(xwa));
65 XGetWindowAttributes(dpy, win, &xwa);
66 XVisualInfo vtemp; int n = 0;
67 if(!xwa.visual) THROW("Could not get window attributes");
68 vtemp.visualid = xwa.visual->visualid;
69 int maj_opcode = -1, first_event = -1, first_error = -1;
70 if(!XQueryExtension(dpy, "GLX", &maj_opcode, &first_event, &first_error)
71 || maj_opcode < 0 || first_event < 0 || first_error < 0)
72 THROW("GLX extension not available");
73 if(!(v = XGetVisualInfo(dpy, VisualIDMask, &vtemp, &n)) || n == 0)
74 THROW("Could not obtain visual");
75 if(!(ctx = glXCreateContext(dpy, v, NULL, True)))
76 THROW("Could not create GLX context");
77 XFree(v); v = NULL;
78 }
79 catch(...)
80 {
81 if(dpy && ctx)
82 {
83 glXMakeCurrent(dpy, 0, 0); glXDestroyContext(dpy, ctx); ctx = 0;
84 }
85 if(v) XFree(v);
86 if(dpy)
87 {
88 XCloseDisplay(dpy); dpy = NULL;
89 }
90 throw;
91 }
92}
93
94
95GLFrame::~GLFrame(void)

Callers 2

runMethod · 0.45
runMethod · 0.45

Calls 9

pf_getFunction · 0.85
XQueryExtensionFunction · 0.85
glXCreateContextFunction · 0.85
XFreeFunction · 0.85
glXMakeCurrentFunction · 0.85
glXDestroyContextFunction · 0.85
XCloseDisplayFunction · 0.85
LittleEndianFunction · 0.85
initFunction · 0.50

Tested by

no test coverage detected