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())) {