30 const std::string &name,
36 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
39 DCAST_INTO_V(egl_pipe, _pipe);
41 _egl_display = egl_pipe->_egl_display;
44 _egl_surface = EGL_NO_SURFACE;
48 _screenshot_buffer_type = _draw_buffer_type;
55 ~eglGraphicsPixmap() {
56 nassertv(_x_pixmap == None && _egl_surface == EGL_NO_SURFACE);
67 PStatTimer timer(_make_current_pcollector, current_thread);
69 begin_frame_spam(mode);
70 if (_gsg ==
nullptr) {
75 DCAST_INTO_R(eglgsg, _gsg,
false);
76 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
77 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: " 85 eglgsg->reset_if_new();
87 if (mode == FM_render) {
89 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
90 const RenderTexture &rt = cdata->_textures[i];
91 RenderTextureMode rtm_mode = rt._rtm_mode;
92 if (rtm_mode == RTM_bind_or_copy) {
93 CDWriter cdataw(_cycler, cdata,
false);
94 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
95 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
98 clear_cube_map_selection();
102 return _gsg->begin_frame(current_thread);
112 end_frame_spam(mode);
113 nassertv(_gsg !=
nullptr);
115 if (mode == FM_render) {
119 _gsg->end_frame(current_thread);
121 if (mode == FM_render) {
123 clear_cube_map_selection();
130 void eglGraphicsPixmap::
132 if (_gsg !=
nullptr) {
133 if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
134 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: " 140 if (_egl_surface != EGL_NO_SURFACE) {
141 if (!eglDestroySurface(_egl_display, _egl_surface)) {
142 egldisplay_cat.error() <<
"Failed to destroy surface: " 145 _egl_surface = EGL_NO_SURFACE;
148 if (_x_pixmap != None) {
149 XFreePixmap(_display, _x_pixmap);
160 bool eglGraphicsPixmap::
163 DCAST_INTO_R(egl_pipe, _pipe,
false);
175 DCAST_INTO_R(eglgsg, _gsg,
false);
183 if (eglgsg->_fbconfig == None) {
189 XVisualInfo *visual_info = eglgsg->_visual;
190 if (visual_info ==
nullptr) {
192 egldisplay_cat.error()
193 <<
"No X visual: cannot create pixmap.\n";
198 if (_host !=
nullptr) {
199 if (_host->is_of_type(eglGraphicsWindow::get_class_type())) {
202 }
else if (_host->is_of_type(eglGraphicsPixmap::get_class_type())) {
204 _drawable = pix->_drawable;
208 _x_pixmap = XCreatePixmap(_display, _drawable,
209 _size.get_x(), _size.get_y(), visual_info->depth);
210 if (_x_pixmap == None) {
211 egldisplay_cat.error()
212 <<
"Failed to create X pixmap.\n";
217 nassertr(eglgsg->_fbconfig,
false);
218 _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap,
nullptr);
220 if (_egl_surface == EGL_NO_SURFACE) {
221 egldisplay_cat.error()
222 <<
"Failed to create EGL pixmap surface:" 228 eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context);
229 eglgsg->reset_if_new();
230 if (!eglgsg->is_valid()) {
235 (_fb_properties, eglgsg->get_gl_renderer())) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An interface to the egl system for managing GLES windows under X.
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.
This graphics pipe represents the interface for creating OpenGL ES graphics windows on an X-based (e....
X11_Window get_xwindow() const
Returns the X11 Window handle.
const FrameBufferProperties & get_fb_properties() const
Gets the FrameBufferProperties for all windows and buffers that use this GSG.
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.
const std::string get_egl_error_string(int error)
Returns the given EGL error as string.
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 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...
Another offscreen buffer in the EGL environment.
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).
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 thread; that is, a lightweight process.
Encapsulates all the communication with a particular instance of a given rendering backend.
A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific information.
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
This class is the main interface to controlling the render process.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.