To stay in Irrlicht style add 'virtual' qualifiers in derived classes.
Also improve some code comments. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5555 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
66530e3941
commit
87546d90ad
|
@ -128,8 +128,8 @@ bool CEGLManager::generateSurface()
|
|||
#endif
|
||||
|
||||
#if defined(_IRR_EMSCRIPTEN_PLATFORM_)
|
||||
// eglChooseConfig is only implemented as stub in emscripten currently (version 1.37.22 at point of writing)
|
||||
// So we have to chose ourselves.
|
||||
// eglChooseConfig is currently only implemented as stub in emscripten (version 1.37.22 at point of writing)
|
||||
// But the other solution would also be fine as it also only generates a single context so there is not much to choose from.
|
||||
EglConfig = chooseConfig(ECS_IRR_CHOOSE);
|
||||
#else
|
||||
EglConfig = chooseConfig(ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS);
|
||||
|
@ -212,6 +212,14 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
|
|||
u32 steps = 5;
|
||||
|
||||
// Choose the best EGL config.
|
||||
// TODO: We should also have a confStyle ECS_EGL_CHOOSE_CLOSEST
|
||||
// which doesn't take first result of eglChooseConfigs,
|
||||
// but the closest to requested parameters. eglChooseConfigs
|
||||
// can return more than 1 result and first one might have
|
||||
// "better" values than requested (more bits per pixel etc).
|
||||
// So this returns the config which can do most, not the
|
||||
// config which is closest to the requested parameters.
|
||||
//
|
||||
while (!eglChooseConfig(EglDisplay, Attribs, &configResult, 1, &numConfigs) || !numConfigs)
|
||||
{
|
||||
switch (steps)
|
||||
|
@ -294,6 +302,7 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
|
|||
}
|
||||
else if ( confStyle == ECS_IRR_CHOOSE )
|
||||
{
|
||||
// find number of available configs
|
||||
EGLint numConfigs;
|
||||
if ( eglGetConfigs( EglDisplay, NULL, 0, &numConfigs) == EGL_FALSE )
|
||||
{
|
||||
|
@ -304,6 +313,7 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
|
|||
if ( numConfigs <= 0 )
|
||||
return 0;
|
||||
|
||||
// Get all available configs.
|
||||
EGLConfig * configs = new EGLConfig[numConfigs];
|
||||
if ( eglGetConfigs( EglDisplay, configs, numConfigs, &numConfigs) == EGL_FALSE )
|
||||
{
|
||||
|
@ -330,6 +340,7 @@ EGLConfig CEGLManager::chooseConfig(EConfigStyle confStyle)
|
|||
|
||||
if ( ratings[0].rating != 0 )
|
||||
{
|
||||
// This is just to print some log info (it also rates again while doing that, but rating is cheap enough, so that doesn't matter here).
|
||||
rateConfig(ratings[0].config, eglOpenGLBIT, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,49 +40,43 @@ namespace video
|
|||
// Initialize EGL.
|
||||
/* This method initialize EGLand create EGL display, anyway surface and context
|
||||
aren't create. */
|
||||
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
|
||||
virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) _IRR_OVERRIDE_;
|
||||
|
||||
// Terminate EGL.
|
||||
/* Terminate EGL context. This method break both existed surface and context. */
|
||||
void terminate();
|
||||
virtual void terminate() _IRR_OVERRIDE_;
|
||||
|
||||
// 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 generateSurface();
|
||||
virtual bool generateSurface() _IRR_OVERRIDE_;
|
||||
|
||||
// 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();
|
||||
virtual void destroySurface() _IRR_OVERRIDE_;
|
||||
|
||||
// Create EGL context.
|
||||
/* This method create and activate EGL context. */
|
||||
bool generateContext();
|
||||
virtual bool generateContext() _IRR_OVERRIDE_;
|
||||
|
||||
// Destroy EGL context.
|
||||
/* This method destroy EGL context. */
|
||||
void destroyContext();
|
||||
virtual void destroyContext() _IRR_OVERRIDE_;
|
||||
|
||||
const SExposedVideoData& getContext() const;
|
||||
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
|
||||
|
||||
bool activateContext(const SExposedVideoData& videoData);
|
||||
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
|
||||
|
||||
// Swap buffers.
|
||||
bool swapBuffers();
|
||||
virtual bool swapBuffers() _IRR_OVERRIDE_;
|
||||
|
||||
protected:
|
||||
enum EConfigStyle
|
||||
{
|
||||
// TODO: We should also have something like ECS_EGL_CHOOSE_CLOSEST
|
||||
// which doesn't take first result of eglChooseConfigs,
|
||||
// but the closest to requested parameters. eglChooseConfigs
|
||||
// can return more than 1 result and first one might have
|
||||
// "better" values than requested (more bits per pixel etc).
|
||||
|
||||
//! Get first result of eglChooseConfigs and if that fails try again by requesting simpler attributes
|
||||
ECS_EGL_CHOOSE_FIRST_LOWER_EXPECTATIONS,
|
||||
|
||||
|
@ -92,7 +86,7 @@ namespace video
|
|||
|
||||
EGLConfig chooseConfig(EConfigStyle confStyle);
|
||||
|
||||
// Check how close this config is to the parameters we requested
|
||||
//! Check how close this config is to the parameters we requested
|
||||
//! returns 0 is perfect, larger values are worse and < 0 is unusable.
|
||||
irr::s32 rateConfig(EGLConfig config, EGLint eglOpenGLBIT, bool log=false);
|
||||
|
||||
|
|
|
@ -34,31 +34,31 @@ namespace video
|
|||
~CGLXManager();
|
||||
|
||||
// Initialize
|
||||
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
|
||||
virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) _IRR_OVERRIDE_;
|
||||
|
||||
// Terminate
|
||||
void terminate();
|
||||
virtual void terminate() _IRR_OVERRIDE_;
|
||||
|
||||
// Create surface.
|
||||
bool generateSurface();
|
||||
virtual bool generateSurface() _IRR_OVERRIDE_;
|
||||
|
||||
// Destroy surface.
|
||||
void destroySurface();
|
||||
virtual void destroySurface() _IRR_OVERRIDE_;
|
||||
|
||||
// Create context.
|
||||
bool generateContext();
|
||||
virtual bool generateContext() _IRR_OVERRIDE_;
|
||||
|
||||
// Destroy context.
|
||||
void destroyContext();
|
||||
virtual void destroyContext() _IRR_OVERRIDE_;
|
||||
|
||||
//! Get current context
|
||||
const SExposedVideoData& getContext() const;
|
||||
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Change render context, disable old and activate new defined by videoData
|
||||
bool activateContext(const SExposedVideoData& videoData);
|
||||
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
|
||||
|
||||
// Swap buffers.
|
||||
bool swapBuffers();
|
||||
virtual bool swapBuffers() _IRR_OVERRIDE_;
|
||||
|
||||
XVisualInfo* getVisual() const {return VisualInfo;} // return XVisualInfo
|
||||
|
||||
|
|
|
@ -32,31 +32,31 @@ namespace video
|
|||
~CWGLManager();
|
||||
|
||||
// Initialize
|
||||
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
|
||||
virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) _IRR_OVERRIDE_;
|
||||
|
||||
// Terminate
|
||||
void terminate();
|
||||
virtual void terminate() _IRR_OVERRIDE_;
|
||||
|
||||
// Create surface.
|
||||
bool generateSurface();
|
||||
virtual bool generateSurface() _IRR_OVERRIDE_;
|
||||
|
||||
// Destroy surface.
|
||||
void destroySurface();
|
||||
virtual void destroySurface() _IRR_OVERRIDE_;
|
||||
|
||||
// Create context.
|
||||
bool generateContext();
|
||||
virtual bool generateContext() _IRR_OVERRIDE_;
|
||||
|
||||
// Destroy EGL context.
|
||||
void destroyContext();
|
||||
virtual void destroyContext() _IRR_OVERRIDE_;
|
||||
|
||||
//! Get current context
|
||||
const SExposedVideoData& getContext() const;
|
||||
virtual const SExposedVideoData& getContext() const _IRR_OVERRIDE_;
|
||||
|
||||
//! Change render context, disable old and activate new defined by videoData
|
||||
bool activateContext(const SExposedVideoData& videoData);
|
||||
virtual bool activateContext(const SExposedVideoData& videoData) _IRR_OVERRIDE_;
|
||||
|
||||
// Swap buffers.
|
||||
bool swapBuffers();
|
||||
virtual bool swapBuffers() _IRR_OVERRIDE_;
|
||||
|
||||
private:
|
||||
SIrrlichtCreationParameters Params;
|
||||
|
|
Loading…
Reference in New Issue