Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-07-20 11:59:30 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-07-20 11:59:30 +0300
commit422ffd252ac5f73f27f3c91b75b5d20a0ed7d460 (patch)
tree31ff6522ae64f2eb9b8b6c5875881cc13df2966b /intern
parent05ee9d2dd060b2e5ff20aa745c525cf20dc750ab (diff)
Pixel format selection now favours a format with a number of samples
closer to the one requested on Windows. Patch D1384 by Benoit Bolsee.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.cpp88
-rw-r--r--intern/ghost/intern/GHOST_ContextWGL.h7
2 files changed, 63 insertions, 32 deletions
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index 4f4cab77602..d2a9eed95d9 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -475,7 +475,7 @@ static void makeAttribList(
out.push_back(numOfAASamples);
out.push_back(WGL_SAMPLE_BUFFERS_ARB);
- out.push_back(1);
+ out.push_back(GL_TRUE);
}
if (sRGB) {
@@ -489,7 +489,7 @@ static void makeAttribList(
int GHOST_ContextWGL::_choose_pixel_format_arb_2(
bool stereoVisual,
- int numOfAASamples,
+ int *numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
@@ -502,12 +502,12 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
int samples;
// guard against some insanely high number of samples
- if (numOfAASamples > 64) {
+ if (*numOfAASamples > 64) {
fprintf(stderr, "Warning! Clamping number of samples to 64.\n");
samples = 64;
}
else {
- samples = numOfAASamples;
+ samples = *numOfAASamples;
}
// request a format with as many samples as possible, but not more than requested
@@ -542,46 +542,78 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_2(
int actualSamples;
wglGetPixelFormatAttribivARB(m_hDC, iPixelFormat, 0, 1, iQuery, &actualSamples);
- if (actualSamples != numOfAASamples) {
+ if (actualSamples != *numOfAASamples) {
fprintf(stderr,
"Warning! Unable to find a multisample pixel format that supports exactly %d samples. "
"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;
}
-int GHOST_ContextWGL::_choose_pixel_format_arb_1(
- bool stereoVisual,
+int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual,
int numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,
- int &swapMethodOut)
+ int *swapMethodOut)
{
int iPixelFormat;
-
- swapMethodOut = WGL_SWAP_COPY_ARB;
- iPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
-
- if (iPixelFormat == 0) {
- swapMethodOut = WGL_SWAP_UNDEFINED_ARB;
- iPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
+ int copyPixelFormat = 0;
+ int undefPixelFormat = 0;
+ int exchPixelFormat = 0;
+ int copyNumOfAASamples = 0;
+ int undefNumOfAASamples = 0;
+ int exchNumOfAASamples = 0;
+
+ *swapMethodOut = WGL_SWAP_COPY_ARB;
+ copyNumOfAASamples = numOfAASamples;
+ copyPixelFormat = _choose_pixel_format_arb_2(
+ stereoVisual, &copyNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut);
+
+ if (copyPixelFormat == 0 || copyNumOfAASamples < numOfAASamples) {
+ *swapMethodOut = WGL_SWAP_UNDEFINED_ARB;
+ undefNumOfAASamples = numOfAASamples;
+ undefPixelFormat = _choose_pixel_format_arb_2(
+ stereoVisual, &undefNumOfAASamples, needAlpha, needStencil, sRGB, *swapMethodOut);
+
+ if (undefPixelFormat == 0 || undefNumOfAASamples < numOfAASamples) {
+ *swapMethodOut = WGL_SWAP_EXCHANGE_ARB;
+ exchNumOfAASamples = numOfAASamples;
+ 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;
+ }
}
-
- if (iPixelFormat == 0) {
- swapMethodOut = WGL_SWAP_EXCHANGE_ARB;
- iPixelFormat = _choose_pixel_format_arb_2(
- stereoVisual, numOfAASamples, needAlpha, needStencil, sRGB, swapMethodOut);
+ else {
+ iPixelFormat = copyPixelFormat;
+ m_numOfAASamples = copyNumOfAASamples;
}
-
return iPixelFormat;
}
@@ -602,7 +634,7 @@ int GHOST_ContextWGL::choose_pixel_format_arb(
needAlpha,
needStencil,
sRGB,
- swapMethodOut);
+ &swapMethodOut);
if (iPixelFormat == 0 && stereoVisual) {
fprintf(stderr, "Warning! Unable to find a stereo pixel format.\n");
@@ -613,7 +645,7 @@ int GHOST_ContextWGL::choose_pixel_format_arb(
needAlpha,
needStencil,
sRGB,
- swapMethodOut);
+ &swapMethodOut);
m_stereoVisual = false; // set context property to actual value
}
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h b/intern/ghost/intern/GHOST_ContextWGL.h
index 9f4f6fab58a..c457ddab2f7 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -148,11 +148,10 @@ private:
bool needAlpha,
bool needStencil,
bool sRGB,
- int &swapMethodOut);
+ int *swapMethodOut);
- int _choose_pixel_format_arb_2(
- bool stereoVisual,
- int numOfAASamples,
+ int _choose_pixel_format_arb_2(bool stereoVisual,
+ int *numOfAASamples,
bool needAlpha,
bool needStencil,
bool sRGB,