Commit 728505f0 authored by kenan's avatar kenan

居中

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