77#include < string>
88#include < utility>
99
10- // Note: This is intentionally included here since it's only needed at the
10+ // Note: These are intentionally included here since they are only needed at the
1111// implementation level, and not in a grouping of more generic headers like
1212// opengl_includes.h. See opengl_context.h for where pimpl is applied.
13+ #include < vtkX11Functions.h>
1314#include < vtkglad/include/glad/glx.h>
1415
1516#include " drake/common/drake_assert.h"
@@ -119,7 +120,7 @@ class OpenGlContext::Impl {
119120 GLXFBConfig* fb_configs =
120121 glXChooseFBConfig (display (), screen_id, kVisualAttribs , &fb_count);
121122 ScopeExit guard ([fb_configs]() {
122- XFree (fb_configs);
123+ vtkXFree (fb_configs);
123124 });
124125 if (fb_configs == nullptr ) {
125126 throw std::runtime_error (
@@ -139,7 +140,7 @@ class OpenGlContext::Impl {
139140 " unavailable." );
140141 }
141142 ScopeExit visual_guard ([visual]() {
142- XFree (visual);
143+ vtkXFree (visual);
143144 });
144145 XSetWindowAttributes window_attribs;
145146
@@ -149,23 +150,23 @@ class OpenGlContext::Impl {
149150 bool is_complete = false ;
150151
151152 // This requires a call to XFreeColormap in the destructor.
152- window_attribs.colormap = XCreateColormap (
153+ window_attribs.colormap = vtkXCreateColormap (
153154 display (), RootWindow (display (), screen_id), visual->visual , AllocNone);
154155 ScopeExit colormap_guard (
155156 [colormap = window_attribs.colormap , &is_complete]() {
156- if (!is_complete) XFreeColormap (display (), colormap);
157+ if (!is_complete) vtkXFreeColormap (display (), colormap);
157158 });
158159
159160 // Enable just the Expose event so we know when the window is ready to be
160161 // redrawn.
161162 window_attribs.event_mask = ExposureMask;
162163 // This requires a call to XDestroyWindow in the destructor.
163- window_ = XCreateWindow (display (), RootWindow (display (), screen_id), 0 , 0 ,
164- window_width_, window_height_, 0 , visual-> depth ,
165- InputOutput, visual->visual ,
166- CWColormap | CWEventMask, &window_attribs);
164+ window_ = vtkXCreateWindow (display (), RootWindow (display (), screen_id), 0 ,
165+ 0 , window_width_, window_height_, 0 ,
166+ visual-> depth , InputOutput, visual->visual ,
167+ CWColormap | CWEventMask, &window_attribs);
167168 ScopeExit window_guard ([window = window_, &is_complete]() {
168- if (!is_complete) XDestroyWindow (display (), window);
169+ if (!is_complete) vtkXDestroyWindow (display (), window);
169170 });
170171
171172 // Create an OpenGL context.
@@ -185,7 +186,7 @@ class OpenGlContext::Impl {
185186 if (!is_complete) glXDestroyContext (display (), context);
186187 });
187188
188- XSync (display (), False);
189+ vtkXSync (display (), False);
189190
190191 // Enable debug.
191192 if (debug) {
@@ -205,9 +206,9 @@ class OpenGlContext::Impl {
205206 ~Impl () {
206207 glXDestroyContext (display (), context_);
207208 XWindowAttributes window_attribs;
208- XGetWindowAttributes (display (), window_, &window_attribs);
209- XFreeColormap (display (), window_attribs.colormap );
210- XDestroyWindow (display (), window_);
209+ vtkXGetWindowAttributes (display (), window_, &window_attribs);
210+ vtkXFreeColormap (display (), window_attribs.colormap );
211+ vtkXDestroyWindow (display (), window_);
211212 }
212213
213214 void MakeCurrent () const {
@@ -230,14 +231,14 @@ class OpenGlContext::Impl {
230231
231232 void DisplayWindow (const int width, const int height) {
232233 if (width != window_width_ || height != window_height_) {
233- XResizeWindow (display (), window_, width, height);
234+ vtkXResizeWindow (display (), window_, width, height);
234235 // If the window isn't viewable, it won't send an expose event.
235236 if (IsWindowViewable ()) WaitForExposeEvent ();
236237 window_width_ = width;
237238 window_height_ = height;
238239 }
239240 if (!IsWindowViewable ()) {
240- XMapRaised (display (), window_);
241+ vtkXMapRaised (display (), window_);
241242 WaitForExposeEvent ();
242243 }
243244 // We wait for confirmation events to make sure we don't attempt to draw
@@ -249,14 +250,14 @@ class OpenGlContext::Impl {
249250
250251 void HideWindow () {
251252 if (IsWindowViewable ()) {
252- XUnmapWindow (display (), window_);
253+ vtkXUnmapWindow (display (), window_);
253254 // Unmapping a window provides no events on that window.
254255 }
255256 }
256257
257258 bool IsWindowViewable () const {
258259 XWindowAttributes attr;
259- const Status status = XGetWindowAttributes (display (), window_, &attr);
260+ const Status status = vtkXGetWindowAttributes (display (), window_, &attr);
260261
261262 // In xlib, a zero status implies function failure.
262263 // https://tronche.com/gui/x/xlib/introduction/errors.html#Status
@@ -269,15 +270,15 @@ class OpenGlContext::Impl {
269270 }
270271
271272 void UpdateWindow () {
272- XClearWindow (display (), window_);
273+ vtkXClearWindow (display (), window_);
273274 glXSwapBuffers (display (), window_);
274275 }
275276
276277 // Waits for the display() to transmit an Expose event.
277278 void WaitForExposeEvent () const {
278279 XEvent event;
279280 // This blocks until the window gets an "Expose" event.
280- XWindowEvent (display (), window_, ExposureMask, &event);
281+ vtkXWindowEvent (display (), window_, ExposureMask, &event);
281282 DRAKE_DEMAND (event.type == Expose);
282283 }
283284
0 commit comments