Added comments to EGL manager.
git-svn-id: http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4603 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
b6251df6e8
commit
58721c6e8a
@ -32,6 +32,7 @@ bool CEGLManager::initialize()
|
|||||||
if (EglWindow != 0 && EglDisplay != EGL_NO_DISPLAY)
|
if (EglWindow != 0 && EglDisplay != EGL_NO_DISPLAY)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Window is depend on platform.
|
||||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||||
EglWindow = (NativeWindowType)Data->OpenGLWin32.HWnd;
|
EglWindow = (NativeWindowType)Data->OpenGLWin32.HWnd;
|
||||||
HDc = GetDC((HWND)EglWindow);
|
HDc = GetDC((HWND)EglWindow);
|
||||||
@ -44,6 +45,7 @@ bool CEGLManager::initialize()
|
|||||||
EglDisplay = eglGetDisplay((NativeDisplayType) EGL_DEFAULT_DISPLAY);
|
EglDisplay = eglGetDisplay((NativeDisplayType) EGL_DEFAULT_DISPLAY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We must check if EGL display is valid.
|
||||||
if (EglDisplay == EGL_NO_DISPLAY)
|
if (EglDisplay == EGL_NO_DISPLAY)
|
||||||
{
|
{
|
||||||
os::Printer::log("Could not get EGL display.");
|
os::Printer::log("Could not get EGL display.");
|
||||||
@ -59,6 +61,7 @@ bool CEGLManager::initialize()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize EGL here.
|
||||||
if (!eglInitialize(EglDisplay, &MajorVersion, &MinorVersion))
|
if (!eglInitialize(EglDisplay, &MajorVersion, &MinorVersion))
|
||||||
{
|
{
|
||||||
os::Printer::log("Could not initialize EGL display.");
|
os::Printer::log("Could not initialize EGL display.");
|
||||||
@ -86,6 +89,7 @@ void CEGLManager::terminate()
|
|||||||
if (EglWindow == 0 && EglDisplay == EGL_NO_DISPLAY)
|
if (EglWindow == 0 && EglDisplay == EGL_NO_DISPLAY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// We should unbind current EGL context before terminate EGL.
|
||||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
eglTerminate(EglDisplay);
|
eglTerminate(EglDisplay);
|
||||||
@ -111,12 +115,15 @@ bool CEGLManager::createSurface()
|
|||||||
if (EglSurface != EGL_NO_SURFACE)
|
if (EglSurface != EGL_NO_SURFACE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// We should assign new WindowID on platforms, where WindowID may change at runtime,
|
||||||
|
// at this time only Android support this feature.
|
||||||
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||||
EglWindow = (ANativeWindow*)Data->OGLESAndroid.window;
|
EglWindow = (ANativeWindow*)Data->OGLESAndroid.window;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EGLint EglOpenGLBIT = 0;
|
EGLint EglOpenGLBIT = 0;
|
||||||
|
|
||||||
|
// We need properly OpenGL BIT.
|
||||||
switch (Params.DriverType)
|
switch (Params.DriverType)
|
||||||
{
|
{
|
||||||
case EDT_OGLES1:
|
case EDT_OGLES1:
|
||||||
@ -151,6 +158,7 @@ bool CEGLManager::createSurface()
|
|||||||
EGLint NumConfigs = 0;
|
EGLint NumConfigs = 0;
|
||||||
u32 Steps = 5;
|
u32 Steps = 5;
|
||||||
|
|
||||||
|
// Choose the best EGL config.
|
||||||
while (!eglChooseConfig(EglDisplay, Attribs, &EglConfig, 1, &NumConfigs) || !NumConfigs)
|
while (!eglChooseConfig(EglDisplay, Attribs, &EglConfig, 1, &NumConfigs) || !NumConfigs)
|
||||||
{
|
{
|
||||||
switch (Steps)
|
switch (Steps)
|
||||||
@ -238,7 +246,8 @@ bool CEGLManager::createSurface()
|
|||||||
|
|
||||||
ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, Format);
|
ANativeWindow_setBuffersGeometry(EglWindow, 0, 0, Format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Now we are able to create EGL surface.
|
||||||
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);
|
EglSurface = eglCreateWindowSurface(EglDisplay, EglConfig, EglWindow, 0);
|
||||||
|
|
||||||
if (EGL_NO_SURFACE == EglSurface)
|
if (EGL_NO_SURFACE == EglSurface)
|
||||||
@ -252,9 +261,11 @@ bool CEGLManager::createSurface()
|
|||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
eglBindAPI(EGL_OPENGL_ES_API);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// FIX-ME
|
||||||
if (Params.Vsync)
|
if (Params.Vsync)
|
||||||
eglSwapInterval(EglDisplay, 1);
|
eglSwapInterval(EglDisplay, 1);
|
||||||
|
|
||||||
|
// If EGL context already exist we should activate it.
|
||||||
if (EglContext != EGL_NO_CONTEXT)
|
if (EglContext != EGL_NO_CONTEXT)
|
||||||
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
eglMakeCurrent(EglDisplay, EglSurface, EglSurface, EglContext);
|
||||||
|
|
||||||
@ -266,6 +277,7 @@ void CEGLManager::destroySurface()
|
|||||||
if (EglSurface == EGL_NO_SURFACE)
|
if (EglSurface == EGL_NO_SURFACE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// We should unbind current EGL context before destroy EGL surface.
|
||||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
eglDestroySurface(EglDisplay, EglSurface);
|
eglDestroySurface(EglDisplay, EglSurface);
|
||||||
@ -320,7 +332,9 @@ void CEGLManager::destroyContext()
|
|||||||
if (EglContext == EGL_NO_CONTEXT)
|
if (EglContext == EGL_NO_CONTEXT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// We must unbind current EGL context before destroy it.
|
||||||
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
|
|
||||||
eglDestroyContext(EglDisplay, EglContext);
|
eglDestroyContext(EglDisplay, EglContext);
|
||||||
|
|
||||||
EglContext = EGL_NO_CONTEXT;
|
EglContext = EGL_NO_CONTEXT;
|
||||||
|
@ -32,21 +32,33 @@ namespace video
|
|||||||
virtual ~CEGLManager();
|
virtual ~CEGLManager();
|
||||||
|
|
||||||
// Initialize EGL.
|
// Initialize EGL.
|
||||||
|
/* This method initialize EGLand create EGL display, anyway surface and context
|
||||||
|
aren't create. */
|
||||||
bool initialize();
|
bool initialize();
|
||||||
|
|
||||||
// Terminate EGL.
|
// Terminate EGL.
|
||||||
|
/* Terminate EGL context. This method break both existed surface and context. */
|
||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
// Create EGL surface.
|
// Create EGL surface.
|
||||||
|
/* This method create EGL surface. On some platforms eg. Android, we must
|
||||||
|
recreate surface on each resume, because WindowID may change, so existed
|
||||||
|
surface may not be valid. If EGL context already exist, this method
|
||||||
|
automatically activates it. */
|
||||||
bool createSurface();
|
bool createSurface();
|
||||||
|
|
||||||
// Destroy EGL surface.
|
// Destroy EGL surface.
|
||||||
|
/* This method destroy EGL. On some platforms eg. Android, we should call
|
||||||
|
this method on each pause, because after resume this surface may not be valid.
|
||||||
|
Hovewer this method doesn'r break EGL context. */
|
||||||
void destroySurface();
|
void destroySurface();
|
||||||
|
|
||||||
// Create EGL context.
|
// Create EGL context.
|
||||||
|
/* This method create and activate EGL context. */
|
||||||
bool createContext();
|
bool createContext();
|
||||||
|
|
||||||
// Destroy EGL context.
|
// Destroy EGL context.
|
||||||
|
/* This method destroy EGL context. */
|
||||||
void destroyContext();
|
void destroyContext();
|
||||||
|
|
||||||
// Swap buffers.
|
// Swap buffers.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user