31 const std::string &name,
37 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
40 DCAST_INTO_V(glx_pipe, _pipe);
48 _screenshot_buffer_type = _draw_buffer_type;
55 ~glxGraphicsPixmap() {
56 nassertv(_x_pixmap == None && _glx_pixmap == None);
67 PStatTimer timer(_make_current_pcollector, current_thread);
69 begin_frame_spam(mode);
70 if (_gsg ==
nullptr ||
71 _glx_pixmap == None) {
76 DCAST_INTO_R(glxgsg, _gsg,
false);
79 glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
86 glxgsg->reset_if_new();
88 if (mode == FM_render) {
90 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
91 const RenderTexture &rt = cdata->_textures[i];
92 RenderTextureMode rtm_mode = rt._rtm_mode;
93 if (rtm_mode == RTM_bind_or_copy) {
94 CDWriter cdataw(_cycler, cdata,
false);
95 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
96 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
99 clear_cube_map_selection();
103 return _gsg->begin_frame(current_thread);
113 end_frame_spam(mode);
114 nassertv(_gsg !=
nullptr);
116 if (mode == FM_render) {
120 _gsg->end_frame(current_thread);
122 if (mode == FM_render) {
124 clear_cube_map_selection();
131 void glxGraphicsPixmap::
134 if (_gsg !=
nullptr) {
135 glXMakeCurrent(_display, None,
nullptr);
139 if (_glx_pixmap != None) {
140 glXDestroyGLXPixmap(_display, _glx_pixmap);
144 if (_x_pixmap != None) {
145 XFreePixmap(_display, _x_pixmap);
156 bool glxGraphicsPixmap::
159 DCAST_INTO_R(glx_pipe, _pipe,
false);
163 if (_gsg ==
nullptr) {
171 DCAST_INTO_R(glxgsg, _gsg,
false);
172 if (!glxgsg->_context_has_pixmap ||
180 if (!glxgsg->_context_has_pixmap) {
185 XVisualInfo *visual_info = glxgsg->_visual;
186 if (visual_info ==
nullptr) {
188 glxdisplay_cat.error()
189 <<
"No X visual: cannot create pixmap.\n";
194 if (_host !=
nullptr) {
195 if (_host->is_of_type(glxGraphicsWindow::get_class_type())) {
198 }
else if (_host->is_of_type(glxGraphicsPixmap::get_class_type())) {
200 _drawable = pix->_drawable;
205 _x_pixmap = XCreatePixmap(_display, _drawable,
207 if (_x_pixmap == None) {
208 glxdisplay_cat.error()
209 <<
"Failed to create X pixmap.\n";
214 if (glxgsg->_fbconfig) {
216 _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap,
nullptr);
219 _glx_pixmap = glXCreateGLXPixmap(_display, visual_info, _x_pixmap);
222 if (_glx_pixmap == None) {
223 glxdisplay_cat.error()
224 <<
"Failed to create GLX pixmap.\n";
230 glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
238 glxgsg->reset_if_new();
239 if (!glxgsg->is_valid()) {
244 (_fb_properties, glxgsg->get_gl_renderer())) {
This graphics pipe represents the interface for creating OpenGL graphics windows on an X-based (e....
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.
A tiny specialization on GLGraphicsStateGuardian to add some glx-specific information.
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.
static int disable_x_error_messages()
Globally disables the printing of error messages that are raised by the X11 system,...
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
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.
static int enable_x_error_messages()
Reenables the printing of error messages after a previous call to disable_x_error_messages().
X11_Window get_xwindow() const
Returns the X11 Window handle.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
An offscreen buffer for rendering into.
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.
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
X11_Display * get_display() const
Returns a pointer to the X display associated with the pipe: the display on which to create the windo...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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.
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
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.
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
An interface to the glx system for managing GL windows under X.
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.
Another offscreen buffer in the GLX environment.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.