33#ifndef EGL_GL_COLORSPACE_KHR
34#define EGL_GL_COLORSPACE_KHR 0x309D
37#ifndef EGL_GL_COLORSPACE_SRGB_KHR
38#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
48 const std::string &name,
57 DCAST_INTO_V(egl_pipe, _pipe);
58 _egl_display = egl_pipe->get_egl_display();
75bool eglGraphicsWindow::
76begin_frame(FrameMode mode,
Thread *current_thread) {
77 PStatTimer timer(_make_current_pcollector, current_thread);
79 begin_frame_spam(mode);
80 if (_gsg ==
nullptr) {
83 if (_awaiting_configure_since != -1) {
90 DCAST_INTO_R(eglgsg, _gsg,
false);
94 if (eglGetCurrentDisplay() == _egl_display &&
95 eglGetCurrentSurface(EGL_READ) == _egl_surface &&
96 eglGetCurrentSurface(EGL_DRAW) == _egl_surface &&
97 eglGetCurrentContext() == eglgsg->_context) {
102 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
103 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
113 eglgsg->reset_if_new();
115 if (mode == FM_render) {
117 clear_cube_map_selection();
120 _gsg->set_current_properties(&get_fb_properties());
121 return _gsg->begin_frame(current_thread);
129void eglGraphicsWindow::
130end_frame(FrameMode mode,
Thread *current_thread) {
131 end_frame_spam(mode);
132 nassertv(_gsg !=
nullptr);
134 if (mode == FM_render) {
139 _gsg->end_frame(current_thread);
141 if (mode == FM_render) {
143 clear_cube_map_selection();
154void eglGraphicsWindow::
156 if (_gsg !=
nullptr && _flip_ready) {
165 eglSwapBuffers(_egl_display, _egl_surface);
173void eglGraphicsWindow::
175 if (_gsg !=
nullptr) {
176 if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
177 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
183 if (_ic != (XIC)
nullptr) {
188 if (_egl_surface != 0) {
189 if (!eglDestroySurface(_egl_display, _egl_surface)) {
190 egldisplay_cat.error() <<
"Failed to destroy surface: "
195 if (_xwindow != (X11_Window)
nullptr) {
196 XDestroyWindow(_display, _xwindow);
197 _xwindow = (X11_Window)
nullptr;
203 GraphicsWindow::close_window();
210bool eglGraphicsWindow::
213 DCAST_INTO_R(egl_pipe, _pipe,
false);
225 DCAST_INTO_R(eglgsg, _gsg,
false);
233 _visual_info = eglgsg->_visual;
234 if (_visual_info ==
nullptr) {
236 egldisplay_cat.error()
237 <<
"No X visual: cannot open window.\n";
241 setup_colormap(_visual_info);
243 if (!x11GraphicsWindow::open_window()) {
248 EGLint *attribs_p =
nullptr;
250 attribs[0] = EGL_GL_COLORSPACE_KHR;
251 attribs[1] = EGL_GL_COLORSPACE_SRGB_KHR;
252 attribs[2] = EGL_NONE;
253 attribs[3] = EGL_NONE;
256 _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, attribs_p);
257 if (eglGetError() != EGL_SUCCESS) {
258 egldisplay_cat.error()
259 <<
"Failed to create window surface.\n";
263 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
264 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
267 eglgsg->reset_if_new();
268 if (!eglgsg->is_valid()) {
273 (_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...
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...
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
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.
Similar to MutexHolder, but for a light reentrant mutex.
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.
Interfaces to the X11 window system.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
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.