22 #include <EGL/eglext.h>
32 vector_string extensions;
33 const char *ext_ptr = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
34 if (ext_ptr !=
nullptr) {
37 if (egldisplay_cat.is_debug()) {
38 std::ostream &out = egldisplay_cat.debug()
39 <<
"Supported EGL client extensions:\n";
41 for (
const std::string &extension : extensions) {
42 out <<
" " << extension <<
"\n";
46 else if (egldisplay_cat.is_debug()) {
48 egldisplay_cat.debug()
49 <<
"EGL client extensions not supported.\n";
57 _egl_display = eglGetDisplay((NativeDisplayType) _display);
59 _egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
61 if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
62 egldisplay_cat.warning()
63 <<
"Couldn't initialize the default EGL display: "
65 _egl_display = EGL_NO_DISPLAY;
69 std::find(extensions.begin(), extensions.end(),
"EGL_EXT_platform_device") != extensions.end() &&
70 std::find(extensions.begin(), extensions.end(),
"EGL_EXT_device_enumeration") != extensions.end()) {
72 PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
73 (PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress(
"eglQueryDevicesEXT");
75 EGLint num_devices = 0;
76 if (eglQueryDevicesEXT !=
nullptr &&
77 eglQueryDevicesEXT(0,
nullptr, &num_devices) &&
79 EGLDeviceEXT *devices = (EGLDeviceEXT *)alloca(
sizeof(EGLDeviceEXT) * num_devices);
80 eglQueryDevicesEXT(num_devices, devices, &num_devices);
82 if (egldisplay_cat.is_debug()) {
83 egldisplay_cat.debug()
84 <<
"Found " << num_devices <<
" EGL devices.\n";
87 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
88 (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress(
"eglGetPlatformDisplayEXT");
90 if (eglGetPlatformDisplayEXT !=
nullptr) {
91 for (EGLint i = 0; i < num_devices && !_egl_display; ++i) {
92 _egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[i],
nullptr);
94 if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
95 egldisplay_cat.warning()
96 <<
"Couldn't initialize EGL platform display " << i <<
": "
98 _egl_display = EGL_NO_DISPLAY;
106 egldisplay_cat.error()
107 <<
"Failed to find or initialize a suitable EGL display connection.\n";
112 if (egldisplay_cat.is_debug()) {
113 egldisplay_cat.debug()
114 <<
"Successfully initialized EGL display, got version " << major <<
"." << minor <<
"\n";
117 #if defined(OPENGLES_1) || defined(OPENGLES_2)
118 if (!eglBindAPI(EGL_OPENGL_ES_API)) {
119 egldisplay_cat.error()
120 <<
"Couldn't bind EGL to the OpenGL ES API: "
123 if (!eglBindAPI(EGL_OPENGL_API)) {
124 egldisplay_cat.error()
125 <<
"Couldn't bind EGL to the OpenGL API: "
142 if (!eglTerminate(_egl_display)) {
143 egldisplay_cat.error() <<
"Failed to terminate EGL display: "
157 #if defined(OPENGLES_1) || defined(OPENGLES_2)
177 make_output(
const std::string &name,
193 DCAST_INTO_R(eglgsg, gsg,
nullptr);
214 if (((flags&BF_require_parasite)!=0)||
215 ((flags&BF_refuse_window)!=0)||
216 ((flags&BF_resizeable)!=0)||
217 ((flags&BF_size_track_host)!=0)||
218 ((flags&BF_rtt_cumulative)!=0)||
219 ((flags&BF_can_bind_color)!=0)||
220 ((flags&BF_can_bind_every)!=0)) {
223 return new eglGraphicsWindow(engine,
this, name, fb_prop, win_prop,
234 ((flags&BF_require_parasite)!=0)||
235 ((flags&BF_require_window)!=0)) {
240 if ((flags & BF_fb_props_optional)==0) {
241 if (fb_prop.get_indexed_color() > 0 ||
242 fb_prop.get_back_buffers() > 0 ||
243 fb_prop.get_accum_bits() > 0) {
250 (eglgsg->is_valid()) &&
251 (!eglgsg->needs_reset()) &&
252 (eglgsg->_supports_framebuffer_object) &&
253 (eglgsg->_glDrawBuffers != 0)&&
258 return new GLES2GraphicsBuffer(engine,
this, name, fb_prop, win_prop,
260 #elif defined(OPENGLES_1)
261 return new GLESGraphicsBuffer(engine,
this, name, fb_prop, win_prop,
264 return new GLGraphicsBuffer(engine,
this, name, fb_prop, win_prop,
271 if (((flags&BF_require_parasite)!=0)||
272 ((flags&BF_require_window)!=0)||
273 ((flags&BF_resizeable)!=0)||
274 ((flags&BF_size_track_host)!=0)) {
279 if (((flags&BF_rtt_cumulative)!=0)||
280 ((flags&BF_can_bind_every)!=0)) {
297 if (((flags&BF_require_parasite)!=0)||
298 ((flags&BF_require_window)!=0)||
299 ((flags&BF_resizeable)!=0)||
300 ((flags&BF_size_track_host)!=0)) {
304 if (((flags&BF_rtt_cumulative)!=0)||
305 ((flags&BF_can_bind_every)!=0)) {
309 return new eglGraphicsPixmap(engine,
this, name, fb_prop, win_prop,
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
bool is_basic() const
Returns true if the properties are extremely basic.
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.
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...
An offscreen buffer in the EGL environment.
This graphics pipe represents the interface for creating OpenGL ES graphics windows on an X-based (e....
virtual std::string get_interface_name() const
Returns the name of the rendering interface associated with this GraphicsPipe.
A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific information.
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.
int extract_words(const string &str, vector_string &words)
Divides the string into a number of words according to whitespace.