⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macvideo.cpp

📁 英特尔&#174 线程构建模块(英特尔&#174 TBB)是一个屡获殊荣的 C++ 运行时库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}//--------------------------------------------------------------------------------------------// functions (internal/private) ---------------------------------------------// CheckRenderer// looks at renderer attributes it has at least the VRAM is accelerated// Inputs:     hGD: GDHandle to device to look at//            pVRAM: pointer to VRAM in bytes required; out is actual VRAM if a renderer was found, otherwise it is the input parameter//            pTextureRAM:  pointer to texture RAM in bytes required; out is same (implementation assume VRAM returned by card is total so we add texture and VRAM)//            fAccelMust: do we check for acceleration// Returns: true if renderer for the requested device complies, false otherwisestatic Boolean CheckRenderer (GDHandle hGD, long* pVRAM, long* pTextureRAM, GLint* pDepthSizeSupport, Boolean fAccelMust){    AGLRendererInfo info, head_info;    GLint inum;    GLint dAccel = 0;    GLint dVRAM = 0, dMaxVRAM = 0;    Boolean canAccel = false, found = false;    head_info = aglQueryRendererInfo(&hGD, 1);    aglReportError ();    if(!head_info)    {        ReportError ("aglQueryRendererInfo error");        return false;    }    else    {        info = head_info;        inum = 0;        // see if we have an accelerated renderer, if so ignore non-accelerated ones        // this prevents returning info on software renderer when actually we'll get the hardware one        while (info)        {                aglDescribeRenderer(info, AGL_ACCELERATED, &dAccel);            aglReportError ();            if (dAccel)                canAccel = true;            info = aglNextRendererInfo(info);            aglReportError ();            inum++;        }                    info = head_info;        inum = 0;        while (info)        {            aglDescribeRenderer (info, AGL_ACCELERATED, &dAccel);            aglReportError ();            // if we can accel then we will choose the accelerated renderer             // how about compliant renderers???            if ((canAccel && dAccel) || (!canAccel && (!fAccelMust || dAccel)))            {                aglDescribeRenderer (info, AGL_VIDEO_MEMORY, &dVRAM);    // we assume that VRAM returned is total thus add texture and VRAM required                aglReportError ();                if (dVRAM >= (*pVRAM + *pTextureRAM))                {                    if (dVRAM >= dMaxVRAM) // find card with max VRAM                    {                        aglDescribeRenderer (info, AGL_DEPTH_MODES, pDepthSizeSupport);    // which depth buffer modes are supported                        aglReportError ();                        dMaxVRAM = dVRAM; // store max                        found = true;                    }                }            }            info = aglNextRendererInfo(info);            aglReportError ();            inum++;        }    }    aglDestroyRendererInfo(head_info);    if (found) // if we found a card that has enough VRAM and meets the accel criteria    {        *pVRAM = dMaxVRAM; // return VRAM        return true;    }    // VRAM will remain to same as it did when sent in    return false;}//-----------------------------------------------------------------------------------------------------------------------// CheckAllDeviceRenderers // looks at renderer attributes and each device must have at least one renderer that fits the profile// Inputs:     pVRAM: pointer to VRAM in bytes required; out is actual min VRAM of all renderers found, otherwise it is the input parameter//            pTextureRAM:  pointer to texture RAM in bytes required; out is same (implementation assume VRAM returned by card is total so we add texture and VRAM)//            fAccelMust: do we check fro acceleration// Returns: true if any renderer for on each device complies (not necessarily the same renderer), false otherwisestatic Boolean CheckAllDeviceRenderers (long* pVRAM, long* pTextureRAM, GLint* pDepthSizeSupport, Boolean fAccelMust){    AGLRendererInfo info, head_info;    GLint inum;    GLint dAccel = 0;    GLint dVRAM = 0, dMaxVRAM = 0;    Boolean canAccel = false, found = false, goodCheck = true; // can the renderer accelerate, did we find a valid renderer for the device, are we still successfully on all the devices looked at    long MinVRAM = 0x8FFFFFFF; // max long    GDHandle hGD = GetDeviceList (); // get the first screen    while (hGD && goodCheck)    {        head_info = aglQueryRendererInfo(&hGD, 1);        aglReportError ();        if(!head_info)        {            ReportError ("aglQueryRendererInfo error");            return false;        }        else        {            info = head_info;            inum = 0;            // see if we have an accelerated renderer, if so ignore non-accelerated ones            // this prevents returning info on software renderer when actually we'll get the hardware one            while (info)            {                aglDescribeRenderer(info, AGL_ACCELERATED, &dAccel);                aglReportError ();                if (dAccel)                    canAccel = true;                info = aglNextRendererInfo(info);                aglReportError ();                inum++;            }                            info = head_info;            inum = 0;            while (info)            {                    aglDescribeRenderer(info, AGL_ACCELERATED, &dAccel);                aglReportError ();                // if we can accel then we will choose the accelerated renderer                 // how about compliant renderers???                if ((canAccel && dAccel) || (!canAccel && (!fAccelMust || dAccel)))                {                    aglDescribeRenderer(info, AGL_VIDEO_MEMORY, &dVRAM);    // we assume that VRAM returned is total thus add texture and VRAM required                    aglReportError ();                    if (dVRAM >= (*pVRAM + *pTextureRAM))                    {                        if (dVRAM >= dMaxVRAM) // find card with max VRAM                        {                            aglDescribeRenderer(info, AGL_DEPTH_MODES, pDepthSizeSupport);    // which depth buffer modes are supported                            aglReportError ();                            dMaxVRAM = dVRAM; // store max                            found = true;                        }                    }                }                info = aglNextRendererInfo(info);                aglReportError ();                inum++;            }        }        aglDestroyRendererInfo(head_info);        if (found) // if we found a card that has enough VRAM and meets the accel criteria        {            if (MinVRAM > dMaxVRAM)                MinVRAM = dMaxVRAM; // return VRAM                    }        else            goodCheck = false; // one device failed thus entire requirement fails        hGD = GetNextDevice (hGD); // get next device    } // while    if (goodCheck) // we check all devices and each was good    {        *pVRAM = MinVRAM; // return VRAM        return true;    }    return false; //at least one device failed to have mins}//-----------------------------------------------------------------------------------------------------------------------// DumpCurrent// Kills currently allocated context// does not care about being pretty (assumes display is likely faded)// Inputs:     paglDraw, paglContext: things to be destroyedvoid DumpCurrent (AGLDrawable* paglDraw, AGLContext* paglContext, pstructGLInfo pcontextInfo){    if (*paglContext)    {        aglSetCurrentContext (NULL);        aglReportError ();        aglSetDrawable (*paglContext, NULL);        aglReportError ();        aglDestroyContext (*paglContext);        aglReportError ();        *paglContext = NULL;    }        if (pcontextInfo->fmt)    {        aglDestroyPixelFormat (pcontextInfo->fmt); // pixel format is no longer needed        aglReportError ();    }    pcontextInfo->fmt = 0;    if (*paglDraw) // do not destory a window on DSp since there is no window built in X        DisposeWindow (GetWindowFromPort (*paglDraw));    *paglDraw = NULL;}#pragma mark -// --------------------------------------------------------------------------// BuildGLonWindowstatic OSStatus BuildGLonWindow (WindowPtr pWindow, AGLContext* paglContext, pstructGLWindowInfo pcontextInfo, AGLContext aglShareContext){    GDHandle hGD = NULL;    GrafPtr cgrafSave = NULL;    short numDevices;    GLint depthSizeSupport;    OSStatus err = noErr;        if (!pWindow || !pcontextInfo)    {        ReportError ("NULL parameter passed to BuildGLonWindow.");        return paramErr;    }        GetPort (&cgrafSave);    SetPortWindowPort(pWindow);    // check renderere VRAM and acceleration    numDevices = FindGDHandleFromWindow (pWindow, &hGD);    if (!pcontextInfo->fDraggable)     // if numDevices > 1 then we will only be using the software renderer otherwise check only window device    {        if ((numDevices > 1) || (numDevices == 0)) // this window spans mulitple devices thus will be software only        {            // software renderer            // infinite VRAM, infinite textureRAM, not accelerated            if (pcontextInfo->fAcceleratedMust)            {                ReportError ("Unable to accelerate window that spans multiple devices");                return err;            }        }        else // not draggable on single device        {            if (!CheckRenderer (hGD, &(pcontextInfo->VRAM), &(pcontextInfo->textureRAM), &depthSizeSupport, pcontextInfo->fAcceleratedMust))            {                ReportError ("Renderer check failed");                return err;            }        }    }    // else draggable so must check all for support (each device should have at least one renderer that meets the requirements)    else if (!CheckAllDeviceRenderers (&(pcontextInfo->VRAM), &(pcontextInfo->textureRAM), &depthSizeSupport, pcontextInfo->fAcceleratedMust))    {        ReportError ("Renderer check failed");        return err;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -