Changed: #947 fixed multi screen window positioning, implemented getCurrentScreenMode, (IDriver::InterfaceVersion = 0x67 to enable negative window positions)

This commit is contained in:
rti 2010-06-13 20:24:58 +02:00
parent 45582ac1c8
commit 2e6078898e
14 changed files with 78 additions and 43 deletions

View file

@ -187,7 +187,7 @@ public:
virtual void setWindowTitle(const ucstring &title)=0; virtual void setWindowTitle(const ucstring &title)=0;
/// Set the position of the NeL window /// Set the position of the NeL window
virtual void setWindowPos(uint32 x, uint32 y)=0; virtual void setWindowPos(sint32 x, sint32 y)=0;
/// Show or hide the NeL window /// Show or hide the NeL window
virtual void showWindow(bool show)=0; virtual void showWindow(bool show)=0;
@ -748,7 +748,7 @@ public:
virtual void getWindowSize (uint32 &width, uint32 &height) = 0; virtual void getWindowSize (uint32 &width, uint32 &height) = 0;
/// Get the position of the window always (0,0) in fullscreen /// Get the position of the window always (0,0) in fullscreen
virtual void getWindowPos (uint32 &x, uint32 &y) = 0; virtual void getWindowPos (sint32 &x, sint32 &y) = 0;
/** get the RGBA back buffer. After swapBuffers(), the content of the back buffer is undefined. /** get the RGBA back buffer. After swapBuffers(), the content of the back buffer is undefined.
* *

View file

@ -149,7 +149,7 @@ public:
virtual void setWindowTitle(const ucstring &title); virtual void setWindowTitle(const ucstring &title);
/// Set the position of the NeL window /// Set the position of the NeL window
virtual void setWindowPos(uint32 x, uint32 y); virtual void setWindowPos(sint32 x, sint32 y);
/// Show or hide the NeL window /// Show or hide the NeL window
virtual void showWindow(bool show); virtual void showWindow(bool show);
@ -396,7 +396,7 @@ public:
virtual void getWindowSize (uint32 &width, uint32 &height); virtual void getWindowSize (uint32 &width, uint32 &height);
virtual uint getWindowWidth (); virtual uint getWindowWidth ();
virtual uint getWindowHeight (); virtual uint getWindowHeight ();
virtual void getWindowPos (uint32 &x, uint32 &y); virtual void getWindowPos (sint32 &x, sint32 &y);
virtual uint32 getAvailableVertexAGPMemory (); virtual uint32 getAvailableVertexAGPMemory ();
virtual uint32 getAvailableVertexVRAMMemory (); virtual uint32 getAvailableVertexVRAMMemory ();
virtual void getBuffer (CBitmap &bitmap); virtual void getBuffer (CBitmap &bitmap);

View file

@ -187,7 +187,7 @@ public:
virtual void setWindowTitle(const ucstring &title)=0; virtual void setWindowTitle(const ucstring &title)=0;
/// Set the position of the NeL window /// Set the position of the NeL window
virtual void setWindowPos(uint32 x, uint32 y)=0; virtual void setWindowPos(sint32 x, sint32 y)=0;
/// Show or hide the NeL window /// Show or hide the NeL window
virtual void showWindow(bool show = true)=0; virtual void showWindow(bool show = true)=0;
@ -499,7 +499,7 @@ public:
virtual uint getWindowHeight () =0; virtual uint getWindowHeight () =0;
/// Get the x and y coord of the windows always (0,0) in fullscreen /// Get the x and y coord of the windows always (0,0) in fullscreen
virtual void getWindowPos (uint32 &x, uint32 &y) = 0; virtual void getWindowPos (sint32 &x, sint32 &y) = 0;
/** Return the amount of AGP memory allocated by initVertexArrayRange() to store vertices. /** Return the amount of AGP memory allocated by initVertexArrayRange() to store vertices.
*/ */

View file

