15 #include "glxGraphicsBuffer.h"
16 #include "glxGraphicsStateGuardian.h"
17 #include "config_glxdisplay.h"
18 #include "glxGraphicsPipe.h"
20 #include "graphicsPipe.h"
22 #include "pStatTimer.h"
39 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
42 DCAST_INTO_V(glx_pipe, _pipe);
48 _screenshot_buffer_type = _draw_buffer_type;
57 ~glxGraphicsBuffer() {
58 nassertv(_pbuffer == None);
72 PStatTimer timer(_make_current_pcollector, current_thread);
74 begin_frame_spam(mode);
81 DCAST_INTO_R(glxgsg, _gsg,
false);
82 glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
88 glxgsg->reset_if_new();
90 if (mode == FM_render) {
92 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
93 const RenderTexture &rt = cdata->_textures[i];
94 RenderTextureMode rtm_mode = rt._rtm_mode;
95 if (rtm_mode == RTM_bind_or_copy) {
96 CDWriter cdataw(_cycler, cdata,
false);
97 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
98 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
101 clear_cube_map_selection();
105 return _gsg->begin_frame(current_thread);
117 end_frame_spam(mode);
120 if (mode == FM_render) {
124 _gsg->end_frame(current_thread);
126 if (mode == FM_render) {
128 clear_cube_map_selection();
138 void glxGraphicsBuffer::
141 glXMakeCurrent(_display, None, NULL);
143 if (_pbuffer != None) {
145 DCAST_INTO_V(glxgsg, _gsg);
146 glxgsg->_glXDestroyPbuffer(_display, _pbuffer);
164 bool glxGraphicsBuffer::
167 DCAST_INTO_R(glx_pipe, _pipe,
false);
179 DCAST_INTO_R(glxgsg, _gsg,
false);
181 if (!glxgsg->_context_has_pbuffer ||
190 if (glxgsg->_fbconfig == None || !glxgsg->_context_has_pbuffer) {
196 nassertr(glxgsg->_supports_pbuffer,
false);
198 static const int max_attrib_list = 32;
199 int attrib_list[max_attrib_list];
202 if (glxgsg->_uses_sgix_pbuffer) {
204 nassertr(n < max_attrib_list,
false);
205 attrib_list[n] = (int)None;
206 _pbuffer = glxgsg->_glXCreateGLXPbufferSGIX(glxgsg->_display, glxgsg->_fbconfig,
211 attrib_list[n++] = GLX_PBUFFER_WIDTH;
213 attrib_list[n++] = GLX_PBUFFER_HEIGHT;
216 nassertr(n < max_attrib_list,
false);
217 attrib_list[n] = (int)None;
218 _pbuffer = glxgsg->_glXCreatePbuffer(glxgsg->_display, glxgsg->_fbconfig,
222 if (_pbuffer == None) {
223 glxdisplay_cat.error()
224 <<
"failed to create GLX pbuffer.\n";
228 glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
229 glxgsg->reset_if_new();
230 if (!glxgsg->is_valid()) {
235 (_fb_properties, glxgsg->get_gl_renderer())) {
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.
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
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.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
int get_y_size() const
Returns the visible height of the window or buffer, if it is known.
int get_screen() const
Returns the X screen number associated with the pipe.
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const
Validates that the properties represent the desired kind of renderer (hardware or software)...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
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...
An offscreen buffer for rendering into.
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(...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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 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...
This class is the main interface to controlling the render process.
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...
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
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...