Abstract away the EGLManager into IContextManager and add the manager for win32/ogles1 as well.
Android device should still compile and work, but was not tested. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4596 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7afc23819b
commit
8d647c930e
|
@ -211,7 +211,7 @@ define out. */
|
|||
it should be usually the only HW accelerated one. OpenGL is currently disabled
|
||||
if using this driver, to avoid problems with the ogl-es emulators.
|
||||
*/
|
||||
// #define _IRR_COMPILE_WITH_OGLES1_
|
||||
#define _IRR_COMPILE_WITH_OGLES1_
|
||||
#ifdef NO_IRR_COMPILE_WITH_OGLES1_
|
||||
#undef _IRR_COMPILE_WITH_OGLES1_
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "CEGLManager.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "IGUIEnvironment.h"
|
||||
#include "CEGLManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
|||
Android->onInputEvent = handleInput;
|
||||
|
||||
// Create EGL manager.
|
||||
EGLManager = new video::CEGLManager(CreationParams, &ExposedVideoData);
|
||||
ContextManager = new video::CEGLManager(CreationParams, &ExposedVideoData);
|
||||
|
||||
os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG);
|
||||
|
||||
|
@ -103,8 +104,6 @@ CIrrDeviceAndroid::~CIrrDeviceAndroid()
|
|||
VideoDriver->drop();
|
||||
VideoDriver = 0;
|
||||
}
|
||||
|
||||
delete EGLManager;
|
||||
}
|
||||
|
||||
bool CIrrDeviceAndroid::run()
|
||||
|
@ -210,14 +209,14 @@ void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd)
|
|||
Device->CreationParams.WindowSize.Height = ANativeWindow_getHeight(app->window);
|
||||
}
|
||||
|
||||
Device->getEGLManager()->initializeEGL();
|
||||
Device->getEGLManager()->createSurface();
|
||||
Device->getEGLManager()->createContext();
|
||||
Device->getContextManager()->initialize();
|
||||
Device->getContextManager()->createSurface();
|
||||
Device->getContextManager()->createContext();
|
||||
Device->Initialized = true;
|
||||
break;
|
||||
case APP_CMD_TERM_WINDOW:
|
||||
os::Printer::log("Android command APP_CMD_TERM_WINDOW", ELL_DEBUG);
|
||||
Device->getEGLManager()->destroySurface();
|
||||
Device->getContextManager()->destroySurface();
|
||||
break;
|
||||
case APP_CMD_GAINED_FOCUS:
|
||||
os::Printer::log("Android command APP_CMD_GAINED_FOCUS", ELL_DEBUG);
|
||||
|
@ -345,11 +344,6 @@ video::SExposedVideoData& CIrrDeviceAndroid::getExposedVideoData()
|
|||
return ExposedVideoData;
|
||||
}
|
||||
|
||||
video::CEGLManager* CIrrDeviceAndroid::getEGLManager()
|
||||
{
|
||||
return EGLManager;
|
||||
}
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "IrrlichtDevice.h"
|
||||
#include "IImagePresenter.h"
|
||||
#include "ICursorControl.h"
|
||||
#include "CEGLManager.h"
|
||||
|
||||
#include <android/sensor.h>
|
||||
#include <android_native_app_glue.h>
|
||||
|
@ -66,8 +65,6 @@ namespace irr
|
|||
|
||||
video::SExposedVideoData& getExposedVideoData();
|
||||
|
||||
video::CEGLManager* getEGLManager();
|
||||
|
||||
android_app* Android;
|
||||
ASensorManager* SensorManager;
|
||||
ASensorEventQueue* SensorEventQueue;
|
||||
|
@ -77,7 +74,6 @@ namespace irr
|
|||
bool Paused;
|
||||
|
||||
video::SExposedVideoData ExposedVideoData;
|
||||
video::CEGLManager* EGLManager;
|
||||
};
|
||||
|
||||
} // end namespace irr
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace irr
|
|||
namespace video
|
||||
{
|
||||
|
||||
CEGLManager::CEGLManager(const SIrrlichtCreationParameters& params, SExposedVideoData* data) : EglWindow(0), EglDisplay(EGL_NO_DISPLAY),
|
||||
CEGLManager::CEGLManager(const SIrrlichtCreationParameters& params, SExposedVideoData* data) : IContextManager(), EglWindow(0), EglDisplay(EGL_NO_DISPLAY),
|
||||
EglSurface(EGL_NO_SURFACE), EglContext(EGL_NO_CONTEXT), EglConfig(0), Params(params), Data(data), MajorVersion(0), MinorVersion(0)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
|
@ -24,10 +24,10 @@ CEGLManager::~CEGLManager()
|
|||
{
|
||||
destroyContext();
|
||||
destroySurface();
|
||||
terminateEGL();
|
||||
terminate();
|
||||
}
|
||||
|
||||
bool CEGLManager::initializeEGL()
|
||||
bool CEGLManager::initialize()
|
||||
{
|
||||
if (EglWindow != 0 && EglDisplay != EGL_NO_DISPLAY)
|
||||
return true;
|
||||
|
@ -81,7 +81,7 @@ bool CEGLManager::initializeEGL()
|
|||
return true;
|
||||
}
|
||||
|
||||
void CEGLManager::terminateEGL()
|
||||
void CEGLManager::terminate()
|
||||
{
|
||||
if (EglWindow == 0 && EglDisplay == EGL_NO_DISPLAY)
|
||||
return;
|
||||
|
|
|
@ -15,26 +15,27 @@
|
|||
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "SExposedVideoData.h"
|
||||
#include "IContextManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
// EGL manager.
|
||||
class CEGLManager
|
||||
class CEGLManager : public IContextManager
|
||||
{
|
||||
public:
|
||||
//! Constructor.
|
||||
CEGLManager(const SIrrlichtCreationParameters& params, SExposedVideoData* data);
|
||||
|
||||
//! Destructor.
|
||||
~CEGLManager();
|
||||
virtual ~CEGLManager();
|
||||
|
||||
// Initialize EGL.
|
||||
bool initializeEGL();
|
||||
bool initialize();
|
||||
|
||||
// Terminate EGL.
|
||||
void terminateEGL();
|
||||
void terminate();
|
||||
|
||||
// Create EGL surface.
|
||||
bool createSurface();
|
||||
|
|
|
@ -21,7 +21,7 @@ CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params)
|
|||
: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0),
|
||||
Timer(0), CursorControl(0), UserReceiver(params.EventReceiver),
|
||||
Logger(0), Operator(0), Randomizer(0), FileSystem(0),
|
||||
InputReceivingSceneManager(0), VideoModeList(0),
|
||||
InputReceivingSceneManager(0), VideoModeList(0), ContextManager(0),
|
||||
CreationParams(params), Close(false)
|
||||
{
|
||||
Timer = new CTimer(params.UsePerformanceTimer);
|
||||
|
@ -63,6 +63,9 @@ CIrrDeviceStub::~CIrrDeviceStub()
|
|||
if (VideoDriver)
|
||||
VideoDriver->drop();
|
||||
|
||||
if (ContextManager)
|
||||
ContextManager->drop();
|
||||
|
||||
if (SceneManager)
|
||||
SceneManager->drop();
|
||||
|
||||
|
@ -109,6 +112,12 @@ video::IVideoDriver* CIrrDeviceStub::getVideoDriver()
|
|||
}
|
||||
|
||||
|
||||
//! return the context manager
|
||||
video::IContextManager* CIrrDeviceStub::getContextManager()
|
||||
{
|
||||
return ContextManager;
|
||||
}
|
||||
|
||||
|
||||
//! return file system
|
||||
io::IFileSystem* CIrrDeviceStub::getFileSystem()
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "IImagePresenter.h"
|
||||
#include "SIrrCreationParameters.h"
|
||||
#include "CVideoModeList.h"
|
||||
#include "IContextManager.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -76,6 +77,9 @@ namespace irr
|
|||
//! Returns a pointer to a list with all video modes supported by the gfx adapter.
|
||||
virtual video::IVideoModeList* getVideoModeList();
|
||||
|
||||
//! return the context manager
|
||||
virtual video::IContextManager* CIrrDeviceStub::getContextManager();
|
||||
|
||||
//! Returns a pointer to the ITimer object. With it the current Time can be received.
|
||||
virtual ITimer* getTimer();
|
||||
|
||||
|
@ -212,6 +216,7 @@ namespace irr
|
|||
};
|
||||
SMouseMultiClicks MouseMultiClicks;
|
||||
video::CVideoModeList* VideoModeList;
|
||||
video::IContextManager* ContextManager;
|
||||
SIrrlichtCreationParameters CreationParams;
|
||||
bool Close;
|
||||
};
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
#include "CEGLManager.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -53,7 +56,13 @@ namespace irr
|
|||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params, video::SExposedVideoData& data, io::IFileSystem* io);
|
||||
IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params, video::SExposedVideoData& data, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
|
@ -1148,9 +1157,12 @@ void CIrrDeviceWin32::createDriver()
|
|||
video::SExposedVideoData data;
|
||||
data.OpenGLWin32.HWnd=HWnd;
|
||||
|
||||
ContextManager = new video::CEGLManager(CreationParams,&data);
|
||||
ContextManager->initialize();
|
||||
ContextManager->createSurface();
|
||||
switchToFullScreen();
|
||||
|
||||
VideoDriver = video::createOGLES1Driver(CreationParams, data, FileSystem);
|
||||
VideoDriver = video::createOGLES1Driver(CreationParams, data, FileSystem, ContextManager);
|
||||
if (!VideoDriver)
|
||||
{
|
||||
os::Printer::log("Could not create OpenGL-ES1 driver.", ELL_ERROR);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace video
|
|||
COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, CEGLManager* eglManager
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params,
|
|||
Transformation3DChanged(true), AntiAlias(params.AntiAlias),
|
||||
RenderTargetTexture(0), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8)
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, EGLManager(eglManager)
|
||||
, ContextManager(contextManager)
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, Device(device), ViewFramebuffer(0),
|
||||
ViewRenderbuffer(0), ViewDepthRenderbuffer(0)
|
||||
|
@ -49,7 +49,11 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params,
|
|||
core::dimension2d<u32> WindowSize(0, 0);
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EGLManager->createContext();
|
||||
if (!ContextManager)
|
||||
return;
|
||||
|
||||
ContextManager->grab();
|
||||
ContextManager->createContext();
|
||||
|
||||
WindowSize = params.WindowSize;
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
|
@ -94,7 +98,11 @@ COGLES1Driver::~COGLES1Driver()
|
|||
deleteAllTextures();
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EGLManager->destroyContext();
|
||||
if (ContextManager)
|
||||
{
|
||||
ContextManager->destroyContext();
|
||||
ContextManager->drop();
|
||||
}
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
if (0 != ViewFramebuffer)
|
||||
{
|
||||
|
@ -261,7 +269,7 @@ bool COGLES1Driver::endScene()
|
|||
CNullDriver::endScene();
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
EGLManager->swapBuffers();
|
||||
ContextManager->swapBuffers();
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
glFlush();
|
||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, ViewRenderbuffer);
|
||||
|
@ -3027,7 +3035,7 @@ class CEGLManager;
|
|||
IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
video::SExposedVideoData& data, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, CEGLManager* eglManager
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
|
@ -3036,7 +3044,7 @@ IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params,
|
|||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||
return new COGLES1Driver(params, data, io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, eglManager
|
||||
, contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, device
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace video
|
|||
COGLES1Driver(const SIrrlichtCreationParameters& params,
|
||||
const SExposedVideoData& data, io::IFileSystem* io
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
, CEGLManager* eglManager
|
||||
, IContextManager* contextManager
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
, CIrrDeviceIPhone* device
|
||||
#endif
|
||||
|
@ -370,7 +370,7 @@ namespace video
|
|||
GLuint ViewRenderbuffer;
|
||||
GLuint ViewDepthRenderbuffer;
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_WINDOWS_API_) || defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
CEGLManager* EGLManager;
|
||||
IContextManager* ContextManager;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (C) 2013 Patryk Nadrowski
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
|
||||
#define __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
class IContextManager : public virtual IReferenceCounted
|
||||
{
|
||||
public:
|
||||
// Initialize manager
|
||||
virtual bool initialize() =0;
|
||||
|
||||
// Terminate manager
|
||||
virtual void terminate() =0;
|
||||
|
||||
// Create surface.
|
||||
virtual bool createSurface() =0;
|
||||
|
||||
// Destroy surface.
|
||||
virtual void destroySurface() =0;
|
||||
|
||||
// Create context.
|
||||
virtual bool createContext() =0;
|
||||
|
||||
// Destroy context.
|
||||
virtual void destroyContext() =0;
|
||||
|
||||
// Swap buffers.
|
||||
virtual void swapBuffers() =0;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif
|
|
@ -1013,6 +1013,7 @@
|
|||
<ClInclude Include="COGLESMaterialRenderer.h" />
|
||||
<ClInclude Include="COGLESTexture.h" />
|
||||
<ClInclude Include="CSceneManager.h" />
|
||||
<ClInclude Include="IContextManager.h" />
|
||||
<ClInclude Include="Octree.h" />
|
||||
<ClInclude Include="CSMFMeshFileLoader.h" />
|
||||
<ClInclude Include="C3DSMeshFileLoader.h" />
|
||||
|
|
|
@ -1357,6 +1357,9 @@
|
|||
<ClInclude Include="CImageLoaderPVR.h">
|
||||
<Filter>Irrlicht\video\Null\Loader</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IContextManager.h">
|
||||
<Filter>include\video</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\changes.txt">
|
||||
|
|
Loading…
Reference in New Issue