Some fixes for video mode list on android.

Should be a bit safer when user wants to close the game very early (i.e. when assets are extracting) and we get destroy event before irr_driver is actually initialized.
This commit is contained in:
Deve 2017-06-19 22:41:53 +02:00
parent 1d8a709e38
commit 72358371f7
2 changed files with 18 additions and 17 deletions

View File

@ -89,7 +89,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
ExposedVideoData.OGLESAndroid.Window = Android->window;
getVideoModeList();
createVideoModeList();
createDriver();
@ -103,25 +103,26 @@ CIrrDeviceAndroid::~CIrrDeviceAndroid()
Android->userData = NULL;
}
video::IVideoModeList* CIrrDeviceAndroid::getVideoModeList()
void CIrrDeviceAndroid::createVideoModeList()
{
if (Android == NULL || Android->window == NULL)
return NULL;
core::dimension2d<u32> size = core::dimension2d<u32>(
ANativeWindow_getWidth(Android->window),
ANativeWindow_getHeight(Android->window));
CreationParams.WindowSize.Width = size.Width;
CreationParams.WindowSize.Height = size.Height;
if (!VideoModeList.getVideoModeCount())
if (VideoModeList.getVideoModeCount() > 0)
return;
int width = ANativeWindow_getWidth(Android->window);
int height = ANativeWindow_getHeight(Android->window);
if (width > 0 && height > 0)
{
VideoModeList.addMode(size, 32);
VideoModeList.setDesktop(32, size);
CreationParams.WindowSize.Width = width;
CreationParams.WindowSize.Height = height;
}
return &VideoModeList;
core::dimension2d<u32> size = core::dimension2d<u32>(
CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height);
VideoModeList.addMode(size, 32);
VideoModeList.setDesktop(32, size);
}
void CIrrDeviceAndroid::createDriver()

View File

@ -54,7 +54,6 @@ namespace irr
virtual bool deactivateGyroscope();
virtual bool isGyroscopeActive();
virtual bool isGyroscopeAvailable();
video::IVideoModeList* getVideoModeList();
class CCursorControl : public gui::ICursorControl
{
@ -114,6 +113,7 @@ namespace irr
void createDriver();
void createKeyMap();
void createVideoModeList();
void getKeyChar(SEvent& event);
video::SExposedVideoData& getExposedVideoData();