33 const std::string &name,
39 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
42 DCAST_INTO_V(egl_pipe, _pipe);
43 _egl_display = egl_pipe->get_egl_display();
46 _egl_surface = EGL_NO_SURFACE;
50 _screenshot_buffer_type = _draw_buffer_type;
57 ~eglGraphicsPixmap() {
58 nassertv(_x_pixmap == None && _egl_surface == EGL_NO_SURFACE);
67 bool eglGraphicsPixmap::
68 begin_frame(FrameMode mode,
Thread *current_thread) {
69 PStatTimer timer(_make_current_pcollector, current_thread);
71 begin_frame_spam(mode);
72 if (_gsg ==
nullptr) {
77 DCAST_INTO_R(eglgsg, _gsg,
false);
78 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
79 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
87 eglgsg->reset_if_new();
89 if (mode == FM_render) {
90 CDLockedReader cdata(_cycler);
91 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
92 const RenderTexture &rt = cdata->_textures[i];
93 RenderTextureMode rtm_mode = rt._rtm_mode;
94 if (rtm_mode == RTM_bind_or_copy) {
95 CDWriter cdataw(_cycler, cdata,
false);
96 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
97 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
100 clear_cube_map_selection();
103 _gsg->set_current_properties(&get_fb_properties());
104 return _gsg->begin_frame(current_thread);
112 void eglGraphicsPixmap::
113 end_frame(FrameMode mode,
Thread *current_thread) {
114 end_frame_spam(mode);
115 nassertv(_gsg !=
nullptr);
117 if (mode == FM_render) {
121 _gsg->end_frame(current_thread);
123 if (mode == FM_render) {
125 clear_cube_map_selection();
132 void eglGraphicsPixmap::
134 if (_gsg !=
nullptr) {
135 if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
136 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
142 if (_egl_surface != EGL_NO_SURFACE) {
143 if (!eglDestroySurface(_egl_display, _egl_surface)) {
144 egldisplay_cat.error() <<
"Failed to destroy surface: "
147 _egl_surface = EGL_NO_SURFACE;
150 if (_x_pixmap != None) {
151 XFreePixmap(_display, _x_pixmap);
162 bool eglGraphicsPixmap::
165 DCAST_INTO_R(egl_pipe, _pipe,
false);
177 DCAST_INTO_R(eglgsg, _gsg,
false);
185 if (eglgsg->_fbconfig == None) {
191 XVisualInfo *visual_info = eglgsg->_visual;
192 if (visual_info ==
nullptr) {
194 egldisplay_cat.error()
195 <<
"No X visual: cannot create pixmap.\n";
199 _display = egl_pipe->get_display();
200 _drawable = egl_pipe->get_root();
201 if (_host !=
nullptr) {
202 if (_host->is_of_type(eglGraphicsWindow::get_class_type())) {
203 eglGraphicsWindow *win = DCAST(eglGraphicsWindow, _host);
204 _drawable = win->get_xwindow();
205 }
else if (_host->is_of_type(eglGraphicsPixmap::get_class_type())) {
206 eglGraphicsPixmap *pix = DCAST(eglGraphicsPixmap, _host);
207 _drawable = pix->_drawable;
211 _x_pixmap = XCreatePixmap(_display, _drawable,
212 _size.get_x(), _size.get_y(), visual_info->depth);
213 if (_x_pixmap == None) {
214 egldisplay_cat.error()
215 <<
"Failed to create X pixmap.\n";
220 nassertr(eglgsg->_fbconfig,
false);
221 _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap,
nullptr);
223 if (_egl_surface == EGL_NO_SURFACE) {
224 egldisplay_cat.error()
225 <<
"Failed to create EGL pixmap surface:"
231 eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context);
232 eglgsg->reset_if_new();
233 if (!eglgsg->is_valid()) {
238 (_fb_properties, eglgsg->get_gl_renderer())) {
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
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).
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
An offscreen buffer for rendering into.
This class is the main interface to controlling the render process.
This is a base class for the various different classes that represent the result of a frame of render...
An object to create GraphicsOutputs that share a particular 3-D API.
Encapsulates all the communication with a particular instance of a given rendering backend.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
A thread; that is, a lightweight 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 window before we o...
This graphics pipe represents the interface for creating OpenGL ES graphics windows on an X-based (e....
A tiny specialization on GLESGraphicsStateGuardian to add some egl-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, eglGraphicsPipe *egl_pipe, bool need_window, bool need_pbuffer, bool need_pixmap)
Selects a visual or fbconfig for all the windows and buffers that use this gsg.
const std::string get_egl_error_string(int error)
Returns the given EGL error as string.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.