@ -957,6 +957,9 @@ namespace olc
virtual olc : : rcode CreateGraphics ( bool bFullScreen , bool bEnableVSYNC , const olc : : vi2d & vViewPos , const olc : : vi2d & vViewSize ) = 0 ;
virtual olc : : rcode CreateWindowPane ( const olc : : vi2d & vWindowPos , olc : : vi2d & vWindowSize , bool bFullScreen ) = 0 ;
virtual olc : : rcode SetWindowTitle ( const std : : string & s ) = 0 ;
virtual olc : : rcode SetFullscreen ( const bool bFullscreen , const vi2d windowPos = { } ) = 0 ;
virtual void SetWindowPos ( vi2d pos ) = 0 ;
virtual void SetWindowSize ( vi2d size ) = 0 ;
virtual olc : : rcode StartSystemEventLoop ( ) = 0 ;
virtual olc : : rcode HandleSystemEvent ( ) = 0 ;
virtual olc : : rcode SendRequest ( std : : string_view url , std : : string_view data ) { return olc : : rcode : : OK ; } ;
@ -1068,11 +1071,13 @@ namespace olc
// Gets "screen" size
const olc : : vi2d & GetScreenSize ( ) const ;
const bool IsFullscreen ( ) const ;
void SetFullScreen ( bool bFullscreen ) ;
// Gets any files dropped this frame
const std : : vector < std : : string > & GetDroppedFiles ( ) const ;
const olc : : vi2d & GetDroppedFilesPoint ( ) const ;
void SetWindowPos ( vi2d pos ) ;
void SetWindowSize ( vi2d size ) ;
public : // CONFIGURATION ROUTINES
// Layer targeting functions
void SetDrawTarget ( uint8_t layer , bool bDirty = true ) ;
@ -1098,7 +1103,7 @@ namespace olc
// Change the blend factor from between 0.0f to 1.0f;
void SetPixelBlend ( float fBlend ) ;
void SetFullscreen ( const bool bFullscreen , const vi2d windowPos = { } ) ;
public : // DRAWING ROUTINES
// Draws a single Pixel
@ -2274,10 +2279,6 @@ namespace olc
return bFullScreen ;
}
void PixelGameEngine : : SetFullScreen ( bool bFullscreen ) {
//TODO: Implement fullscreen capabilities.
}
const olc : : vi2d & PixelGameEngine : : GetWindowMouse ( ) const
{ return vMouseWindowPos ; }
@ -4229,6 +4230,11 @@ namespace olc
if ( fBlendFactor > 1.0f ) fBlendFactor = 1.0f ;
}
void PixelGameEngine : : SetFullscreen ( const bool bFullscreen , const vi2d windowPos ) {
this - > bFullScreen = bFullscreen ;
platform - > SetFullscreen ( bFullscreen , windowPos ) ;
}
std : : stringstream & PixelGameEngine : : ConsoleOut ( )
{ return ssConsoleOutput ; }
@ -4330,7 +4336,13 @@ namespace olc
const olc : : vi2d & PixelGameEngine : : GetDroppedFilesPoint ( ) const
{ return vDroppedFilesPoint ; }
void PixelGameEngine : : SetWindowPos ( vi2d pos ) {
platform - > SetWindowPos ( pos ) ;
}
void PixelGameEngine : : SetWindowSize ( vi2d size ) {
platform - > SetWindowSize ( size ) ;
}
void PixelGameEngine : : TextEntryEnable ( const bool bEnable , const std : : string & sText )
{
@ -6369,6 +6381,58 @@ namespace olc
return olc : : OK ;
}
virtual olc : : rcode SetFullscreen ( const bool bFullscreen , const vi2d windowPos ) override {
// Define window furniture
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE ;
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME ;
if ( bFullscreen )
{
dwExStyle = 0 ;
dwStyle = WS_VISIBLE | WS_POPUP ;
HMONITOR hmon = MonitorFromWindow ( olc_hWnd , MONITOR_DEFAULTTONEAREST ) ;
MONITORINFO mi = { sizeof ( mi ) } ;
if ( ! GetMonitorInfo ( hmon , & mi ) ) return olc : : rcode : : FAIL ;
//AdjustWindowRectEx(&rWndRect, dwStyle, FALSE, dwExStyle);
SetWindowLongPtrA ( olc_hWnd , GWL_EXSTYLE , dwExStyle ) ;
SetWindowLongPtrA ( olc_hWnd , GWL_STYLE , dwStyle ) ;
MoveWindow ( olc_hWnd , 0 , 0 , mi . rcMonitor . right , mi . rcMonitor . bottom , true ) ;
} else {
RECT rWndRect = { 0 , 0 , ptrPGE - > GetScreenSize ( ) . x * ptrPGE - > GetPixelSize ( ) . x , ptrPGE - > GetScreenSize ( ) . y * ptrPGE - > GetPixelSize ( ) . y } ;
SetWindowLongPtrA ( olc_hWnd , GWL_EXSTYLE , dwExStyle ) ;
SetWindowLongPtrA ( olc_hWnd , GWL_STYLE , dwStyle ) ;
AdjustWindowRectEx ( & rWndRect , dwStyle , FALSE , dwExStyle ) ;
int width = rWndRect . right - rWndRect . left ;
int height = rWndRect . bottom - rWndRect . top ;
MoveWindow ( olc_hWnd , windowPos . x , windowPos . y , width , height , true ) ;
}
return olc : : OK ;
}
virtual void SetWindowPos ( vi2d pos ) override {
if ( ! ptrPGE - > IsFullscreen ( ) ) {
RECT rWndRect = { 0 , 0 , ptrPGE - > GetWindowSize ( ) . x , ptrPGE - > GetWindowSize ( ) . y } ;
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE ;
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME ;
AdjustWindowRectEx ( & rWndRect , dwStyle , FALSE , dwExStyle ) ;
int width = rWndRect . right - rWndRect . left ;
int height = rWndRect . bottom - rWndRect . top ;
MoveWindow ( olc_hWnd , pos . x , pos . y , width , height , true ) ;
}
}
virtual void SetWindowSize ( vi2d size ) override {
if ( ! ptrPGE - > IsFullscreen ( ) ) {
RECT rWndRect = { 0 , 0 , size . x , size . y } ;
DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE ;
DWORD dwStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_THICKFRAME ;
WINDOWPLACEMENT placement ;
GetWindowPlacement ( olc_hWnd , & placement ) ;
int width = rWndRect . right - rWndRect . left ;
int height = rWndRect . bottom - rWndRect . top ;
MoveWindow ( olc_hWnd , placement . rcNormalPosition . left , placement . rcNormalPosition . top , width * ptrPGE - > GetPixelSize ( ) . x , height * ptrPGE - > GetPixelSize ( ) . y , true ) ;
}
}
virtual olc : : rcode StartSystemEventLoop ( ) override
{
MSG msg ;
@ -6639,6 +6703,35 @@ namespace olc
return olc : : OK ;
}
virtual olc : : rcode SetFullscreen ( const bool bFullscreen , const vi2d windowPos ) override {
using namespace X11 ;
Atom wm_state ;
Atom fullscreen ;
wm_state = XInternAtom ( olc_Display , " _NET_WM_STATE " , False ) ;
fullscreen = XInternAtom ( olc_Display , " _NET_WM_STATE_FULLSCREEN " , False ) ;
XEvent xev { 0 } ;
xev . type = ClientMessage ;
xev . xclient . window = olc_Window ;
xev . xclient . message_type = wm_state ;
xev . xclient . format = 32 ;
xev . xclient . data . l [ 0 ] = bFullscreen ? 1 : 0 ; // the action (0: off, 1: on, 2: toggle)
xev . xclient . data . l [ 1 ] = fullscreen ; // first property to alter
xev . xclient . data . l [ 2 ] = 0 ; // second property to alter
xev . xclient . data . l [ 3 ] = 0 ; // source indication
XMapWindow ( olc_Display , olc_Window ) ;
XSendEvent ( olc_Display , DefaultRootWindow ( olc_Display ) , False ,
SubstructureRedirectMask | SubstructureNotifyMask , & xev ) ;
XFlush ( olc_Display ) ;
XWindowAttributes gwa ;
XGetWindowAttributes ( olc_Display , olc_Window , & gwa ) ;
if ( ! bFullscreen ) {
XMoveWindow ( olc_Display , olc_Window , windowPos . x , windowPos . y ) ;
}
return olc : : OK ;
}
virtual olc : : rcode StartSystemEventLoop ( ) override
{
return olc : : OK ;