Skip to content

Commit

Permalink
Resize & fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Nax committed Apr 22, 2015
1 parent f62b38a commit 5c45b09
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
6 changes: 6 additions & 0 deletions include/Lums/Core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ namespace lm
{
return _height;
}

Window&
window()
{
return _win;
}

/**
* Start the core.
Expand Down
2 changes: 1 addition & 1 deletion include/Lums/Lums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define LUMS_STR(str) LUMS_STR2(str)
#define LUMS_VERSION_MAJOR 2
#define LUMS_VERSION_MINOR 8
#define LUMS_VERSION_TEENY 2
#define LUMS_VERSION_TEENY 4
#define LUMS_VERSION_PATCH 0

#define LUMS_VERSION_NUMBER LUMS_STR(LUMS_VERSION_MAJOR) "." \
Expand Down
5 changes: 5 additions & 0 deletions include/Lums/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ namespace lm
extractEvent(event, true);
}

void resize(int w, int h, bool fullscreen = false);

bool visible() const;

/**
* Pump event from the underlying implementation to the event stack.
*/
Expand Down Expand Up @@ -109,6 +113,7 @@ namespace lm
void* _windowHandle;
void* _openGlHandle;
std::queue<Event> _events;
bool _fullscreen;
};
}

Expand Down
6 changes: 4 additions & 2 deletions src/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ Core::start()
doEvent();
doUpdate();
}
doRender();
//std::this_thread::sleep_for(microseconds(400)); // CPU is happy
if (_win.visible())
doRender();
else
std::this_thread::sleep_for(microseconds(400));
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/MacOSX/Window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,36 @@
[win setupHid];
}

void
Window::resize(int w, int h, bool fullscreen)
{
LMWindow* win = (LMWindow*)_windowHandle;
NSOpenGLContext* context = (NSOpenGLContext*)_openGlHandle;

[win setFrame:NSMakeRect(0, 0, w, h) display:YES animate:NO];
if (fullscreen != _fullscreen)
{
_fullscreen = fullscreen;
[win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[win toggleFullScreen:win];
[win setCollectionBehavior:0];
if (fullscreen)
[win setStyleMask:NSBorderlessWindowMask];
else
[win setStyleMask:0];
}
[context update];
glViewport(0, 0, w, h);
}

bool
Window::visible() const
{
LMWindow* win = (LMWindow*)_windowHandle;

return true; // TODO
}

void
Window::pumpEvent()
{
Expand Down

0 comments on commit 5c45b09

Please sign in to comment.