Last active
August 29, 2015 14:22
-
-
Save motoishmz/239337c457f5cf609b35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
class ofApp : public ofBaseApp | |
{ | |
public: | |
void setup() | |
{ | |
// GLFW Monitor handling | |
// http://www.glfw.org/docs/latest/group__monitor.html | |
int num_monitors; | |
GLFWmonitor** monitors = glfwGetMonitors(&num_monitors); | |
for (int i=0; i<num_monitors; i++) | |
{ | |
GLFWmonitor *monitor = monitors[i]; | |
int x, y; | |
glfwGetMonitorPos(monitor, &x, &y); | |
int width, height; | |
glfwGetMonitorPhysicalSize(monitor, &width, &height); | |
const char* name = glfwGetMonitorName(monitors[i]); | |
stringstream report; | |
report << "model name:" << name << endl; // uniqueな名前じゃないので注意 | |
report << "pos:" << x << ", " << y << endl; | |
report << "physical size:" << width << "mm / " << height << "mm" << endl; | |
report << "---" << endl; | |
cout << report.str() << endl; | |
} | |
/* | |
// 出力例 | |
name:Color LCD (これがMBP, primary display) | |
pos:0, 0 | |
physical size:331mm / 206mm | |
--- | |
name:S2411W (イクミさんのお下がりDisplay) | |
pos:0, 1800 | |
physical size:518mm / 324mm | |
--- | |
*/ | |
} | |
/* | |
MacOSだったら AppKit.framework 越しに取れる NSScreenNumber が使えそう... | |
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSScreen_Class/ | |
``` | |
for (int i=0; i<[[NSScreen screens] count]; i++) | |
{ | |
NSLog(@"%@", [[[NSScreen screens] objectAtIndex:i] deviceDescription]); | |
} | |
``` | |
// 出力例 | |
2015-06-10 18:25:41.220 templateDebug[23390:957023] { | |
NSDeviceBitsPerSample = 8; | |
NSDeviceColorSpaceName = NSCalibratedRGBColorSpace; | |
NSDeviceIsScreen = YES; | |
NSDeviceResolution = "NSSize: {72, 72}"; | |
NSDeviceSize = "NSSize: {2880, 1800}"; | |
NSScreenNumber = 69731900; <-- これがMBP | |
} | |
2015-06-10 18:25:41.220 templateDebug[23390:957023] { | |
NSDeviceBitsPerSample = 8; | |
NSDeviceColorSpaceName = NSCalibratedRGBColorSpace; | |
NSDeviceIsScreen = YES; | |
NSDeviceResolution = "NSSize: {72, 72}"; | |
NSDeviceSize = "NSSize: {1920, 1200}"; | |
NSScreenNumber = 1892029440; <-- いくみさん | |
} | |
*/ | |
}; | |
#pragma mark - | |
#pragma mark main | |
int main(){ | |
ofSetupOpenGL(1600, 900, OF_WINDOW); | |
ofRunApp(new ofApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment