Commit 728505f0 authored by kenan's avatar kenan

居中

parent 90f4a6cb
...@@ -35,6 +35,11 @@ bool Game::Initialize() { ...@@ -35,6 +35,11 @@ bool Game::Initialize() {
#endif #endif
srand(time(0)); srand(time(0));
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters(); irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
int screenH = android::getScreenHeight(app);
int screenW = android::getScreenWidth(app);
xScale = screenH / 1024.0;
yScale = screenW / 640.0;
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
android::InitOptions *options = android::getInitOptions(app); android::InitOptions *options = android::getInitOptions(app);
glversion = options->getOpenglVersion(); glversion = options->getOpenglVersion();
...@@ -48,6 +53,8 @@ bool Game::Initialize() { ...@@ -48,6 +53,8 @@ bool Game::Initialize() {
params.ZBufferBits = 16; params.ZBufferBits = 16;
params.AntiAlias = 0; params.AntiAlias = 0;
params.WindowSize = irr::core::dimension2d<u32>(0, 0); params.WindowSize = irr::core::dimension2d<u32>(0, 0);
params.WindowLeft = (screenH - 1024.0*xScale)/2.0;
params.WindowTop = (screenW - 640.0*yScale)/2.0;
#else #else
if(gameConf.use_d3d) if(gameConf.use_d3d)
params.DriverType = irr::video::EDT_DIRECT3D9; params.DriverType = irr::video::EDT_DIRECT3D9;
...@@ -55,6 +62,7 @@ bool Game::Initialize() { ...@@ -55,6 +62,7 @@ bool Game::Initialize() {
params.DriverType = irr::video::EDT_OPENGL; params.DriverType = irr::video::EDT_OPENGL;
params.WindowSize = irr::core::dimension2d<u32>(1280, 720); params.WindowSize = irr::core::dimension2d<u32>(1280, 720);
#endif #endif
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device)
return false; return false;
...@@ -70,8 +78,7 @@ bool Game::Initialize() { ...@@ -70,8 +78,7 @@ bool Game::Initialize() {
// logger->setLogLevel(ELL_WARNING); // logger->setLogLevel(ELL_WARNING);
isPSEnabled = options->isPendulumScaleEnabled(); isPSEnabled = options->isPendulumScaleEnabled();
dataManager.FileSystem = device->getFileSystem(); dataManager.FileSystem = device->getFileSystem();
xScale = android::getScreenHeight(app) / 1024.0;
yScale = android::getScreenWidth(app) / 640.0;
/* if (xScale < yScale) { /* if (xScale < yScale) {
* xScale = android::getScreenWidth(app) / 1024.0; * xScale = android::getScreenWidth(app) / 1024.0;
* yScale = android::getScreenHeight(app) / 640.0; * yScale = android::getScreenHeight(app) / 640.0;
......
...@@ -51,6 +51,8 @@ namespace irr ...@@ -51,6 +51,8 @@ namespace irr
UsePerformanceTimer(true), UsePerformanceTimer(true),
SDK_version_do_not_use(IRRLICHT_SDK_VERSION), SDK_version_do_not_use(IRRLICHT_SDK_VERSION),
PrivateData(0), PrivateData(0),
WindowLeft(0),
WindowTop(0),
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_ #ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
OGLES2ShaderPath("") OGLES2ShaderPath("")
#elif defined(_IRR_ANDROID_PLATFORM_) #elif defined(_IRR_ANDROID_PLATFORM_)
...@@ -117,6 +119,10 @@ namespace irr ...@@ -117,6 +119,10 @@ namespace irr
//! Size of the window or the video mode in fullscreen mode. Default: 800x600 //! Size of the window or the video mode in fullscreen mode. Default: 800x600
core::dimension2d<u32> WindowSize; core::dimension2d<u32> WindowSize;
int WindowLeft;
int WindowTop;
//! Position of the window on-screen. Default: (-1, -1) or centered. //! Position of the window on-screen. Default: (-1, -1) or centered.
core::position2di WindowPosition; core::position2di WindowPosition;
......
...@@ -38,7 +38,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param) ...@@ -38,7 +38,7 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CIrrDeviceAndroid"); setDebugName("CIrrDeviceAndroid");
#endif #endif
startPoint = core::position2di(param.WindowLeft, param.WindowTop);
// Get the interface to the native Android activity. // Get the interface to the native Android activity.
Android = (ANDROID_APP)(param.PrivateData); Android = (ANDROID_APP)(param.PrivateData);
...@@ -189,7 +189,7 @@ void CIrrDeviceAndroid::restoreWindow() ...@@ -189,7 +189,7 @@ void CIrrDeviceAndroid::restoreWindow()
core::position2di CIrrDeviceAndroid::getWindowPosition() core::position2di CIrrDeviceAndroid::getWindowPosition()
{ {
return core::position2di(0, 0); return startPoint;
} }
E_DEVICE_TYPE CIrrDeviceAndroid::getType() const E_DEVICE_TYPE CIrrDeviceAndroid::getType() const
......
...@@ -75,6 +75,8 @@ namespace irr ...@@ -75,6 +75,8 @@ namespace irr
bool Focused; bool Focused;
bool Initialized; bool Initialized;
bool Paused; bool Paused;
core::position2di startPoint;
JNIEnv* JNIEnvAttachedToVM; JNIEnv* JNIEnvAttachedToVM;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment