Skip to content

Commit

Permalink
bugfix ofAppGLFWWindow requested monitor wasn't being clamped (#6718)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofTheo committed Mar 24, 2021
1 parent 23f9bfd commit ee30e43
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/openFrameworks/app/ofAppGLFWWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ void ofAppGLFWWindow::setup(const ofGLFWWindowSettings & _settings){
if(settings.windowMode==OF_GAME_MODE){
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
if( settings.monitor >= count ){
ofLogError("ofAppGLFWWindow") << "requested game mode monitor is: " << settings.monitor << " monitor count is: " << count;
}
settings.monitor = ofClamp(settings.monitor,0,count-1);
if(settings.isSizeSet()){
currentW = settings.getWidth();
currentH = settings.getHeight();
Expand All @@ -238,13 +242,17 @@ void ofAppGLFWWindow::setup(const ofGLFWWindowSettings & _settings){
if(settings.windowMode==OF_FULLSCREEN){
int count = 0;
auto monitors = glfwGetMonitors(&count);
if( settings.monitor >= count ){
ofLogError("ofAppGLFWWindow") << "requested fullscreen monitor is: " << settings.monitor << " monitor count is: " << count;
}
settings.monitor = ofClamp(settings.monitor,0,count-1);

auto mode = glfwGetVideoMode(monitors[settings.monitor]);
currentW = mode->width;
currentH = mode->height;
if(!settings.isPositionSet()){
if(count > 0){
int x = 0, y = 0;
settings.monitor = ofClamp(settings.monitor,0,count-1);
glfwGetMonitorPos(monitors[settings.monitor],&x,&y);
settings.setPosition(glm::vec2(x,y));
setWindowPosition(settings.getPosition().x,settings.getPosition().y);
Expand Down

0 comments on commit ee30e43

Please sign in to comment.