37 const std::string &name,
46 DCAST_INTO_V(egl_pipe, _pipe);
47 _egl_display = egl_pipe->_egl_display;
55 ~eglGraphicsWindow() {
66 PStatTimer timer(_make_current_pcollector, current_thread);
68 begin_frame_spam(mode);
69 if (_gsg ==
nullptr) {
72 if (_awaiting_configure) {
79 DCAST_INTO_R(eglgsg, _gsg,
false);
83 if (eglGetCurrentDisplay() == _egl_display &&
84 eglGetCurrentSurface(EGL_READ) == _egl_surface &&
85 eglGetCurrentSurface(EGL_DRAW) == _egl_surface &&
86 eglGetCurrentContext() == eglgsg->_context) {
91 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
92 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
102 eglgsg->reset_if_new();
104 if (mode == FM_render) {
106 clear_cube_map_selection();
110 return _gsg->begin_frame(current_thread);
120 end_frame_spam(mode);
121 nassertv(_gsg !=
nullptr);
123 if (mode == FM_render) {
128 _gsg->end_frame(current_thread);
130 if (mode == FM_render) {
132 clear_cube_map_selection();
145 if (_gsg !=
nullptr && _flip_ready) {
154 eglSwapBuffers(_egl_display, _egl_surface);
162 void eglGraphicsWindow::
164 if (_gsg !=
nullptr) {
165 if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
166 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
172 if (_ic != (XIC)
nullptr) {
177 if (_egl_surface != 0) {
178 if (!eglDestroySurface(_egl_display, _egl_surface)) {
179 egldisplay_cat.error() <<
"Failed to destroy surface: "
184 if (_xwindow != (X11_Window)
nullptr) {
185 XDestroyWindow(_display, _xwindow);
186 _xwindow = (X11_Window)
nullptr;
192 GraphicsWindow::close_window();
199 bool eglGraphicsWindow::
202 DCAST_INTO_R(egl_pipe, _pipe,
false);
214 DCAST_INTO_R(eglgsg, _gsg,
false);
222 _visual_info = eglgsg->_visual;
223 if (_visual_info ==
nullptr) {
225 egldisplay_cat.error()
226 <<
"No X visual: cannot open window.\n";
230 setup_colormap(_visual_info);
232 if (!x11GraphicsWindow::open_window()) {
236 _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow,
nullptr);
237 if (eglGetError() != EGL_SUCCESS) {
238 egldisplay_cat.error()
239 <<
"Failed to create window surface.\n";
243 if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) {
244 egldisplay_cat.error() <<
"Failed to call eglMakeCurrent: "
247 eglgsg->reset_if_new();
248 if (!eglgsg->is_valid()) {
253 (_fb_properties, eglgsg->get_gl_renderer())) {