本文整理汇总了C++中CGMainDisplayID函数的典型用法代码示例。如果您正苦于以下问题:C++ CGMainDisplayID函数的具体用法?C++ CGMainDisplayID怎么用?C++ CGMainDisplayID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CGMainDisplayID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char * argv[])
{
IOReturn err;
CGDirectDisplayID dspy = CGMainDisplayID();
io_service_t framebuffer;
CGRect bounds;
vm_address_t buffer;
vm_size_t size, rowBytes;
framebuffer = CGDisplayIOServicePort(dspy);
assert (framebuffer != MACH_PORT_NULL);
dspy = CGMainDisplayID();
bounds = CGDisplayBounds(dspy);
rowBytes = CGDisplayBytesPerRow(dspy);
err = IOAccelReadFramebuffer(framebuffer, bounds.size.width, bounds.size.height, rowBytes,
&buffer, &size);
if (kIOReturnSuccess == err)
{
fprintf(stderr, "writing 0x%x bytes from 0x%x\n", size, buffer);
write(STDOUT_FILENO, (const void *) buffer, size);
vm_deallocate(mach_task_self(), buffer, size);
}
return (0);
}
示例2: screen
static CGDirectDisplayID screen(void* w) {
HIRect bounds;
OSStatus err = HIWindowGetBounds((WindowRef)w, kWindowGlobalPortRgn,
kHICoordSpace72DPIGlobal, &bounds);
if (err) {
lprintf("HIWindowGetBounds failed: %d\n", err);
return CGMainDisplayID();
}
CGDirectDisplayID display;
CGDisplayCount displayCount;
CGDisplayErr e = CGGetDisplaysWithRect(bounds, 1,
&display, &displayCount);
return (displayCount && !e) ? display : CGMainDisplayID();
}
示例3: GetMonitorProfile
void GetMonitorProfile(wxString& profileName, cmsHPROFILE& profile)
{
ColorsyncIteratorData data;
data.dispuuid = CGDisplayCreateUUIDFromDisplayID(CGMainDisplayID());
if (data.dispuuid == NULL)
{
DEBUG_INFO("CGDisplayCreateUUIDFromDisplayID() failed.");
return;
}
data.url = NULL;
ColorSyncIterateDeviceProfiles(ColorSyncIterateCallback, (void *)&data);
CFRelease(data.dispuuid);
CFStringRef urlstr = CFURLCopyFileSystemPath(data.url, kCFURLPOSIXPathStyle);
CFRelease(data.url);
if (urlstr == NULL)
{
DEBUG_INFO("Failed to get URL in CFString");
}
else
{
CFRetain(urlstr);
profileName = wxCFStringRef(urlstr).AsString(wxLocale::GetSystemEncoding());
profile = cmsOpenProfileFromFile(profileName.c_str(), "r");
DEBUG_INFO("Found profile: " << profileName.c_str());
};
};
示例4: listDisplays
void
listDisplays(void)
{
CGDisplayErr dErr;
CGDisplayCount displayCount, i;
CGDirectDisplayID mainDisplay;
CGDisplayCount maxDisplays = MAX_DISPLAYS;
CGDirectDisplayID onlineDisplays[MAX_DISPLAYS];
mainDisplay = CGMainDisplayID();
dErr = CGGetOnlineDisplayList(maxDisplays, onlineDisplays, &displayCount);
if (dErr != kCGErrorSuccess) {
fprintf(stderr, "CGGetOnlineDisplayList: error %d.\n", dErr);
exit(1);
}
printf("Display ID Resolution\n");
for (i = 0; i < displayCount; i++) {
CGDirectDisplayID dID = onlineDisplays[i];
printf("%-16p %lux%lu %32s", dID,
CGDisplayPixelsWide(dID), CGDisplayPixelsHigh(dID),
(dID == mainDisplay) ? "[main display]\n" : "\n");
}
exit(0);
}
示例5: Open
static int Open(void * hwnd)
{
CGLRendererInfoObj renderer;
long numRenderer;
CGDirectDisplayID l[32];
CGDisplayCount count;
SYS_ASSERT(g_pCGLC == 0);
UNUSED(hwnd);
CGGetActiveDisplayList (sizeof(l), l, &count);
#ifdef _DEBUG
// Debug in multiple monitor. Use the secondary monitor for rendering
g_cgDisplayID = l[count-1];
#else
g_cgDisplayID = CGMainDisplayID ();
#endif
g_cgPrevDisplayMode = CGDisplayCurrentMode (g_cgDisplayID);
g_cgDisplayModeList = CGDisplayAvailableModes (g_cgDisplayID);
CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(g_cgDisplayID), &renderer, &numRenderer);
CGLDestroyRendererInfo(renderer);
return 0;
}
示例6: CGMainDisplayID
nglVideoMode::nglVideoMode()
{
#ifdef __NGL_MACHO__
mDisplay = CGMainDisplayID();
#endif
Init();
#ifdef __NGL_MACHO__
CFDictionaryRef displayMode ;
CFNumberRef number ;
displayMode = (CFDictionaryRef) CGDisplayCurrentMode((CGDirectDisplayID)mDisplay) ;
/* Get the height and width of this display mode. Print them out. */
number = (CFNumberRef)CFDictionaryGetValue( displayMode, kCGDisplayWidth ) ;
CFNumberGetValue( number, kCFNumberLongType, &mWidth ) ;
number = (CFNumberRef)CFDictionaryGetValue( displayMode, kCGDisplayHeight ) ;
CFNumberGetValue( number, kCFNumberLongType, &mHeight ) ;
number = (CFNumberRef)CFDictionaryGetValue( displayMode, kCGDisplayRefreshRate ) ;
CFNumberGetValue( number, kCFNumberLongType, &mRate ) ;
number = (CFNumberRef)CFDictionaryGetValue( displayMode, kCGDisplayBitsPerPixel ) ;
CFNumberGetValue( number, kCFNumberLongType, &mBPP ) ;
#else
mWidth = 800;
mHeight = 600;
mBPP = 32;
mRate = 60;
#endif
}
示例7: macdrv_displays_changed
/***********************************************************************
* macdrv_displays_changed
*
* Handler for DISPLAYS_CHANGED events.
*/
void macdrv_displays_changed(const macdrv_event *event)
{
HWND hwnd = GetDesktopWindow();
/* A system display change will get delivered to all GUI-attached threads,
so the desktop-window-owning thread will get it and all others should
ignore it. A synthesized display change event due to activation
will only get delivered to the activated process. So, it needs to
process it (by sending it to the desktop window). */
if (event->displays_changed.activating ||
GetWindowThreadProcessId(hwnd, NULL) == GetCurrentThreadId())
{
CGDirectDisplayID mainDisplay = CGMainDisplayID();
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(mainDisplay);
size_t width = CGDisplayModeGetWidth(mode);
size_t height = CGDisplayModeGetHeight(mode);
int mode_bpp = display_mode_bits_per_pixel(mode);
struct display_mode_descriptor* desc = create_original_display_mode_descriptor(mainDisplay);
BOOL is_original = display_mode_matches_descriptor(mode, desc);
free_display_mode_descriptor(desc);
CGDisplayModeRelease(mode);
if (is_original && retina_enabled)
{
width *= 2;
height *= 2;
}
SendMessageW(hwnd, WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp,
MAKELPARAM(width, height));
}
}
示例8: VID_GetGamma
int VID_GetGamma(unsigned short *ramps, int rampsize)
{
CGGammaValue table_red [GAMMA_TABLE_SIZE];
CGGammaValue table_green [GAMMA_TABLE_SIZE];
CGGammaValue table_blue [GAMMA_TABLE_SIZE];
CGTableCount actualsize = 0;
int i;
// Get the gamma ramps from the system
if (CGGetDisplayTransferByTable(CGMainDisplayID(), rampsize, table_red, table_green, table_blue, &actualsize) != CGDisplayNoErr)
{
Con_Print("VID_GetGamma: ERROR: CGGetDisplayTransferByTable failed!\n");
return false;
}
if (actualsize != (unsigned int)rampsize)
{
Con_Printf("VID_GetGamma: ERROR: invalid gamma table size (%u != %u)\n", actualsize, rampsize);
return false;
}
// Convert the 3 float tables into 1 unsigned short table
for (i = 0; i < rampsize; i++)
ramps[i] = table_red[i] * 65535.0f;
for (i = 0; i < rampsize; i++)
ramps[i + rampsize] = table_green[i] * 65535.0f;
for (i = 0; i < rampsize; i++)
ramps[i + 2 * rampsize] = table_blue[i] * 65535.0f;
return true;
}
示例9: VID_ListModes
size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)
{
CGDirectDisplayID mainDisplay = CGMainDisplayID();
CFArrayRef vidmodes = CGDisplayAvailableModes(mainDisplay);
CFDictionaryRef thismode;
unsigned int n = CFArrayGetCount(vidmodes);
unsigned int i;
size_t k;
k = 0;
for(i = 0; i < n; ++i)
{
thismode = (CFDictionaryRef) CFArrayGetValueAtIndex(vidmodes, i);
if(!GetDictionaryBoolean(thismode, kCGDisplayModeIsSafeForHardware))
continue;
if(k >= maxcount)
break;
modes[k].width = GetDictionaryLong(thismode, kCGDisplayWidth);
modes[k].height = GetDictionaryLong(thismode, kCGDisplayHeight);
modes[k].bpp = GetDictionaryLong(thismode, kCGDisplayBitsPerPixel);
modes[k].refreshrate = GetDictionaryLong(thismode, kCGDisplayRefreshRate);
modes[k].pixelheight_num = 1;
modes[k].pixelheight_denom = 1; // OS X doesn't expose this either
++k;
}
return k;
}
示例10: screeninit
void
screeninit(void)
{
int fmt;
int dx, dy;
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
fmt = XBGR32; //XRGB32;
devRect = max_bounds();
dx = devRect.size.width;
dy = devRect.size.height;
gscreen = allocmemimage(Rect(0,0,dx,dy), fmt);
dataProviderRef = CGDataProviderCreateWithData(0, gscreen->data->bdata,
dx * dy * 4, 0);
fullScreenImage = CGImageCreate(dx, dy, 8, 32, dx * 4,
CGColorSpaceCreateDeviceRGB(),
kCGImageAlphaNoneSkipLast,
dataProviderRef, 0, 0, kCGRenderingIntentDefault);
devRect = CGDisplayBounds(CGMainDisplayID());
kproc("osxscreen", winproc, nil, 0);
kproc("osxflush", flushproc, nil, 0);
Sleep(&rend, isready, nil);
}
示例11: glutWarpPointer
void Input::confineMouse(){
if (!bWarpMouse)
return;
#ifdef TARGET_WIN32
glutWarpPointer(renderer->windowX/2,renderer->windowY/2);
#endif
#ifdef TARGET_LINUX
glutWarpPointer(renderer->windowX/2,renderer->windowY/2);
#endif
#ifdef TARGET_MACOSX
CGPoint myPoint;
int centerX=renderer->windowX/2;
int centerY=renderer->windowY/2;
myPoint.x=centerX+renderer->windowPosX;
myPoint.y=centerY+renderer->windowPosY;
CGDisplayMoveCursorToPoint( CGMainDisplayID (),myPoint);
#endif
mouseX=renderer->windowX/2;
mouseY=renderer->windowY/2;
}
示例12: CGMainDisplayID
VideoMode VideoModeImpl::getDesktopMode()
{
CGDirectDisplayID display = CGMainDisplayID();
return VideoMode(CGDisplayPixelsWide(display),
CGDisplayPixelsHigh(display),
displayBitsPerPixel(display));
}
示例13: sizeof
static void *gfx_ctx_cgl_init(void *video_driver)
{
CGError err;
gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)calloc(1, sizeof(gfx_ctx_cgl_data_t));
if (!cgl)
goto error;
cgl->displayID = CGMainDisplayID();
err = CGDisplayCapture(cgl->displayID);
if (err != kCGErrorSuccess)
goto error;
cgl->glCtx = gfx_ctx_cgl_init_create();
if (!cgl->glCtx)
goto error;
attach_gl_context_to_window(cgl->glCtx,
CGShieldingWindowID(cgl->displayID), &cgl->width, &cgl->height);
printf("size:%dx%d\n", cgl->width, cgl->height);
CGLSetCurrentContext(cgl->glCtx);
return cgl;
error:
gfx_ctx_cgl_destroy(cgl);
return NULL;
}
示例14: wxDisplayDepth
// Returns depth of screen
int wxDisplayDepth()
{
int theDepth = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
if ( UMAGetSystemVersion() >= 0x1060 )
{
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
CFStringRef encoding = CGDisplayModeCopyPixelEncoding(currentMode);
if(CFStringCompare(encoding, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
theDepth = 32;
else if(CFStringCompare(encoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
theDepth = 16;
else if(CFStringCompare(encoding, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
theDepth = 8;
else
theDepth = 32; // some reasonable default
CFRelease(encoding);
CGDisplayModeRelease(currentMode);
}
else
#endif
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
theDepth = (int) CGDisplayBitsPerPixel(CGMainDisplayID());
#endif
}
return theDepth;
}
示例15: CGMainDisplayID
//---------------------------------------------------------------------------
// AGL init
//---------------------------------------------------------------------------
bool Pipe::configInit()
{
CGDirectDisplayID displayID = CGMainDisplayID();
const uint32_t device = getPipe()->getDevice();
if( device != LB_UNDEFINED_UINT32 )
{
CGDirectDisplayID *displayIDs = static_cast< CGDirectDisplayID* >(
alloca( (device+1) * sizeof( displayIDs )));
CGDisplayCount nDisplays;
if( CGGetOnlineDisplayList( device+1, displayIDs, &nDisplays ) !=
kCGErrorSuccess )
{
sendError( ERROR_AGLPIPE_DISPLAYS_NOTFOUND );
return false;
}
if( nDisplays <= device )
{
sendError( ERROR_AGLPIPE_DEVICE_NOTFOUND );
return false;
}
displayID = displayIDs[device];
}
_setCGDisplayID( displayID );
LBVERB << "Using CG displayID " << displayID << std::endl;
return true;
}