Is there a way to get screen size of the second monitor? The issue I’m having is this. I start the app on main monitor and drag it to the second monitor with different resolution. How can I get the screen resolution of the monitor where the app currently is.
ofGetScreenWidth() return me the primary monitor resolution, while ofGetWidth returns the window size.
Crappy answer but do you know the resolution of the primary monitor? You can put the app in full screen, get the whole window width and then subtract the primary monitor width. From there you can call setwindowsize and setwindowposition to get the app to fill the second screen only.
Try to check which windowing system your version of OF is using. If I’m not mistaken, 0.8.0 uses GLFW, I haven’t tested any of these but GLFW offers some functionality regarding several monitors.
I think it’s the default, apparently you can’t directly access those functions. But if you add:
#include "ofAppGLFWWindow.h"
To your ofApp.h you should be able to access all those functions. And then get all monitors information.
Try placing ofGetCurrentRenderer wherever in code, and debug into the call, see where it gets you. You should be able to debug some virtual function from ofAppBaseWindow and see what class is implementing them.
GLFW should be the default window for all OF 0.8.0 -> OF 0.9.0
ofGetScreenWidth() / height() should return the screen width of the monitor your window is on.
This is the actual code which queries which monitor is active. So ofGetScreenWidth should be querying the correct screen dimensions.
Thanks a lot guyz! It works, now i can get all the displays info.
The next step is to figure out a way to specify particular display for application start?
I’ve found that particular display is specifying when fullscreen window is creating
Here is a function to detect the second monitor dimension and position in a main.cpp file. The function is used to set a second window in full screen on the second monitor:
bool setSecondWindowDimensions(ofGLFWWindowSettings& settings) {
// Check screens size and location
int count;
GLFWmonitor** monitors = glfwGetMonitors(&count);
cout << "Number of screens found: " << count << endl;
if (count>1) {
int xM; int yM;
glfwGetMonitorPos(monitors[1], &xM, &yM); // We take the second monitor
const GLFWvidmode * desktopMode = glfwGetVideoMode(monitors[1]);
settings.width = desktopMode->width;
settings.height = desktopMode->height;
settings.setPosition(ofVec2f(xM, yM));
return true;
} else {
settings.width = 800; // Default settings if there is only one screen
settings.height = 600;
settings.setPosition(ofVec2f(0, 0));
return false;
}
}
//========================================================================
int main() {
ofGLFWWindowSettings settings;
settings.width = 1200;
settings.height = 600;
settings.setPosition(ofVec2f(0, 0));
settings.resizable = true;
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
setSecondWindowDimensions(settings);
settings.resizable = false;
settings.decorated = false;
settings.shareContextWith = mainWindow;
shared_ptr<ofAppBaseWindow> secondWindow = ofCreateWindow(settings);
secondWindow->setVerticalSync(false);
shared_ptr<ofApp> mainApp(new ofApp);
ofAddListener(secondWindow->events().draw, mainApp.get(), &ofApp::drawProjWindow);
mainApp->projWindow = secondWindow;
ofRunApp(mainWindow, mainApp);
ofRunMainLoop();
}