2 // Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "gnashconfig.h"
27 // #include "RunResources.h"
29 #include "GnashException.h"
34 # error "This file needs EGL, which is part of OpenGL-ES"
39 #include "eglDevice.h"
41 #include "configTemplates.h"
47 // The debug log used by all the gnash libraries.
48 static LogFile
& dbglogfile
= LogFile::getDefaultInstance();
50 EGLDevice::EGLDevice()
52 _eglContext(EGL_NO_CONTEXT
),
53 _eglSurface(EGL_NO_SURFACE
),
54 _eglDisplay(EGL_NO_DISPLAY
),
63 GNASH_REPORT_FUNCTION
;
68 EGLDevice::EGLDevice(int argc
, char *argv
[])
70 _eglContext(EGL_NO_CONTEXT
),
71 _eglSurface(EGL_NO_SURFACE
),
72 _eglDisplay(EGL_NO_DISPLAY
),
81 GNASH_REPORT_FUNCTION
;
85 if (!initDevice(argc
, argv
)) {
86 log_error(_("Couldn't initialize EGL device!"));
90 EGLDevice::EGLDevice(GnashDevice::rtype_t rtype
)
92 _eglContext(EGL_NO_CONTEXT
),
93 _eglSurface(EGL_NO_SURFACE
),
94 _eglDisplay(EGL_NO_DISPLAY
),
103 GNASH_REPORT_FUNCTION
;
107 if (!initDevice(0, 0)) {
108 log_error(_("Couldn't initialize EGL device!"));
110 if (!bindClient(rtype
)) {
111 log_error(_("Couldn't bind client to type %d!"), rtype
);
116 EGLDevice::setAttrib(int bpp
)
120 _attrib
= attrib32_low
;
123 _attrib
= attrib16_low
;
126 _attrib
= attrib1_list
;
131 EGLDevice::~EGLDevice()
133 // GNASH_REPORT_FUNCTION;
135 if (_eglDisplay
!= EGL_NO_DISPLAY
) {
136 eglMakeCurrent(_eglDisplay
, EGL_NO_SURFACE
, EGL_NO_SURFACE
, EGL_NO_CONTEXT
);
138 std::vector
<EGLSurface
>::iterator it
;
139 for (it
= _pbuffers
.begin(); it
!= _pbuffers
.end(); ++it
) {
140 eglDestroySurface(_eglDisplay
, *it
);
143 if (_eglContext
!= EGL_NO_CONTEXT
)
144 eglDestroyContext(_eglDisplay
, _eglContext
);
146 if (_eglSurface
!= EGL_NO_SURFACE
)
147 eglDestroySurface(_eglDisplay
, _eglSurface
);
149 eglTerminate(_eglDisplay
);
153 /// @note: There are a few steps required to initialize an EGL
154 /// Device. This uses threee methods to do so, two are defaults from
155 /// the base class, one is an additional class that is EGL specific.
157 /// To start, initialize the device with the command line
158 /// arguments. These are ignored by EGL, but passed through here to
159 /// follow the way most other Devices need to be initialized.
161 /// Once initialized, EGL must be told which Client API to use, this
162 /// is either OpenVG, OpenGLES1, or OpenGLES2. To do this, we bind the
163 /// EGL device to the client API.
165 /// Once bound, the last step attaches the window surface of the
166 /// desktop or framebuffer to EGL. This is what binds EGL to the
167 /// desktop or framebuffer.
169 EGLDevice::initDevice(int /* argc */, char **/
*argv
[] */
)
171 // EGLDevice::rtype_t rtype;
173 dbglogfile
.setVerbosity(2);
175 GNASH_REPORT_FUNCTION
;
177 // step 1 - get an EGL display
178 // _eglDisplay = eglGetDisplay(XOpenDisplay(0));
179 _eglDisplay
= eglGetDisplay(EGL_DEFAULT_DISPLAY
);
180 if (EGL_NO_DISPLAY
== _eglDisplay
) {
181 log_error(_( "eglGetDisplay() failed (error 0x%x)"), eglGetError());
185 // This can be called multiple times safely
186 if (eglInitialize(_eglDisplay
, 0, 0) != EGL_TRUE
) {
187 log_error(_( "eglInitialize() failed (error %s)"),
188 getErrorString(eglGetError()));
192 // step2 - bind to the wanted client API
193 /// This is done by bindClient() later on
194 // bindClient(GnashDevice::OPENVG);
195 // queryEGLConfig(_eglDisplay);
197 log_debug(_("EGL_CLIENT_APIS = %s"), eglQueryString(_eglDisplay
, EGL_CLIENT_APIS
));
198 log_debug(_("EGL_EXTENSIONS = %s"), eglQueryString(_eglDisplay
, EGL_EXTENSIONS
));
199 log_debug(_("EGL_VERSION = %s, EGL_VENDOR = %s"),
200 eglQueryString(_eglDisplay
, EGL_VERSION
),
201 eglQueryString(_eglDisplay
, EGL_VENDOR
));
203 // step3 - find a suitable config
204 EGLint max_num_config
= 0;
206 // Get the number of supported configurations
207 if ( EGL_FALSE
== eglGetConfigs(_eglDisplay
, 0, 0, &max_num_config
) ) {
208 log_error(_("eglGetConfigs() failed to retrieve the number of configs (error %s)"),
209 getErrorString(eglGetError()));
212 if(max_num_config
<= 0) {
213 log_error(_( "No EGLconfigs found\n" ));
216 log_debug(_("Max number of EGL Configs is %d"), max_num_config
);
218 // The quality of the rendering is controlled by the number of samples
219 // and sample buffers as specified in the configuration. Higher quality
220 // settings force lower performance.
222 // eglChooseConfig() always returns EGL_SUCCESS, so we we just check the
223 // returned number of configurations to see if eglChooseConfig() actually
224 // found a workable configuration.
225 EGLint eglNumOfConfigs
= 0;
228 eglChooseConfig(_eglDisplay
, attrib32_low
, &_eglConfig
,
229 1, &eglNumOfConfigs
);
230 if (eglNumOfConfigs
) {
231 log_debug(_("Using the 32bpp, low quality configuration"));
233 log_error(_("eglChooseConfig(32-low) failed"));
234 eglChooseConfig(_eglDisplay
, attrib16_low
, &_eglConfig
,
235 1, &eglNumOfConfigs
);
236 if (eglNumOfConfigs
) {
237 log_debug(_("Using the 16bpp, low quality configuration"));
239 log_error(_("eglChooseConfig(16-low) failed"));
244 case EGLDevice::MEDIUM
:
245 eglChooseConfig(_eglDisplay
, attrib32_medium
, &_eglConfig
,
246 1, &eglNumOfConfigs
);
247 if (eglNumOfConfigs
) {
248 log_debug(_("Using the 32bpp, medium quality configuration"));
250 log_error(_("eglChooseConfig(32-medium) failed"));
251 eglChooseConfig(_eglDisplay
, attrib16_medium
, &_eglConfig
,
252 1, &eglNumOfConfigs
);
253 if (eglNumOfConfigs
) {
254 log_debug(_("Using the 16bpp, medium quality configuration"));
256 log_error(_("eglChooseConfig(16-medium) failed"));
261 case EGLDevice::HIGH
:
262 eglChooseConfig(_eglDisplay
, attrib32_high
, &_eglConfig
,
263 1, &eglNumOfConfigs
);
264 if (eglNumOfConfigs
) {
265 log_debug(_("Using the 32bpp, high quality configuration"));
267 log_error(_("eglChooseConfig(32-high) failed"));
268 eglChooseConfig(_eglDisplay
, attrib16_high
, &_eglConfig
,
269 1, &eglNumOfConfigs
);
270 if (eglNumOfConfigs
) {
271 log_debug(_("Using the 16bpp, medium quality configuration"));
273 log_error(_("eglChooseConfig(16-high) failed"));
282 if (!checkEGLConfig(_eglConfig
)) {
283 log_error(_("EGL configuration doesn't match!"));
286 printEGLConfig(_eglConfig
);
293 EGLDevice::supportsRenderer(rtype_t rtype
)
295 GNASH_REPORT_FUNCTION
;
297 if (_eglDisplay
&& _eglContext
) {
299 eglQueryContext(_eglDisplay
, _eglContext
, EGL_CONTEXT_CLIENT_TYPE
, &value
);
301 if ((value
== EGL_OPENGL_ES_API
) && (rtype
== EGLDevice::OPENGLES2
)) {
303 } else if ((value
== EGL_OPENGL_ES_API
) && (rtype
== EGLDevice::OPENGLES1
)) {
305 } else if ((value
== EGL_OPENVG_API
) && (rtype
== EGLDevice::OPENVG
)){
312 #ifdef BUILD_X11_DEVICE
314 EGLDevice::getNativeVisual()
317 if (_eglDisplay
&& _eglConfig
) {
318 if (!eglGetConfigAttrib(_eglDisplay
, _eglConfig
, EGL_NATIVE_VISUAL_ID
, &vid
)) {
319 log_error(_("eglGetConfigAttrib() failed (error %s)"),
320 getErrorString(eglGetError()));
323 log_debug(_("EGL native visual is: %d"), vid
);
332 EGLDevice::bindClient(rtype_t rtype
)
334 GNASH_REPORT_FUNCTION
;
337 case GnashDevice::OPENGLES2
:
339 log_debug(_("Initializing EGL for OpenGLES2"));
340 if(EGL_FALSE
== eglBindAPI(EGL_OPENGL_ES_API
)) {
341 log_error(_("eglBindAPI() failed to retrieve the number of configs (error %s)"),
342 getErrorString(eglGetError()));
347 case GnashDevice::OPENGLES1
:
349 log_debug(_("Initializing EGL for OpenGLES1"));
350 if(EGL_FALSE
== eglBindAPI(EGL_OPENGL_ES_API
)) {
351 log_error(_("eglBindAPI() failed to retrive the number of configs (error %s)"),
352 getErrorString(eglGetError()));
357 case GnashDevice::OPENVG
:
359 log_debug(_("Initializing EGL for OpenVG"));
360 if(EGL_FALSE
== eglBindAPI(EGL_OPENVG_API
)) {
361 log_error(_("eglBindAPI() failed to retrieve the number of configs (error %s)"),
362 getErrorString(eglGetError()));
367 case GnashDevice::XORG
:
368 case GnashDevice::VAAPI
:
376 EGLDevice::attachWindow(GnashDevice::native_window_t window
)
378 GNASH_REPORT_FUNCTION
;
381 throw GnashException("bogus window handle!");
383 #ifdef EGL_NATIVE_WINDOW_INT
384 _nativeWindow
= static_cast<EGLNativeWindowType
>(window
);
386 _nativeWindow
= reinterpret_cast<EGLNativeWindowType
>(window
);
390 if (_eglSurface
!= EGL_NO_SURFACE
) {
391 eglDestroySurface(_eglDisplay
, _eglSurface
);
394 log_debug(_("Initializing EGL Surface"));
395 if (_eglDisplay
&& _eglConfig
) {
396 _eglSurface
= eglCreateWindowSurface(_eglDisplay
, _eglConfig
,
397 _nativeWindow
, surface_attributes
);
400 if (EGL_NO_SURFACE
== _eglSurface
) {
401 log_error(_("eglCreateWindowSurface failed (error %s)"),
402 getErrorString(eglGetError()));
404 printEGLSurface(_eglSurface
);
407 // step5 - create a context
408 _eglContext
= eglCreateContext(_eglDisplay
, _eglConfig
, EGL_NO_CONTEXT
, NULL
);
409 if (EGL_NO_CONTEXT
== _eglContext
) {
410 // At least on Ubuntu 10.10, this returns a successful error string
411 // with LibeMesa's OpenVG 1.0 implementation. With OpenVG 1.1 on
412 // an ARM board, this works fine. Even the libMesa examples fail
414 boost::format fmt
= boost::format(
415 _("eglCreateContext failed (error %s)")
416 ) % getErrorString(eglGetError());
417 throw GnashException(fmt
.str());
419 printEGLContext(_eglContext
);
422 // step6 - make the context and surface current
423 if (EGL_FALSE
== eglMakeCurrent(_eglDisplay
, _eglSurface
, _eglSurface
, _eglContext
)) {
424 // If for some reason we get a context, but can't make it current,
425 // nothing else will work anyway, so don't continue.
426 boost::format fmt
= boost::format(
427 _("eglMakeCurrent failed (error %s)")
428 ) % getErrorString(eglGetError());
429 throw GnashException(fmt
.str());
436 EGLDevice::getErrorString(int error
)
440 return "EGL_SUCCESS";
441 case EGL_NOT_INITIALIZED
:
442 return "EGL_NOT_INITIALIZED";
444 return "EGL_BAD_ACCESS";
446 return "EGL_BAD_ALLOC";
447 case EGL_BAD_ATTRIBUTE
:
448 return "EGL_BAD_ATTRIBUTE";
450 return "EGL_BAD_CONFIG";
451 case EGL_BAD_CONTEXT
:
452 return "EGL_BAD_CONTEXT";
453 case EGL_BAD_CURRENT_SURFACE
:
454 return "EGL_BAD_CURRENT_SURFACE";
455 case EGL_BAD_DISPLAY
:
456 return "EGL_BAD_DISPLAY";
458 return "EGL_BAD_MATCH";
459 case EGL_BAD_NATIVE_PIXMAP
:
460 return "EGL_BAD_NATIVE_PIXMAP";
461 case EGL_BAD_NATIVE_WINDOW
:
462 return "EGL_BAD_NATIVE_WINDOW";
463 case EGL_BAD_PARAMETER
:
464 return "EGL_BAD_PARAMETER";
465 case EGL_BAD_SURFACE
:
466 return "EGL_BAD_SURFACE";
467 case EGL_CONTEXT_LOST
:
468 return "EGL_CONTEXT_LOST";
470 return "unknown error code";
475 EGLDevice::checkEGLConfig(EGLConfig config
)
477 // GNASH_REPORT_FUNCTION;
479 // Use this to explicitly check that the EGL config has the expected color depths
482 eglGetConfigAttrib(_eglDisplay
, config
, EGL_RED_SIZE
, &value
);
486 eglGetConfigAttrib(_eglDisplay
, config
, EGL_GREEN_SIZE
, &value
);
490 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BLUE_SIZE
, &value
);
494 eglGetConfigAttrib(_eglDisplay
, config
, EGL_ALPHA_SIZE
, &value
);
498 eglGetConfigAttrib(_eglDisplay
, config
, EGL_SAMPLES
, &value
);
502 } else if (_bpp
== 16) {
503 eglGetConfigAttrib(_eglDisplay
, config
, EGL_RED_SIZE
, &value
);
507 eglGetConfigAttrib(_eglDisplay
, config
, EGL_GREEN_SIZE
, &value
);
511 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BLUE_SIZE
, &value
);
515 eglGetConfigAttrib(_eglDisplay
, config
, EGL_ALPHA_SIZE
, &value
);
519 eglGetConfigAttrib(_eglDisplay
, config
, EGL_SAMPLES
, &value
);
525 #ifdef RENDERER_OPENVG
537 /// Query the system for all supported configs
539 EGLDevice::queryEGLConfig(EGLDisplay display
)
541 GNASH_REPORT_FUNCTION
;
542 EGLConfig
*configs
= 0;
543 EGLint max_num_config
= 0;
545 // Get the number of supported configurations
546 if ( EGL_FALSE
== eglGetConfigs(display
, 0, 0, &max_num_config
) ) {
547 log_error(_("eglGetConfigs() failed to retrieve the number of configs (error %s)"),
548 getErrorString(eglGetError()));
551 if(max_num_config
<= 0) {
552 log_error(_("No EGLconfigs found\n"));
555 log_debug(_("Max number of EGL Configs is %d"), max_num_config
);
557 configs
= new EGLConfig
[max_num_config
];
559 log_error(_("Out of memory\n"));
563 if ( EGL_FALSE
== eglGetConfigs(display
, configs
, max_num_config
, &max_num_config
)) {
564 log_error(_("eglGetConfigs() failed to retrieve the configs (error %s)"),
565 getErrorString(eglGetError()));
570 // This prints out all the configurations, so it can be quite large
571 for (int i
=0; i
<max_num_config
; i
++ ) {
572 std::cerr
<< "Config[" << i
<< "] is:" << std::endl
;
573 printEGLConfig(configs
[i
]);
577 return max_num_config
;
581 EGLDevice::printEGLAttribs(const EGLint
*attrib
)
584 std::cout
<< "Printing EGL Attributes list" << std::endl
;
586 while (attrib
[i
] != EGL_NONE
) {
589 std::cout
<< "\tRed: " << attrib
[i
+1];
592 std::cout
<< ", Green: " << attrib
[i
+1];
595 std::cout
<< ", Blue: " << attrib
[i
+1] << std::endl
;
598 std::cout
<< ", Depth: " << attrib
[i
+1] << std::endl
;
600 case EGL_RENDERABLE_TYPE
:
601 if (attrib
[i
+1] & EGL_OPENVG_BIT
) {
602 std::cout
<< "\tOpenVG Renderable" << std::endl
;
604 if (attrib
[i
+1] & EGL_OPENGL_ES_BIT
) {
605 std::cout
<< "\tOpenGLES1 Renderable" << std::endl
;
607 if (attrib
[i
+1] & EGL_OPENGL_ES2_BIT
) {
608 std::cout
<< "\tOpenGLES2 Renderable" << std::endl
;
617 std::cout
<< "----------------------------------" << std::endl
;
621 EGLDevice::printEGLConfig(EGLConfig config
)
623 EGLint red
, blue
, green
;
625 eglGetConfigAttrib(_eglDisplay
, config
, EGL_RED_SIZE
, &red
);
626 eglGetConfigAttrib(_eglDisplay
, config
, EGL_GREEN_SIZE
, &green
);
627 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BLUE_SIZE
, &blue
);
628 std::cout
<< "\tConfig has RED = " << red
<< ", GREEN = " << green
629 << ", BLUE = " << blue
<< std::endl
;
631 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BUFFER_SIZE
, &value
);
632 std::cout
<< "\tEGL_BUFFER_SIZE is " << value
<< std::endl
;
633 eglGetConfigAttrib(_eglDisplay
, config
, EGL_ALPHA_SIZE
, &value
);
634 std::cout
<< "\tEGL_ALPHA_SIZE is " << value
<< std::endl
;
635 eglGetConfigAttrib(_eglDisplay
, config
, EGL_ALPHA_MASK_SIZE
, &value
);
636 std::cout
<< "\tEGL_ALPHA_MASK_SIZE is " << value
<< std::endl
;
637 eglGetConfigAttrib(_eglDisplay
, config
, EGL_STENCIL_SIZE
, &value
);
638 std::cout
<< "\tEGL_STENCIL_SIZE is " << value
<< std::endl
;
639 eglGetConfigAttrib(_eglDisplay
, config
, EGL_SAMPLES
, &value
);
640 std::cout
<< "\tEGL_SAMPLES is " << value
<< std::endl
;
641 eglGetConfigAttrib(_eglDisplay
, config
, EGL_DEPTH_SIZE
, &value
);
642 std::cout
<< "\tEGL_DEPTH_SIZE is " << value
<< std::endl
;
643 eglGetConfigAttrib(_eglDisplay
, config
, EGL_MAX_SWAP_INTERVAL
, &value
);
644 std::cout
<< "\tEGL_MAX_SWAP_INTERVAL is " << value
<< std::endl
;
645 eglGetConfigAttrib(_eglDisplay
, config
, EGL_MIN_SWAP_INTERVAL
, &value
);
646 std::cout
<< "\tEGL_MIN_SWAP_INTERVAL is " << value
<< std::endl
;
647 eglGetConfigAttrib(_eglDisplay
, config
, EGL_NATIVE_RENDERABLE
, &value
);
648 std::string val
= (value
)? "true" : "false";
649 std::cout
<< "\tEGL_NATIVE_RENDERABLE is " << val
<< std::endl
;
650 eglGetConfigAttrib(_eglDisplay
, config
, EGL_SAMPLE_BUFFERS
, &value
);
651 std::cout
<< "\tEGL_SAMPLE_BUFFERS is " << value
<< std::endl
;
652 eglGetConfigAttrib(_eglDisplay
, config
, EGL_RENDERABLE_TYPE
, &value
);
655 if (value
& EGL_OPENGL_ES2_BIT
) {
656 str
+= " OpenGL-ES 2.0";
658 if (value
& EGL_OPENGL_ES_BIT
) {
659 str
+= " OpenGL-ES 1.1";
661 if (value
& EGL_OPENVG_BIT
) {
664 if (value
& EGL_OPENGL_BIT
) {
667 std::cout
<<"\tEGL_RENDERABLE_TYPE = " << str
<< std::endl
;
669 std::cout
<<"\tEGL_RENDERABLE_TYPE (default)" << std::endl
;
671 eglGetConfigAttrib(_eglDisplay
, config
, EGL_SURFACE_TYPE
, &value
);
674 if (value
& EGL_WINDOW_BIT
) {
677 if (value
& EGL_PIXMAP_BIT
) {
680 if (value
& EGL_PBUFFER_BIT
) {
683 std::cout
<<"\tEGL_SURFACE_TYPE = " << str
<< std::endl
;
685 std::cout
<<"\tEGL_SURFACE_TYPE (default)" << std::endl
;
688 eglGetConfigAttrib(_eglDisplay
, config
, EGL_CONFIG_CAVEAT
, &value
);
691 if (value
& EGL_NONE
) {
694 if (value
& EGL_SLOW_CONFIG
) {
695 str
+= " EGL_SLOW_CONFIG";
697 if (value
& EGL_NON_CONFORMANT_CONFIG
) {
698 str
+= " EGL_NON_CONFORMANT_CONFIG";
700 std::cout
<<"\tEGL_CONFIG_CAVEAT = " << str
<< std::endl
;
702 std::cout
<<"\tEGL_CONFIG_CAVEAT (default)" << std::endl
;
705 #ifdef BUILD_X11_DEVICE
706 eglGetConfigAttrib(_eglDisplay
, config
, EGL_NATIVE_VISUAL_ID
, &value
);
707 std::cout
<< "\tX11 Visual is: " << value
<< std::endl
;
710 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BIND_TO_TEXTURE_RGB
, &value
);
711 val
= (value
)? "true" : "false";
712 std::cout
<< "\tEGL_BIND_TO_TEXTURE_RGB is " << val
<< std::endl
;
714 eglGetConfigAttrib(_eglDisplay
, config
, EGL_BIND_TO_TEXTURE_RGBA
, &value
);
715 val
= (value
)? "true" : "false";
716 std::cout
<< "\tEGL_BIND_TO_TEXTURE_RGBA is " << val
<< std::endl
;
721 EGLDevice::printEGLContext(EGLContext context
)
724 eglQueryContext(_eglDisplay
, context
, EGL_CONFIG_ID
, &value
);
725 std::cout
<< "Context EGL_CONFIG_ID is " << value
<< std::endl
;
726 eglQueryContext(_eglDisplay
, context
, EGL_CONTEXT_CLIENT_TYPE
, &value
);
727 std::cout
<< "\tEGL_CONTEXT_CLIENT_TYPE is "
728 << std::string((value
== EGL_OPENVG_API
)
729 ? "EGL_OPENVG_API" : "EGL_OPENGL_ES_API") << std::endl
;
730 // eglQueryContext(_eglDisplay, context, EGL_CONTEXT_CLIENT_VERSION, &value);
731 // log_debug("EGL_CONTEXT_CLIENT_VERSION is %d", value);
732 eglQueryContext(_eglDisplay
, context
, EGL_RENDER_BUFFER
, &value
);
733 std::cout
<< "\tEGL_RENDER_BUFFER is " << std::string((value
== EGL_BACK_BUFFER
)
734 ? "EGL_BACK_BUFFER" : "EGL_SINGLE_BUFFER") << std::endl
;
738 EGLDevice::printEGLSurface(EGLSurface surface
)
741 eglQuerySurface(_eglDisplay
, surface
, EGL_CONFIG_ID
, &value
);
742 std::cout
<< "Surface EGL_CONFIG_ID is " << value
<< std::endl
;
743 eglQuerySurface(_eglDisplay
, surface
, EGL_HEIGHT
, &value
);
744 std::cout
<< "\tEGL_HEIGHT is " << value
<< std::endl
;
745 eglQuerySurface(_eglDisplay
, surface
, EGL_WIDTH
, &value
);
746 std::cout
<< "\tEGL_WIDTH is " << value
<< std::endl
;
747 eglQuerySurface(_eglDisplay
, surface
, EGL_RENDER_BUFFER
, &value
);
748 std::cout
<< "\tEGL_RENDER_BUFFER is " << std::string((value
== EGL_BACK_BUFFER
)
749 ? "EGL_BACK_BUFFER" : "EGL_SINGLE_BUFFER") << std::endl
;
750 eglQuerySurface(_eglDisplay
, surface
, EGL_VERTICAL_RESOLUTION
, &value
);
751 std::cout
<< "\tEGL_VERTICAL_RESOLUTION is " << value
<< std::endl
;
752 eglQuerySurface(_eglDisplay
, surface
, EGL_HORIZONTAL_RESOLUTION
, &value
);
753 std::cout
<< "\tEGL_HORIZONTAL_RESOLUTION is " << value
<< std::endl
;
754 eglQuerySurface(_eglDisplay
, surface
, EGL_SWAP_BEHAVIOR
, &value
);
755 std::cout
<< "\tEGL_SWAP_BEHAVIOR is "
756 << std::string((value
== EGL_BUFFER_DESTROYED
)
757 ? "EGL_BUFFER_DESTROYED" : "EGL_BUFFER_PRESERVED") << std::endl
;
758 eglQuerySurface(_eglDisplay
, surface
, EGL_MULTISAMPLE_RESOLVE
, &value
);
759 std::cout
<< "\tEGL_MULTISAMPLE_RESOLVE is "
760 << std::string((value
== EGL_MULTISAMPLE_RESOLVE_BOX
)
761 ? "EGL_MULTISAMPLE_RESOLVE_BOX" : "EGL_MULTISAMPLE_RESOLVE_DEFAULT") << std::endl
;
764 // EGL WIDTH, EGL HEIGHT, EGL LARGEST PBUFFER, EGL TEXTURE FORMAT,
765 // EGL TEXTURE TARGET, EGL MIPMAP TEXTURE, EGL COLORSPACE, and EGL ALPHA FORMAT.
767 EGLDevice::createPbuffer(int width
, int height
)
769 const EGLint attribs
[] = {
775 EGLSurface pbuf
= eglCreatePbufferSurface(_eglDisplay
, _eglConfig
, attribs
);
776 if (pbuf
== EGL_NO_SURFACE
) {
777 log_error(_( "eglCreatePbufferSurface() failed (error 0x%x)"), eglGetError());
778 return EGL_NO_SURFACE
;
781 _pbuffers
.push_back(pbuf
);
786 EGLDevice::createPbuffer(int width
, int height
, EGLClientBuffer buf
, EGLenum type
)
788 const EGLint attribs
[] = {
794 EGLSurface pbuf
= eglCreatePbufferFromClientBuffer(_eglDisplay
, type
, buf
,
795 _eglConfig
, attribs
);
796 if (pbuf
== EGL_NO_SURFACE
) {
797 log_error(_("eglCreatePbufferFromClientBuffer() failed (error 0x%x)"),
799 return EGL_NO_SURFACE
;
802 _pbuffers
.push_back(pbuf
);
808 EGLDevice::createPixmap(int width
, int height
, NativePixmapType buf
)
810 const EGLint attribs
[] = {
816 EGLSurface pbuf
= eglCreatePixmapSurface(_eglDisplay
, _eglConfig
, buf
, attribs
);
817 if (pbuf
== EGL_NO_SURFACE
) {
818 log_error(_("eglCreatePbufferFromClientBuffer() failed (error 0x%x)"),
820 return EGL_NO_SURFACE
;
823 _pbuffers
.push_back(pbuf
);
828 // Set the bitmask for the configured renderable types.
830 EGLDevice::getRenderableTypes()
833 #ifdef RENDERER_GLES1
834 type
= type
| EGL_OPENGL_ES_BIT
;
836 #ifdef RENDERER_GLES2
837 type
= type
| EGL_OPENGL_ES2_BIT
;
839 #ifdef RENDERER_OPENVG
840 type
= type
| EGL_OPENVG_BIT
;
847 } // namespace renderer
852 // indent-tabs-mode: nil