@ -34,7 +34,7 @@ namespace NL3D
{ {
// *************************************************************************** // ***************************************************************************
const uint32 IDriver::InterfaceVersion = 0x66; // added IEventEmitter::emulateMouseRawMode(bool) const uint32 IDriver::InterfaceVersion = 0x67; // changed window pos from uint32 to sint32
// *************************************************************************** // ***************************************************************************
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )

View file

@ -1817,7 +1817,7 @@ void CDriverD3D::getWindowSize (uint32 &width, uint32 &height)
// *************************************************************************** // ***************************************************************************
void CDriverD3D::getWindowPos (uint32 &x, uint32 &y) void CDriverD3D::getWindowPos (sint32 &x, sint32 &y)
{ {
H_AUTO_D3D(CDriverD3D_getWindowPos); H_AUTO_D3D(CDriverD3D_getWindowPos);
x = _WindowX; x = _WindowX;
@ -2187,10 +2187,10 @@ void CDriverD3D::setWindowTitle(const ucstring &title)
} }
// *************************************************************************** // ***************************************************************************
void CDriverD3D::setWindowPos(uint32 x, uint32 y) void CDriverD3D::setWindowPos(sint32 x, sint32 y)
{ {
_WindowX = (sint32)x; _WindowX = x;
_WindowY = (sint32)y; _WindowY = y;
SetWindowPos(_HWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); SetWindowPos(_HWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
} }

View file

@ -753,14 +753,14 @@ public:
virtual emptyProc getWindowProc(); virtual emptyProc getWindowProc();
virtual NLMISC::IEventEmitter *getEventEmitter(); virtual NLMISC::IEventEmitter *getEventEmitter();
virtual void getWindowSize (uint32 &width, uint32 &height); virtual void getWindowSize (uint32 &width, uint32 &height);
virtual void getWindowPos (uint32 &x, uint32 &y); virtual void getWindowPos (sint32 &x, sint32 &y);
virtual uint8 getBitPerPixel (); virtual uint8 getBitPerPixel ();
/// Set the title of the NeL window /// Set the title of the NeL window
virtual void setWindowTitle(const ucstring &title); virtual void setWindowTitle(const ucstring &title);
/// Set the position of the NeL window /// Set the position of the NeL window
virtual void setWindowPos(uint32 x, uint32 y); virtual void setWindowPos(sint32 x, sint32 y);
/// Show or hide the NeL window /// Show or hide the NeL window
virtual void showWindow(bool show); virtual void showWindow(bool show);

View file

@ -298,7 +298,7 @@ public:
virtual void setWindowTitle(const ucstring &title); virtual void setWindowTitle(const ucstring &title);
/// Set the position of the NeL window /// Set the position of the NeL window
virtual void setWindowPos(uint32 x, uint32 y); virtual void setWindowPos(sint32 x, sint32 y);
/// Show or hide the NeL window /// Show or hide the NeL window
virtual void showWindow(bool show); virtual void showWindow(bool show);
@ -502,7 +502,7 @@ public:
virtual void getWindowSize (uint32 &width, uint32 &height); virtual void getWindowSize (uint32 &width, uint32 &height);
virtual void getWindowPos (uint32 &x, uint32 &y); virtual void getWindowPos (sint32 &x, sint32 &y);
virtual void getBuffer (CBitmap &bitmap); virtual void getBuffer (CBitmap &bitmap);

View file

@ -862,7 +862,7 @@ bool CDriverGL::setScreenMode(const GfxMode &mode)
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
// TODO return NL3D::MAC::setMode(mode);
#elif defined(NL_OS_UNIX) #elif defined(NL_OS_UNIX)
@ -1237,9 +1237,8 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
mode.AntiAlias = _AntiAliasing; mode.AntiAlias = _AntiAliasing;
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
# warning "OpenGL Driver: Temporary Mac Implementation"
nlwarning("OpenGL Driver: Temporary Mac Implementation"); NL3D::MAC::getCurrentScreenMode(mode);
mode.Depth = 24;
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
/* /*
@ -1309,10 +1308,10 @@ void CDriverGL::setWindowTitle(const ucstring &title)
} }
// *************************************************************************** // ***************************************************************************
void CDriverGL::setWindowPos(uint32 x, uint32 y) void CDriverGL::setWindowPos(sint32 x, sint32 y)
{ {
_WindowX = (sint32)x; _WindowX = x;
_WindowY = (sint32)y; _WindowY = y;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -1557,7 +1556,7 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
} }
void CDriverGL::getWindowPos(uint32 &x, uint32 &y) void CDriverGL::getWindowPos(sint32 &x, sint32 &y)
{ {
H_AUTO_OGL(CDriverGL_getWindowPos) H_AUTO_OGL(CDriverGL_getWindowPos)
@ -1575,8 +1574,8 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y)
{ {
if (_win) if (_win)
{ {
x = (uint32)_WindowX; x = _WindowX;
y = (uint32)_WindowY; y = _WindowY;
} }
} }

View file

@ -58,14 +58,17 @@ bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable);
/// mac specific stuff while calling CDriverGL::setMode() /// mac specific stuff while calling CDriverGL::setMode()
bool setMode(const GfxMode& mode); bool setMode(const GfxMode& mode);
/// mac specific stuff while calling CDriverGL::getCurrentScreenMode()
void getCurrentScreenMode(GfxMode& mode);
/// mac specific stuff while calling CDriverGL::getWindowSize() /// mac specific stuff while calling CDriverGL::getWindowSize()
void getWindowSize(uint32 &width, uint32 &height); void getWindowSize(uint32 &width, uint32 &height);
/// mac specific stuff while calling CDriverGL::getWindowPos() /// mac specific stuff while calling CDriverGL::getWindowPos()
void getWindowPos(uint32 &x, uint32 &y); void getWindowPos(sint32 &x, sint32 &y);
/// mac specific stuff while calling CDriverGL::setWindowPos() /// mac specific stuff while calling CDriverGL::setWindowPos()
void setWindowPos(uint32 x, uint32 y); void setWindowPos(sint32 x, sint32 y);
/// mac specific stuff while calling CDriverGL::setWindowTitle() /// mac specific stuff while calling CDriverGL::setWindowTitle()
void setWindowTitle(const ucstring &title); void setWindowTitle(const ucstring &title);

View file

@ -237,11 +237,36 @@ bool setMode(const GfxMode& mode)
return true; return true;
} }
void getCurrentScreenMode(GfxMode& mode)
{
// the sceen with the menu bar
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
mode.OffScreen = false;
mode.Frequency = 0;
mode.Depth = NSBitsPerPixelFromDepth([screen depth]);
// in fullscreen mode
if([g_glview isInFullScreenMode])
{
// return the size of the back buffer (like having switched monitor mode)
mode.Windowed = false;
mode.Width = (uint16)g_bufferSize[0];
mode.Height = (uint16)g_bufferSize[1];
}
// in windowes mode
else
{
// return the size of the screen with menu bar
mode.Windowed = true;
mode.Width = (uint16)[screen frame].size.width;
mode.Height = (uint16)[screen frame].size.height;
}
}
void getWindowSize(uint32 &width, uint32 &height) void getWindowSize(uint32 &width, uint32 &height)
{ {
if(!g_glctx)
return;
// A cocoa fullscreen view stays at the native resolution of the display. // A cocoa fullscreen view stays at the native resolution of the display.
// When changing the rendering resolution, the size of the back buffer gets // When changing the rendering resolution, the size of the back buffer gets
// changed, but the view still stays at full resolution. So the scaling of // changed, but the view still stays at full resolution. So the scaling of
@ -313,10 +338,17 @@ void getWindowSize(uint32 &width, uint32 &height)
#endif #endif
} }
void getWindowPos(uint32 &x, uint32 &y) void getWindowPos(sint32 &x, sint32 &y)
{ {
// get the rect (position, size) of the screen // for IDriver conformity
NSRect screenRect = [[g_window screen] frame]; if([g_glview isInFullScreenMode])
{
x = y = 0;
return;
}
// get the rect (position, size) of the screen with menu bar
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
// get the rect (position, size) of the window // get the rect (position, size) of the window
NSRect windowRect = [g_window frame]; NSRect windowRect = [g_window frame];
@ -328,12 +360,12 @@ void getWindowPos(uint32 &x, uint32 &y)
y = screenRect.size.height - windowRect.size.height - windowRect.origin.y; y = screenRect.size.height - windowRect.size.height - windowRect.origin.y;
} }
void setWindowPos(uint32 x, uint32 y) void setWindowPos(sint32 x, sint32 y)
{ {
// get the size of the screen // get the rect (position, size) of the screen with menu bar
NSRect screenRect = [[g_window screen] frame]; NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
// get the size of the window // get the rect (position, size) of the window
NSRect windowRect = [g_window frame]; NSRect windowRect = [g_window frame];
// convert y from NeL coordinates to cocoa coordinates // convert y from NeL coordinates to cocoa coordinates

View file

@ -328,7 +328,7 @@ void CDriverUser::setWindowTitle(const ucstring &title)
} }
// *************************************************************************** // ***************************************************************************
void CDriverUser::setWindowPos(uint32 x, uint32 y) void CDriverUser::setWindowPos(sint32 x, sint32 y)
{ {
NL3D_HAUTO_UI_DRIVER; NL3D_HAUTO_UI_DRIVER;
_Driver->setWindowPos(x, y); _Driver->setWindowPos(x, y);
@ -1530,7 +1530,7 @@ uint CDriverUser::getWindowHeight ()
_Driver->getWindowSize (width, height); _Driver->getWindowSize (width, height);
return height; return height;
} }
void CDriverUser::getWindowPos (uint32 &x, uint32 &y) void CDriverUser::getWindowPos (sint32 &x, sint32 &y)
{ {
NL3D_HAUTO_UI_DRIVER; NL3D_HAUTO_UI_DRIVER;

View file

@ -2009,7 +2009,8 @@ void CClientConfig::release ()
// Driver still alive ? // Driver still alive ?
if (Driver && Driver->isActive ()) if (Driver && Driver->isActive ())
{ {
uint32 x, y, width, height; sint32 x, y;
uint32 width, height;
Driver->getWindowPos(x, y); Driver->getWindowPos(x, y);
Driver->getWindowSize(width, height); Driver->getWindowSize(width, height);

View file

@ -61,8 +61,8 @@ struct CClientConfig
bool SaveConfig; bool SaveConfig;
/// Window position in windowed mode /// Window position in windowed mode
sint PositionX; sint32 PositionX;
sint PositionY; sint32 PositionY;
/// Window frequency /// Window frequency
uint Frequency; uint Frequency;

View file

@ -908,7 +908,7 @@ void prelogInit()
// Set the title // Set the title
Driver->setWindowTitle(CI18N::get("TheSagaOfRyzom")); Driver->setWindowTitle(CI18N::get("TheSagaOfRyzom"));
uint32 posX = 0, posY = 0; sint32 posX = 0, posY = 0;
if (ClientCfg.Windowed) if (ClientCfg.Windowed)
{ {