Unsolved QOpenGLWidget QSurfaceFormat irregularities
-
Hello
I was using QOpenGLWindow to render a line with MSAA enabled by using QSurfaceFormat::setDefaultFormat(format) and it works fine, however if I use the exact same code except I subclass it and use QOpenGLWidget something odd happens,
#include "test.h" #include "Display.h" #include <QtWidgets/QApplication> #include <QSurfaceFormat> #include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat format; format.setVersion(3, 3); //format.setOption(QSurfaceFormat::DebugContext); format.setProfile(QSurfaceFormat::CoreProfile); format.setDepthBufferSize(24); format.setSamples(16); format.setStencilBufferSize(8); QSurfaceFormat::setDefaultFormat(format); ProjectileMotionSim w; w.show(); return a.exec(); }
in the subclass's constructor the format is this:
QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 16, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CoreProfile))
notice how the sample is set at 16 as specified by me in the main function, this is what I expect to see,
however in the initializeGL function the format now looks like this:QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CoreProfile))
the only things that I can change in the second one(even if I set it in the main function) is the depthbuffersize and the OpenGLversion nothing else will change. Also if I set the version to 2.0 I get this:
ARB::createContext: wglCreateContextAttribsARB() failed (GL error code: 0x502) for format: QSurfaceFormat(version 2.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 16, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CoreProfile)), shared context: 0x0 () ARB::createContext: wglCreateContextAttribsARB() failed (GL error code: 0x502) for format: QSurfaceFormat(version 2.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CoreProfile)), shared context: 0x30000 ()
This does not happen when using QOpenGLWindow, it uses 2.0 fine, The documentation did mention if the system does not support MSAA the request will get ignored which is clearly not the case here since I can set (something) to 16 samples.
any help would be appreciated,
thanks -
-
Thanks for the reply,
I tried that, and it still doesn't work
thanks