1 // Copyright (C) 2013 Patryk Nadrowski
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in Irrlicht.h
\r
5 #ifndef __C_EGL_MANAGER_H_INCLUDED__
\r
6 #define __C_EGL_MANAGER_H_INCLUDED__
\r
9 #ifdef _IRR_COMPILE_WITH_EGL_MANAGER_
\r
11 #include <EGL/egl.h>
\r
13 #include "SIrrCreationParameters.h"
\r
14 #include "SExposedVideoData.h"
\r
15 #include "IContextManager.h"
\r
22 class CEGLManager : public IContextManager
\r
29 virtual ~CEGLManager();
\r
32 /* This method initialize EGLand create EGL display, anyway surface and context
\r
34 bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) override;
\r
37 /* Terminate EGL context. This method break both existed surface and context. */
\r
38 void terminate() override;
\r
40 // Create EGL surface.
\r
41 /* This method create EGL surface. On some platforms eg. Android, we must
\r
42 recreate surface on each resume, because WindowID may change, so existed
\r
43 surface may not be valid. If EGL context already exist, this method
\r
44 automatically activates it. */
\r
45 bool generateSurface() override;
\r
47 // Destroy EGL surface.
\r
48 /* This method destroy EGL. On some platforms eg. Android, we should call
\r
49 this method on each pause, because after resume this surface may not be valid.
\r
50 Hovewer this method doesn'r break EGL context. */
\r
51 void destroySurface() override;
\r
53 // Create EGL context.
\r
54 /* This method create and activate EGL context. */
\r
55 bool generateContext() override;
\r
57 // Destroy EGL context.
\r
58 /* This method destroy EGL context. */
\r
59 void destroyContext() override;
\r
61 const SExposedVideoData& getContext() const override;
\r
63 bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero) override;
\r
65 // Get procedure address.
\r
66 void* getProcAddress(const std::string &procName) override;
\r
69 bool swapBuffers() override;
\r
74 //! Get first result of eglChooseConfigs and if that fails try again by requesting simpler attributes
\r
75 ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS,
\r
77 //! We select our own best fit and avoid using eglChooseConfigs
\r
81 EGLConfig chooseConfig(EConfigStyle confStyle);
\r
83 //! Check how close this config is to the parameters we requested
\r
84 //! returns 0 is perfect, larger values are worse and < 0 is unusable.
\r
85 irr::s32 rateConfig(EGLConfig config, EGLint eglOpenGLBIT, bool log=false);
\r
87 // Helper to sort EGLConfig's. (because we got no std::pair....)
\r
88 struct SConfigRating
\r
92 bool operator<(const SConfigRating& other) const
\r
94 return rating < other.rating;
\r
99 bool testEGLError();
\r
101 NativeWindowType EglWindow;
\r
102 EGLDisplay EglDisplay;
\r
103 EGLSurface EglSurface;
\r
104 EGLContext EglContext;
\r
106 EGLConfig EglConfig;
\r
108 SIrrlichtCreationParameters Params;
\r
109 SExposedVideoData Data;
\r
111 EGLint MajorVersion;
\r
112 EGLint MinorVersion;
\r