//--------------------------------------------------------------
ofxDetectDisplays::~ofxDetectDisplays()
{
    clearDisplays();

#if defined(TARGET_OSX)
    CGDisplayRemoveReconfigurationCallback(OnDisplayReconfigurationCallBack, NULL);
#endif
}
Example #2
0
void showOptions(void)
{
	clearDisplays();

	setSingleClickHandler(PLAYER1_LEFT, previous, 0);
	setSingleClickHandler(PLAYER1_RIGHT, next, 0);
	setRepeatClickHandler(PLAYER2_LEFT, 100, changeValue, 1);
	setRepeatClickHandler(PLAYER2_RIGHT, 100, changeValue, 0);
	setSingleClickHandler(MENU, menu, 0);

	selectedOption = 0;

	newMatrixScroll("SECRET");

	print();
}
//--------------------------------------------------------------
int ofxDetectDisplays::detectDisplays()
{
    clearDisplays();
    
#if defined(TARGET_OSX)
    CGDisplayCount displayCount;
    CGDirectDisplayID mainDisplayID = CGMainDisplayID();
    CGDirectDisplayID displaysID[32];
    CGGetActiveDisplayList(32, displaysID, &displayCount);

    for (int i=0; i<displayCount; i++) {
        CGRect displayRect = CGDisplayBounds(displaysID[i]);
        
        DisplayInfo* displayInfo = new DisplayInfo();
        displayInfo->UID = ofToString(displaysID[i]);
        displayInfo->isPrimary = false;
        if (displaysID[i] == mainDisplayID) {
            displayInfo->isPrimary = true;
        }
        
        displayInfo->left = displayRect.origin.x;
        displayInfo->top = displayRect.origin.y;
        displayInfo->width = displayRect.size.width;
        displayInfo->height = displayRect.size.height;
    
        displays.push_back(displayInfo);
    }
    
    return displayCount;
    
#elif defined(TARGET_WIN32)
	DisplaysParam displaysParam;
	displaysParam.count = 0;
	displaysParam.displays = &displays;

    if (EnumDisplayMonitors(NULL, NULL, monitorEnumProc, (LPARAM)&displaysParam)) {

		int index=0;
		DISPLAY_DEVICE dd;
		dd.cb = sizeof(DISPLAY_DEVICE);

		while (EnumDisplayDevices(NULL, index++, &dd, 0))
		{
			if (index-1 >= displaysParam.count) {
				ofLogWarning() << "There is more 'devices' than 'monitors'.";
			} else {
				DISPLAY_DEVICE ddMon;
				ddMon.cb = sizeof(DISPLAY_DEVICE);
				int devMon=0;

				while (EnumDisplayDevices(dd.DeviceName, devMon++, &ddMon, 0))
				{
					vector<string> result = ofSplitString(utf8_encode(ddMon.DeviceID), "\\");
					displays[index-1]->UID = result[1] + "-" + result[3];
				}
			}
		}

		return displaysParam.count;
	}
    return -1;

#endif
}