Browse Source

OpenGL: Add multisampling support on Linux

v6.1.6
reuk 4 years ago
parent
commit
75258a4ba6
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 32 additions and 17 deletions
  1. +32
    -17
      modules/juce_opengl/native/juce_OpenGL_linux_X11.h

+ 32
- 17
modules/juce_opengl/native/juce_OpenGL_linux_X11.h View File

@@ -57,7 +57,7 @@ public:
NativeContext (Component& comp,
const OpenGLPixelFormat& cPixelFormat,
void* shareContext,
bool /*useMultisampling*/,
bool useMultisamplingIn,
OpenGLVersion)
: component (comp), contextToShareWith (shareContext), dummy (*this)
{
@@ -67,25 +67,13 @@ public:
X11Symbols::getInstance()->xSync (display, False);
GLint attribs[] =
const std::vector<GLint> optionalAttribs
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, cPixelFormat.redBits,
GLX_GREEN_SIZE, cPixelFormat.greenBits,
GLX_BLUE_SIZE, cPixelFormat.blueBits,
GLX_ALPHA_SIZE, cPixelFormat.alphaBits,
GLX_DEPTH_SIZE, cPixelFormat.depthBufferBits,
GLX_STENCIL_SIZE, cPixelFormat.stencilBufferBits,
GLX_ACCUM_RED_SIZE, cPixelFormat.accumulationBufferRedBits,
GLX_ACCUM_GREEN_SIZE, cPixelFormat.accumulationBufferGreenBits,
GLX_ACCUM_BLUE_SIZE, cPixelFormat.accumulationBufferBlueBits,
GLX_ACCUM_ALPHA_SIZE, cPixelFormat.accumulationBufferAlphaBits,
None
GLX_SAMPLE_BUFFERS, useMultisamplingIn ? 1 : 0,
GLX_SAMPLES, cPixelFormat.multisamplingLevel
};
bestVisual = glXChooseVisual (display, X11Symbols::getInstance()->xDefaultScreen (display), attribs);
if (bestVisual == nullptr)
if (! tryChooseVisual (cPixelFormat, optionalAttribs) && ! tryChooseVisual (cPixelFormat, {}))
return;
auto* peer = component.getPeer();
@@ -242,6 +230,33 @@ public:
struct Locker { Locker (NativeContext&) {} };
private:
bool tryChooseVisual (const OpenGLPixelFormat& format, const std::vector<GLint>& optionalAttribs)
{
std::vector<GLint> allAttribs
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, format.redBits,
GLX_GREEN_SIZE, format.greenBits,
GLX_BLUE_SIZE, format.blueBits,
GLX_ALPHA_SIZE, format.alphaBits,
GLX_DEPTH_SIZE, format.depthBufferBits,
GLX_STENCIL_SIZE, format.stencilBufferBits,
GLX_ACCUM_RED_SIZE, format.accumulationBufferRedBits,
GLX_ACCUM_GREEN_SIZE, format.accumulationBufferGreenBits,
GLX_ACCUM_BLUE_SIZE, format.accumulationBufferBlueBits,
GLX_ACCUM_ALPHA_SIZE, format.accumulationBufferAlphaBits
};
allAttribs.insert (allAttribs.end(), optionalAttribs.begin(), optionalAttribs.end());
allAttribs.push_back (None);
bestVisual = glXChooseVisual (display, X11Symbols::getInstance()->xDefaultScreen (display), allAttribs.data());
return bestVisual != nullptr;
}
static constexpr int embeddedWindowEventMask = ExposureMask | StructureNotifyMask;
Component& component;


Loading…
Cancel
Save