Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_ContextWGL.cpp
| Show First 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | if (needStencil) { | ||||
| out.push_back(8); | out.push_back(8); | ||||
| } | } | ||||
| if (numOfAASamples > 0) { | if (numOfAASamples > 0) { | ||||
| out.push_back(WGL_SAMPLES_ARB); | out.push_back(WGL_SAMPLES_ARB); | ||||
| out.push_back(numOfAASamples); | out.push_back(numOfAASamples); | ||||
| out.push_back(WGL_SAMPLE_BUFFERS_ARB); | out.push_back(WGL_SAMPLE_BUFFERS_ARB); | ||||
| out.push_back(1); | out.push_back(GL_TRUE); | ||||
| } | } | ||||
| if (sRGB) { | if (sRGB) { | ||||
| out.push_back(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); | out.push_back(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); | ||||
| out.push_back(GL_TRUE); | out.push_back(GL_TRUE); | ||||
| } | } | ||||
| out.push_back(0); | out.push_back(0); | ||||
| } | } | ||||
| int GHOST_ContextWGL::_choose_pixel_format_arb_2( | int GHOST_ContextWGL::_choose_pixel_format_arb_2( | ||||
| bool stereoVisual, | bool stereoVisual, | ||||
| int numOfAASamples, | int &numOfAASamples, | ||||
| bool needAlpha, | bool needAlpha, | ||||
| bool needStencil, | bool needStencil, | ||||
| bool sRGB, | bool sRGB, | ||||
| int swapMethod) | int swapMethod) | ||||
| { | { | ||||
| std::vector<int> iAttributes; | std::vector<int> iAttributes; | ||||
| int iPixelFormat = 0; | int iPixelFormat = 0; | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (iPixelFormat != 0) { | ||||
| wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples); | wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples); | ||||
| if (actualSamples != numOfAASamples) { | if (actualSamples != numOfAASamples) { | ||||
| fprintf(stderr, | fprintf(stderr, | ||||
| "Warning! Unable to find a multisample pixel format that supports exactly %d samples. " | "Warning! Unable to find a multisample pixel format that supports exactly %d samples. " | ||||
| "Substituting one that uses %d samples.\n", | "Substituting one that uses %d samples.\n", | ||||
| numOfAASamples, actualSamples); | numOfAASamples, actualSamples); | ||||
| m_numOfAASamples = actualSamples; // set context property to actual value | numOfAASamples = actualSamples; // set context property to actual value | ||||
| } | } | ||||
| } | } | ||||
| else { | |||||
| numOfAASamples = 0; | |||||
| } | |||||
| return iPixelFormat; | return iPixelFormat; | ||||
| } | } | ||||
| int GHOST_ContextWGL::_choose_pixel_format_arb_1( | int GHOST_ContextWGL::_choose_pixel_format_arb_1( | ||||
| bool stereoVisual, | bool stereoVisual, | ||||
| int numOfAASamples, | int numOfAASamples, | ||||
| bool needAlpha, | bool needAlpha, | ||||
| bool needStencil, | bool needStencil, | ||||
| bool sRGB, | bool sRGB, | ||||
| int &swapMethodOut) | int &swapMethodOut) | ||||
| { | { | ||||
| int iPixelFormat; | int iPixelFormat; | ||||
| int copyPixelFormat = 0; | |||||
| int undefPixelFormat = 0; | |||||
| int exchPixelFormat = 0; | |||||
| int copyNumOfAASamples = 0; | |||||
| int undefNumOfAASamples = 0; | |||||
| int exchNumOfAASamples = 0; | |||||
| swapMethodOut = WGL_SWAP_COPY_ARB; | swapMethodOut = WGL_SWAP_COPY_ARB; | ||||
| iPixelFormat = _choose_pixel_format_arb_2( | copyNumOfAASamples = numOfAASamples; | ||||
| stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | copyPixelFormat = _choose_pixel_format_arb_2( | ||||
| stereoVisual, copyNumOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | |||||
| if (iPixelFormat == 0) { | if (copyPixelFormat == 0 || copyNumOfAASamples < numOfAASamples) { | ||||
| swapMethodOut = WGL_SWAP_UNDEFINED_ARB; | swapMethodOut = WGL_SWAP_UNDEFINED_ARB; | ||||
| iPixelFormat = _choose_pixel_format_arb_2( | undefNumOfAASamples = numOfAASamples; | ||||
| stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | undefPixelFormat = _choose_pixel_format_arb_2( | ||||
| } | stereoVisual, undefNumOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | ||||
| if (iPixelFormat == 0) { | if (undefPixelFormat == 0 || undefNumOfAASamples < numOfAASamples) { | ||||
| swapMethodOut = WGL_SWAP_EXCHANGE_ARB; | swapMethodOut = WGL_SWAP_EXCHANGE_ARB; | ||||
| iPixelFormat = _choose_pixel_format_arb_2( | exchNumOfAASamples = numOfAASamples; | ||||
| stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | exchPixelFormat = _choose_pixel_format_arb_2( | ||||
| stereoVisual, exchNumOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut); | |||||
| if (exchPixelFormat == 0 || exchNumOfAASamples < numOfAASamples) { | |||||
| // the number of AA samples cannot be met, take the highest | |||||
| if (undefPixelFormat != 0 && undefNumOfAASamples >= exchNumOfAASamples) { | |||||
| exchNumOfAASamples = undefNumOfAASamples; | |||||
| exchPixelFormat = undefPixelFormat; | |||||
| swapMethodOut = WGL_SWAP_UNDEFINED_ARB; | |||||
| } | |||||
| if (copyPixelFormat != 0 && copyNumOfAASamples >= exchNumOfAASamples) { | |||||
| exchNumOfAASamples = copyNumOfAASamples; | |||||
| exchPixelFormat = copyPixelFormat; | |||||
| swapMethodOut = WGL_SWAP_COPY_ARB; | |||||
| } | |||||
| } | |||||
| iPixelFormat = exchPixelFormat; | |||||
| m_numOfAASamples = exchNumOfAASamples; | |||||
| } | |||||
| else { | |||||
| iPixelFormat = undefPixelFormat; | |||||
| m_numOfAASamples = undefNumOfAASamples; | |||||
| } | |||||
| } | |||||
| else { | |||||
| iPixelFormat = copyPixelFormat; | |||||
| m_numOfAASamples = copyNumOfAASamples; | |||||
| } | } | ||||
| return iPixelFormat; | return iPixelFormat; | ||||
| } | } | ||||
| int GHOST_ContextWGL::choose_pixel_format_arb( | int GHOST_ContextWGL::choose_pixel_format_arb( | ||||
| bool stereoVisual, | bool stereoVisual, | ||||
| int numOfAASamples, | int numOfAASamples, | ||||
| bool needAlpha, | bool needAlpha, | ||||
| ▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines | |||||