Add window position to creation parameters

This commit is contained in:
Benau 2020-06-15 16:35:33 +08:00
parent 964a13368c
commit 2b0b941219
3 changed files with 31 additions and 20 deletions

View File

@ -8,9 +8,14 @@
#include "EDriverTypes.h"
#include "EDeviceTypes.h"
#include "dimension2d.h"
#include "position2d.h"
#include "ILogger.h"
#include "irrString.h"
#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
#include "SDL_video.h"
#endif
namespace irr
{
class IEventReceiver;
@ -25,6 +30,9 @@ namespace irr
DeviceType(EIDT_BEST),
DriverType(video::EDT_BURNINGSVIDEO),
WindowSize(core::dimension2d<u32>(800, 600)),
#if !defined(SERVER_ONLY) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
WindowPosition(core::position2di(SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED)),
#endif
Bits(16),
ZBufferBits(16),
Fullscreen(false),
@ -85,6 +93,7 @@ namespace irr
ForceLegacyDevice = other.ForceLegacyDevice;
ShadersPath = other.ShadersPath;
PrivateData = other.PrivateData;
WindowPosition = other.WindowPosition;
return *this;
}
@ -111,6 +120,9 @@ namespace irr
//! Size of the window or the video mode in fullscreen mode. Default: 800x600
core::dimension2d<u32> WindowSize;
//! Window created position
core::position2di WindowPosition;
//! Minimum Bits per pixel of the color buffer in fullscreen mode. Ignored if windowed mode. Default: 16.
u8 Bits;

View File

@ -344,8 +344,8 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
Window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, CreationParams.WindowSize.Width,
Window = SDL_CreateWindow("", CreationParams.WindowPosition.X,
CreationParams.WindowPosition.Y, CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height, flags);
if (Window)
{
@ -367,8 +367,8 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
Window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, CreationParams.WindowSize.Width,
Window = SDL_CreateWindow("", CreationParams.WindowPosition.X,
CreationParams.WindowPosition.Y, CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height, flags);
if (Window)
{
@ -389,8 +389,8 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
Window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, CreationParams.WindowSize.Width,
Window = SDL_CreateWindow("", CreationParams.WindowPosition.X,
CreationParams.WindowPosition.Y, CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height, flags);
if (Window)
{
@ -411,8 +411,8 @@ start:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
Window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, CreationParams.WindowSize.Width,
Window = SDL_CreateWindow("", CreationParams.WindowPosition.X,
CreationParams.WindowPosition.Y, CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height, flags);
if (Window)
{
@ -445,8 +445,8 @@ legacy:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
Window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, CreationParams.WindowSize.Width,
Window = SDL_CreateWindow("", CreationParams.WindowPosition.X,
CreationParams.WindowPosition.Y, CreationParams.WindowSize.Width,
CreationParams.WindowSize.Height, flags);
if (Window)
{

View File

@ -480,6 +480,15 @@ void IrrDriver::initDevice()
params.HandleSRGB = false;
params.ShadersPath = (file_manager->getShadersDir() +
"irrlicht/").c_str();
// Set window to remembered position
if ( !UserConfigParams::m_fullscreen
&& UserConfigParams::m_remember_window_location
&& UserConfigParams::m_window_x >= 0
&& UserConfigParams::m_window_y >= 0 )
{
params.WindowPosition.X = UserConfigParams::m_window_x;
params.WindowPosition.Y = UserConfigParams::m_window_y;
}
/*
switch ((int)UserConfigParams::m_antialiasing)
@ -739,16 +748,6 @@ void IrrDriver::initDevice()
// does not set the 'enable mipmap' flag.
m_scene_manager->getParameters()
->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true);
// Set window to remembered position
if ( !UserConfigParams::m_fullscreen
&& UserConfigParams::m_remember_window_location
&& UserConfigParams::m_window_x >= 0
&& UserConfigParams::m_window_y >= 0 )
{
moveWindow(UserConfigParams::m_window_x,
UserConfigParams::m_window_y);
} // If reinstating window location
} // If showing graphics
// Initialize material2D