[Interest] OpenGL: Setting samples on default QSurfaceFormat

Andy asmaloney at gmail.com
Wed Sep 19 14:32:11 CEST 2018


Thanks Sean.

That was my initial thought too, but in order to create the context to
check the results, I need an application. But if I set the default after I
create the application I get a warning:

Warning: Setting a new default format with a different version or profile
after the global shared context is created may cause issues with context
sharing. (qsurfaceformat.cpp:836, static void
QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &))

(Which is what it says in the docs for QSurfaceFormat::setDefaultFormat())

Hence the catch-22.

The problem is actually stranger - if I request with 8 samples:

OpenGL Info
  Vendor: VMware, Inc.
  Renderer: SVGA3D; build: RELEASE;  LLVM;
  Version: 3.0 Mesa 17.2.0 (git-8cfea49610)
  Shading language: 1.30
  Requested: (v3.3 [core], depthBufferSize 24, stencilBufferSize -1, rgba
BufferSizes (-1, -1, -1, -1 ), samples 8, swapBehavior 0, swapInterval 1)
  Current:   (v3.0 [none], depthBufferSize 24, stencilBufferSize 8, rgba
BufferSizes (8, 8, 8, 8 ), samples -1, swapBehavior 2, swapInterval 1)

If I request without setSamples():

OpenGL Info
  Vendor: VMware, Inc.
  Renderer: SVGA3D; build: RELEASE;  LLVM;
  Version: 3.3 (Core Profile) Mesa 17.2.0 (git-8cfea49610)
  Shading language: 3.30
  Requested: (v3.3 [core], depthBufferSize 24, stencilBufferSize -1, rgba
BufferSizes (-1, -1, -1, -1 ), samples -1, swapBehavior 0, swapInterval 1)
  Current:   (v3.3 [core], depthBufferSize 24, stencilBufferSize 8, rgba
BufferSizes (8, 8, 8, 8 ), samples 0, swapBehavior 2, swapInterval 1)


I would have expected the first case to return "0" samples like the second
one - it properly adjusts everything else like the buffer sizes and swap
behaviour.

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>



On Wed, Sep 19, 2018 at 4:28 AM Sean Harmer <sh at theharmers.co.uk> wrote:

> Hi Andy,
>
> In your main, set up the desired QSurfaceFormat, use it to try to create a
> context, and check the results. If that works great, destroy it and carry
> on with that as the default surface format. Otherwise, drop down a level
> and try again until you find a surface format that works.
>
> Cheers,
>
> Sean
>
> On 17/09/2018 17:57, Andy wrote:
>
> I seem to have a catch-22.
>
> - QSurfaceFormat::setDefaultFormat() needs to be called before application
> construction.
>
> - I want multisampling on a 3.3 context by default, so I need to call
> QSurfaceFormat::setSamples().
>
> - I can't know how many samples are supported until after application
> construction by actually creating a context and asking how many it
> supports. (Or can I somehow?)
>
> - If I just setSamples() to the number I want (8) and call
> setDefaultFormat, then any card/driver that doesn't support that many
> samples fails to be created and I end up with a 2.0 default context.
>
> Any ideas?
>
> ---
> Andy Maloney  //  https://asmaloney.com
> twitter ~ @asmaloney <https://twitter.com/asmaloney>
>
>
>
> _______________________________________________
> Interest mailing listInterest at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180919/64ed96fe/attachment.html>


More information about the Interest mailing list