39 const std::string &name,
57 PStatTimer timer(_make_current_pcollector, current_thread);
59 begin_frame_spam(mode);
60 if (_gsg ==
nullptr) {
63 if (_awaiting_configure) {
70 DCAST_INTO_R(glxgsg, _gsg,
false);
74 if (glXGetCurrentDisplay() == _display &&
75 glXGetCurrentDrawable() == _xwindow &&
76 glXGetCurrentContext() == glxgsg->_context) {
81 glXMakeCurrent(_display, _xwindow, glxgsg->_context);
89 glxgsg->reset_if_new();
91 if (mode == FM_render) {
92 glxgsg->push_group_marker(std::string(
"glxGraphicsWindow ") +
get_name());
94 clear_cube_map_selection();
98 return _gsg->begin_frame(current_thread);
109 end_frame_spam(mode);
110 nassertv(_gsg !=
nullptr);
112 if (mode == FM_render) {
117 _gsg->end_frame(current_thread);
119 if (mode == FM_render) {
121 clear_cube_map_selection();
124 DCAST_INTO_V(glxgsg, _gsg);
125 glxgsg->pop_group_marker();
138 if (_gsg !=
nullptr && _flip_ready) {
147 glXSwapBuffers(_display, _xwindow);
155 void glxGraphicsWindow::
159 if (_gsg !=
nullptr) {
160 glXMakeCurrent(_display, None,
nullptr);
164 x11GraphicsWindow::close_window();
171 bool glxGraphicsWindow::
174 DCAST_INTO_R(glx_pipe, _pipe,
false);
178 if (_gsg ==
nullptr) {
186 DCAST_INTO_R(glxgsg, _gsg,
false);
194 if (glxgsg->_context ==
nullptr) {
196 glxdisplay_cat.error()
197 <<
"No GLX context: cannot open window.\n";
201 _visual_info = glxgsg->_visual;
202 if (_visual_info ==
nullptr) {
204 glxdisplay_cat.error()
205 <<
"No X visual: cannot open window.\n";
211 if (glxgsg->_fbconfig != None) {
212 setup_colormap(glxgsg->_fbconfig);
214 setup_colormap(_visual_info);
217 if (!x11GraphicsWindow::open_window()) {
221 glXMakeCurrent(_display, _xwindow, glxgsg->_context);
222 glxgsg->reset_if_new();
223 if (!glxgsg->is_valid()) {
228 (_fb_properties, glxgsg->get_gl_renderer())) {
241 void glxGraphicsWindow::
242 setup_colormap(GLXFBConfig fbconfig) {
244 DCAST_INTO_V(glxgsg, _gsg);
245 nassertv(glxgsg->_supports_fbconfig);
247 XVisualInfo *visual_info = glxgsg->_glXGetVisualFromFBConfig(_display, fbconfig);
248 if (visual_info ==
nullptr) {
252 int visual_class = visual_info->c_class;
253 Visual *visual = visual_info->visual;
257 DCAST_INTO_V(glx_pipe, _pipe);
258 X11_Window root_window = glx_pipe->
get_root();
262 switch (visual_class) {
264 rc = glxgsg->_glXGetFBConfigAttrib(_display, fbconfig, GLX_RGBA, &is_rgb);
265 if (rc == 0 && is_rgb) {
266 glxdisplay_cat.warning()
267 <<
"mesa pseudocolor not supported.\n";
269 _colormap = (Colormap)0;
272 _colormap = XCreateColormap(_display, root_window,
278 _colormap = XCreateColormap(_display, root_window,
284 _colormap = XCreateColormap(_display, root_window,
288 glxdisplay_cat.error()
289 <<
"Could not allocate a colormap for visual class " 290 << visual_class <<
".\n";
299 void glxGraphicsWindow::
300 setup_colormap(XVisualInfo *visual) {
302 DCAST_INTO_V(glx_pipe, _pipe);
303 X11_Window root_window = glx_pipe->
get_root();
305 int visual_class = visual->c_class;
308 switch (visual_class) {
310 rc = glXGetConfig(_display, visual, GLX_RGBA, &is_rgb);
311 if (rc == 0 && is_rgb) {
312 glxdisplay_cat.warning()
313 <<
"mesa pseudocolor not supported.\n";
315 _colormap = (Colormap)0;
318 _colormap = XCreateColormap(_display, root_window,
319 visual->visual, AllocAll);
324 _colormap = XCreateColormap(_display, root_window,
325 visual->visual, AllocNone);
330 _colormap = XCreateColormap(_display, root_window,
331 visual->visual, AllocNone);
334 glxdisplay_cat.error()
335 <<
"Could not allocate a colormap for visual class " 336 << visual_class <<
".\n";
This graphics pipe represents the interface for creating OpenGL graphics windows on an X-based (e....
A tiny specialization on GLGraphicsStateGuardian to add some glx-specific information.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
void choose_pixel_format(const FrameBufferProperties &properties, X11_Display *_display, int _screen, bool need_pbuffer, bool need_pixmap)
Selects a visual or fbconfig for all the windows and buffers that use this gsg.
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
X11_Window get_root() const
Returns the handle to the root window on the pipe's display.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame.
int get_screen() const
Returns the X screen number associated with the pipe.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An object to create GraphicsOutputs that share a particular 3-D API.
X11_Display * get_display() const
Returns a pointer to the X display associated with the pipe: the display on which to create the windo...
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
This is a base class for the various different classes that represent the result of a frame of render...
bool verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const
Validates that the properties represent the desired kind of renderer (hardware or software).
Similar to MutexHolder, but for a light reentrant mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_name
Returns the name that was passed to the GraphicsOutput constructor.
A thread; that is, a lightweight process.
Encapsulates all the communication with a particular instance of a given rendering backend.
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Interfaces to the X11 window system.
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.