Skip to content

Commit 5c45b09

Browse files
author
Nax
committed
Resize & fullscreen
1 parent f62b38a commit 5c45b09

5 files changed

Lines changed: 46 additions & 3 deletions

File tree

include/Lums/Core.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ namespace lm
7777
{
7878
return _height;
7979
}
80+
81+
Window&
82+
window()
83+
{
84+
return _win;
85+
}
8086

8187
/**
8288
* Start the core.

include/Lums/Lums.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define LUMS_STR(str) LUMS_STR2(str)
1919
#define LUMS_VERSION_MAJOR 2
2020
#define LUMS_VERSION_MINOR 8
21-
#define LUMS_VERSION_TEENY 2
21+
#define LUMS_VERSION_TEENY 4
2222
#define LUMS_VERSION_PATCH 0
2323

2424
#define LUMS_VERSION_NUMBER LUMS_STR(LUMS_VERSION_MAJOR) "." \

include/Lums/Window.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ namespace lm
6969
extractEvent(event, true);
7070
}
7171

72+
void resize(int w, int h, bool fullscreen = false);
73+
74+
bool visible() const;
75+
7276
/**
7377
* Pump event from the underlying implementation to the event stack.
7478
*/
@@ -109,6 +113,7 @@ namespace lm
109113
void* _windowHandle;
110114
void* _openGlHandle;
111115
std::queue<Event> _events;
116+
bool _fullscreen;
112117
};
113118
}
114119

src/Core.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ Core::start()
6363
doEvent();
6464
doUpdate();
6565
}
66-
doRender();
67-
//std::this_thread::sleep_for(microseconds(400)); // CPU is happy
66+
if (_win.visible())
67+
doRender();
68+
else
69+
std::this_thread::sleep_for(microseconds(400));
6870
}
6971
}
7072

src/MacOSX/Window.mm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,36 @@
6666
[win setupHid];
6767
}
6868

69+
void
70+
Window::resize(int w, int h, bool fullscreen)
71+
{
72+
LMWindow* win = (LMWindow*)_windowHandle;
73+
NSOpenGLContext* context = (NSOpenGLContext*)_openGlHandle;
74+
75+
[win setFrame:NSMakeRect(0, 0, w, h) display:YES animate:NO];
76+
if (fullscreen != _fullscreen)
77+
{
78+
_fullscreen = fullscreen;
79+
[win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
80+
[win toggleFullScreen:win];
81+
[win setCollectionBehavior:0];
82+
if (fullscreen)
83+
[win setStyleMask:NSBorderlessWindowMask];
84+
else
85+
[win setStyleMask:0];
86+
}
87+
[context update];
88+
glViewport(0, 0, w, h);
89+
}
90+
91+
bool
92+
Window::visible() const
93+
{
94+
LMWindow* win = (LMWindow*)_windowHandle;
95+
96+
return true; // TODO
97+
}
98+
6999
void
70100
Window::pumpEvent()
71101
{

0 commit comments

Comments
 (0)