Improve new wxGLCanvas compatibility with old hardware and code
Combined patch with the following changes: - Don't add wxGLAttributes::Defaults() when the attributes-list is NULL. - Add display default attributes used in wx versions before 3.1 when the attributes-list is NULL. These attributes are different for each platform. - Fix wxMSW PixelFormatDescriptor initialization. - Don't set color buffers when RGBA() is used. - Fix setting colour sizes in OS X and a few other fixes. - Make documentation more clear about these subjects. Closes #17425.
This commit is contained in:
committed by
Vadim Zeitlin
parent
fad33800dc
commit
b28dd88994
@@ -180,17 +180,17 @@ void wxGLContextAttrs::EndList()
|
||||
|
||||
wxGLAttributes& wxGLAttributes::RGBA()
|
||||
{
|
||||
AddAttribute(WXOpenGLPFAColorSize);
|
||||
AddAttribute(24);
|
||||
AddAttribute(WXOpenGLPFAAlphaSize);
|
||||
AddAttribute(8);
|
||||
// No effect
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxGLAttributes& wxGLAttributes::BufferSize(int val)
|
||||
{
|
||||
// No effect
|
||||
wxUnusedVar(val);
|
||||
if ( val >= 0 )
|
||||
{
|
||||
AddAttribute(WXOpenGLPFAColorSize);
|
||||
AddAttribute(val);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -225,6 +225,10 @@ wxGLAttributes& wxGLAttributes::AuxBuffers(int val)
|
||||
|
||||
wxGLAttributes& wxGLAttributes::MinRGBA(int mRed, int mGreen, int mBlue, int mAlpha)
|
||||
{
|
||||
// NOTE: 'NSOpenGLPixelFormat' doesn't offer a value for each of the RGBA
|
||||
// components, but just one for the size of the colour buffer. In order
|
||||
// to make wx more effective, this function _does_ set the colour buffer.
|
||||
|
||||
int minColorBits = 0;
|
||||
if ( mRed > minColorBits )
|
||||
minColorBits = mRed;
|
||||
@@ -232,6 +236,9 @@ wxGLAttributes& wxGLAttributes::MinRGBA(int mRed, int mGreen, int mBlue, int mAl
|
||||
minColorBits = mGreen;
|
||||
if ( mBlue > minColorBits )
|
||||
minColorBits = mBlue;
|
||||
// Now that we have the R/G/B maximum, obtain a minimun for the buffer.
|
||||
minColorBits *= 4; // 'alpha' included
|
||||
|
||||
if ( minColorBits > 0 )
|
||||
{
|
||||
AddAttribute(WXOpenGLPFAColorSize);
|
||||
@@ -268,6 +275,7 @@ wxGLAttributes& wxGLAttributes::Stencil(int val)
|
||||
|
||||
wxGLAttributes& wxGLAttributes::MinAcumRGBA(int mRed, int mGreen, int mBlue, int mAlpha)
|
||||
{
|
||||
// See MinRGBA() for some explanation.
|
||||
int minAcumBits = 0;
|
||||
if ( mRed > minAcumBits )
|
||||
minAcumBits = mRed;
|
||||
@@ -275,15 +283,14 @@ wxGLAttributes& wxGLAttributes::MinAcumRGBA(int mRed, int mGreen, int mBlue, int
|
||||
minAcumBits = mGreen;
|
||||
if ( mBlue > minAcumBits )
|
||||
minAcumBits = mBlue;
|
||||
if ( minAcumBits > 0 )
|
||||
if ( mAlpha > minAcumBits )
|
||||
minAcumBits = mAlpha;
|
||||
minAcumBits *= 4;
|
||||
if ( minAcumBits >= 0 )
|
||||
{
|
||||
AddAttribute(WXOpenGLPFAAccumSize);
|
||||
AddAttribute(minAcumBits);
|
||||
}
|
||||
|
||||
// No effect for Alpha in accumulation buffer
|
||||
wxUnusedVar(mAlpha);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -352,6 +359,15 @@ wxGLAttributes& wxGLAttributes::Defaults()
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxGLAttributes::AddDefaultsForWXBefore31()
|
||||
{
|
||||
// ParseAttribList() will add EndList(), don't do it now
|
||||
DoubleBuffer();
|
||||
// Negative value will keep its buffer untouched
|
||||
BufferSize(8).Depth(8).MinRGBA(-1, -1, -1, 0);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLContext
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user