29 const std::string &name,
35 GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
38 DCAST_INTO_V(egl_pipe, _pipe);
39 _pbuffer = EGL_NO_SURFACE;
43 _draw_buffer_type = RenderBuffer::T_back;
44 _screenshot_buffer_type = RenderBuffer::T_back;
52 nassertv(_pbuffer == EGL_NO_SURFACE);
63 PStatTimer timer(_make_current_pcollector, current_thread);
65 begin_frame_spam(mode);
66 if (_gsg ==
nullptr) {
71 DCAST_INTO_R(eglgsg, _gsg,
false);
72 if (!eglMakeCurrent(eglgsg->_egl_display, _pbuffer, _pbuffer, eglgsg->_context)) {
73 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
81 eglgsg->reset_if_new();
83 if (mode == FM_render) {
85 for (
size_t i = 0; i != cdata->_textures.size(); ++i) {
86 const RenderTexture &rt = cdata->_textures[i];
87 RenderTextureMode rtm_mode = rt._rtm_mode;
88 if (rtm_mode == RTM_bind_or_copy) {
89 CDWriter cdataw(_cycler, cdata,
false);
90 nassertr(cdata->_textures.size() == cdataw->_textures.size(),
false);
91 cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
94 clear_cube_map_selection();
98 return _gsg->begin_frame(current_thread);
108 end_frame_spam(mode);
109 nassertv(_gsg !=
nullptr);
111 if (mode == FM_render) {
115 _gsg->end_frame(current_thread);
117 if (mode == FM_render) {
119 clear_cube_map_selection();
128 nassertv_always(_gsg !=
nullptr);
130 if (_size.get_x() != x || _size.get_y() != y) {
131 eglDestroySurface(_egl_display, _pbuffer);
133 int attrib_list[] = {
140 DCAST_INTO_V(eglgsg, _gsg);
141 _pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list);
150void eglGraphicsBuffer::
152 if (_gsg !=
nullptr) {
154 DCAST_INTO_V(eglgsg, _gsg);
155 if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
156 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
161 if (_pbuffer != EGL_NO_SURFACE) {
162 if (!eglDestroySurface(_egl_display, _pbuffer)) {
163 egldisplay_cat.error() <<
"Failed to destroy surface: "
166 _pbuffer = EGL_NO_SURFACE;
177bool eglGraphicsBuffer::
180 DCAST_INTO_R(egl_pipe, _pipe,
false);
192 DCAST_INTO_R(eglgsg, _gsg,
false);
200 if (eglgsg->_fbconfig ==
nullptr) {
206 _egl_display = eglgsg->_egl_display;
208 int attrib_list[] = {
209 EGL_WIDTH, _size.get_x(),
210 EGL_HEIGHT, _size.get_y(),
214 _pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list);
216 if (_pbuffer == EGL_NO_SURFACE) {
217 egldisplay_cat.error()
218 <<
"Failed to create EGL pbuffer surface: "
223 if (!eglMakeCurrent(eglgsg->_egl_display, _pbuffer, _pbuffer, eglgsg->_context)) {
224 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
227 eglgsg->reset_if_new();
228 if (!eglgsg->is_valid()) {
233 (_fb_properties, eglgsg->get_gl_renderer())) {
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...
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...
const FrameBufferProperties & get_fb_properties() const
Returns the framebuffer properties of the window.
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
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...
virtual void set_size(int x, int y)
This is called by the GraphicsEngine to request that the buffer resize itself.
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.
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.
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.