15 #include "eglGraphicsBuffer.h"
16 #include "eglGraphicsStateGuardian.h"
17 #include "config_egldisplay.h"
18 #include "eglGraphicsPipe.h"
20 #include "graphicsPipe.h"
21 #include "pStatTimer.h"
38 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
41 DCAST_INTO_V(egl_pipe, _pipe);
42 _pbuffer = EGL_NO_SURFACE;
46 _screenshot_buffer_type = _draw_buffer_type;
55 ~eglGraphicsBuffer() {
56 nassertv(_pbuffer == EGL_NO_SURFACE);
70 PStatTimer timer(_make_current_pcollector, current_thread);
72 begin_frame_spam(mode);
78 DCAST_INTO_R(eglgsg, _gsg,
false);
79 if (!eglMakeCurrent(eglgsg->_egl_display, _pbuffer, _pbuffer, eglgsg->_context)) {
80 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
81 << get_egl_error_string(eglGetError()) <<
"\n";
88 eglgsg->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 eglGraphicsBuffer::
142 DCAST_INTO_V(eglgsg, _gsg);
143 if (!eglMakeCurrent(eglgsg->_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
144 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
145 << get_egl_error_string(eglGetError()) <<
"\n";
149 if (_pbuffer != EGL_NO_SURFACE) {
150 if (!eglDestroySurface(_egl_display, _pbuffer)) {
151 egldisplay_cat.error() <<
"Failed to destroy surface: "
152 << get_egl_error_string(eglGetError()) <<
"\n";
154 _pbuffer = EGL_NO_SURFACE;
168 bool eglGraphicsBuffer::
171 DCAST_INTO_R(egl_pipe, _pipe,
false);
183 DCAST_INTO_R(eglgsg, _gsg,
false);
191 if (eglgsg->_fbconfig == None) {
197 int attrib_list[] = {
198 EGL_WIDTH, _size.get_x(),
199 EGL_HEIGHT, _size.get_y(),
203 _pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list);
205 if (_pbuffer == EGL_NO_SURFACE) {
206 egldisplay_cat.error()
207 <<
"Failed to create EGL pbuffer surface: "
208 << get_egl_error_string(eglGetError()) <<
"\n";
212 if (!eglMakeCurrent(eglgsg->_egl_display, _pbuffer, _pbuffer, eglgsg->_context)) {
213 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
214 << get_egl_error_string(eglGetError()) <<
"\n";
216 eglgsg->reset_if_new();
217 if (!eglgsg->is_valid()) {
222 (_fb_properties, eglgsg->get_gl_renderer())) {
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
This graphics pipe represents the interface for creating OpenGL ES graphics windows on an X-based (e...
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 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...
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...
This is a base class for the various different classes that represent the result of a frame of render...
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.
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...
A thread; that is, a lightweight process.
int get_screen() const
Returns the X screen number associated with the pipe.
Encapsulates all the communication with a particular instance of a given rendering backend...
X11_Display * get_display() const
Returns a pointer to the X display associated with the pipe: the display on which to create the windo...
A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific information.
This class is the main interface to controlling the render process.
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...
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.