当前位置: 首页>>代码示例>>C++>>正文


C++ CGMainDisplayID函数代码示例

本文整理汇总了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);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:25,代码来源:readfb.c

示例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();
}
开发者ID:ardeujho,项目名称:self,代码行数:14,代码来源:quartzWindow.cpp

示例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());
                };
            };
开发者ID:ndevenish,项目名称:Hugin,代码行数:27,代码来源:wxcms.cpp

示例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);
}
开发者ID:Pfiver,项目名称:fb-rotate,代码行数:27,代码来源:fb-rotate.c

示例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;
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:26,代码来源:cgl_gl.cpp

示例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
}
开发者ID:hamedmohammadi,项目名称:nui3,代码行数:29,代码来源:nglVideoMode_CoreFoundation.cpp

示例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));
    }
}
开发者ID:AmesianX,项目名称:wine,代码行数:38,代码来源:display.c

示例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;
}
开发者ID:CyberSys,项目名称:darkplaces,代码行数:30,代码来源:vid_agl.c

示例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;
}
开发者ID:CyberSys,项目名称:darkplaces,代码行数:28,代码来源:vid_agl.c

示例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);
}
开发者ID:Vykook,项目名称:acme-sac,代码行数:28,代码来源:win.c

示例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;

}
开发者ID:ElementalSpork,项目名称:Moviesandbox,代码行数:26,代码来源:input.cpp

示例12: CGMainDisplayID

VideoMode VideoModeImpl::getDesktopMode()
{
    CGDirectDisplayID display = CGMainDisplayID();
    return VideoMode(CGDisplayPixelsWide(display), 
                     CGDisplayPixelsHigh(display), 
                     displayBitsPerPixel(display));
}
开发者ID:AdamFlores,项目名称:SFML,代码行数:7,代码来源:VideoModeImpl.cpp

示例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;
}
开发者ID:Sotsukun,项目名称:RetroArch,代码行数:34,代码来源:cgl_ctx.c

示例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;
}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:32,代码来源:utils_osx.cpp

示例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;
}
开发者ID:ImpressionMe,项目名称:Equalizer,代码行数:34,代码来源:pipe.cpp


注:本文中的CGMainDisplayID函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。