| @@ -57,7 +57,7 @@ public: | |||||
| NativeContext (Component& comp, | NativeContext (Component& comp, | ||||
| const OpenGLPixelFormat& cPixelFormat, | const OpenGLPixelFormat& cPixelFormat, | ||||
| void* shareContext, | void* shareContext, | ||||
| bool /*useMultisampling*/, | |||||
| bool useMultisamplingIn, | |||||
| OpenGLVersion) | OpenGLVersion) | ||||
| : component (comp), contextToShareWith (shareContext), dummy (*this) | : component (comp), contextToShareWith (shareContext), dummy (*this) | ||||
| { | { | ||||
| @@ -67,25 +67,13 @@ public: | |||||
| X11Symbols::getInstance()->xSync (display, False); | 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; | return; | ||||
| auto* peer = component.getPeer(); | auto* peer = component.getPeer(); | ||||
| @@ -242,6 +230,33 @@ public: | |||||
| struct Locker { Locker (NativeContext&) {} }; | struct Locker { Locker (NativeContext&) {} }; | ||||
| private: | 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; | static constexpr int embeddedWindowEventMask = ExposureMask | StructureNotifyMask; | ||||
| Component& component; | Component& component; | ||||