15 #include "glxGraphicsPixmap.h" 16 #include "glxGraphicsWindow.h" 17 #include "glxGraphicsStateGuardian.h" 18 #include "config_glxdisplay.h" 19 #include "glxGraphicsPipe.h" 21 #include "graphicsPipe.h" 23 #include "pStatTimer.h" 40 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
43 DCAST_INTO_V(glx_pipe, _pipe);
51 _screenshot_buffer_type = _draw_buffer_type;
60 ~glxGraphicsPixmap() {
61 nassertv(_x_pixmap == None && _glx_pixmap == None);
75 PStatTimer timer(_make_current_pcollector, current_thread);
77 begin_frame_spam(mode);
79 _glx_pixmap == None) {
84 DCAST_INTO_R(glxgsg, _gsg,
false);
85 glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
91 glxgsg->reset_if_new();
93 if (mode == FM_render) {
95 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
96 const RenderTexture &rt = cdata->_textures[i];
97 RenderTextureMode rtm_mode = rt._rtm_mode;
98 if (rtm_mode == RTM_bind_or_copy) {
99 CDWriter cdataw(_cycler, cdata,
false);
100 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
101 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
104 clear_cube_map_selection();
108 return _gsg->begin_frame(current_thread);
120 end_frame_spam(mode);
123 if (mode == FM_render) {
127 _gsg->end_frame(current_thread);
129 if (mode == FM_render) {
131 clear_cube_map_selection();
141 void glxGraphicsPixmap::
144 glXMakeCurrent(_display, None, NULL);
148 if (_glx_pixmap != None) {
149 glXDestroyGLXPixmap(_display, _glx_pixmap);
153 if (_x_pixmap != None) {
154 XFreePixmap(_display, _x_pixmap);
168 bool glxGraphicsPixmap::
171 DCAST_INTO_R(glx_pipe, _pipe,
false);
183 DCAST_INTO_R(glxgsg, _gsg,
false);
184 if (!glxgsg->_context_has_pixmap ||
192 if (!glxgsg->_context_has_pixmap) {
197 XVisualInfo *visual_info = glxgsg->_visual;
198 if (visual_info == NULL) {
200 glxdisplay_cat.error()
201 <<
"No X visual: cannot create pixmap.\n";
207 if (_host->is_of_type(glxGraphicsWindow::get_class_type())) {
210 }
else if (_host->is_of_type(glxGraphicsPixmap::get_class_type())) {
212 _drawable = pix->_drawable;
216 _x_pixmap = XCreatePixmap(_display, _drawable,
218 if (_x_pixmap == None) {
219 glxdisplay_cat.error()
220 <<
"Failed to create X pixmap.\n";
225 if (glxgsg->_fbconfig) {
227 _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap, NULL);
230 _glx_pixmap = glXCreateGLXPixmap(_display, visual_info, _x_pixmap);
233 if (_glx_pixmap == None) {
234 glxdisplay_cat.error()
235 <<
"Failed to create GLX pixmap.\n";
241 glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context);
249 glxgsg->reset_if_new();
250 if (!glxgsg->is_valid()) {
255 (_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, for instance in order to test whether a particular X11 operation will succeed.
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
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.
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.
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(...
bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const
Validates that the properties represent the desired kind of renderer (hardware or software)...
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...
int get_x_size() const
Returns the visible width of the window or buffer, if it is known.
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...
Another offscreen buffer in the GLX environment.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.