Solved Switching from QOpenGLExtraFunctions to QOpenGLFunctions_4_4_Core broke rendering
-
Core programming is very different than compatibility mode. You have to program opengl differently than most of the examples on the internet.
This site should help. It covers the basics in depth:
https://learnopengl.com/Also search on the differences between core programming and compatibility mode. If you don't have the patience for that then use a non core version of the functions.
-
@fcarney But I thought I was programming in core mode...
I've setQSurfaceFormat::setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile)
and so created a context in core mode, but was I actually using compatibility version of functions with core profile?Because I actually already was following some of the rules to program in core mode. Like I have to bind VAO always when I call
glDrawArrays
-
I guess I made a poor assumption. I was thinking you might be uninformed what core mode was. Not sure on that. I am not sure what QOpenGLExtraFunctions assumes as far as modes. Can you check to see if you were indeed in core mode? I wonder if using those functions makes the assumption you are not. Or if something really is broken.
-
@fcarney I've tried to switch to
QOpenGLFunctions_4_4_Compatibility
, but nowQOpenGLContext::versionFunctions<QOpenGLFunctions_4_4_Compatibility>()
returns NULL, what is expected, because I'm creating the context in core mode, because I've set that inQSurfaceFormat
. I'm pretty sure I always was in Core mode... Don't know how to check that exactly, but that would be very surprising, If QT was initializing Compatibility profile. -
Did 4.4 introduce any more shader programs that need to be defined for the pipeline? I seem to remember it adding 2 new shader types to the pipeline, but I was not sure they were required to be defined.
Edit: Versus 3.3
-
@fcarney As far as I know, you aren't required to use any of the new shader types. Just opt-in if they are useful for you. Using 3.3 core profile code under 4.4 should normally Just Work.
Try breaking out the debug logger class and see if it spits out anything useful: https://doc.qt.io/qt-5/qopengldebuglogger.html
?
-
@wrosecrans Yes, I'm already monitoring OpenGL errors using
glDebugMessageCallback
, but It shows no error, as well asglGetError
-
@fcarney I think that the point is that I already was successfully rendering in 4.4 Core, and now I just have changed the class which provides the OpenGL functions, I didn't change the OpenGL profile, and so I don't use any new features.
QOpenGLFunctions_4_4_Core
just has to give me more functions, but instead it broke already successfully used, may be some function calls don't happen for some reason, and so OpenGL state is broken. -
It says here that OpenGLExtraFunctions is for OpenGL ES:
https://doc.qt.io/qt-5/qopenglextrafunctions.html#detailsMaybe that is the difference. I have not programmed ES so I am unsure if the calls would be compatible.
-
@fcarney May be. I guess I have to make a separated project with minimal working code to determine the problem and where is the difference.
-
@fcarney Hi, I've solved the issue, I've appended explanation into the first post, that is a strange behavior for me, or I may miss something about how does QT work with framebuffers.
-
@mr.indieperson said in Switching from QOpenGLExtraFunctions to QOpenGLFunctions_4_4_Core broke rendering:
glBindFrameBuffer
Did you call glGenFramebuffers or where did you get the number for that framebuffer?
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindFramebuffer.xhtmlApparently 0 breaks the binding to the GL_DRAW_FRAMEBUFFER
Edit: If its a "magic" number you tried it is likely to break later.
-
@fcarney No, that is not a magic number, I actually call
f->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultFboId)
inQOpenGLWidget::paintGL
, it just returns 4 always with current project code. Of course it may change. -
@fcarney And well, I've remembered about
QOpenGLWidget::defaultFramebufferObject
, it returns the same value asf->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &defaultFboId)
, which I had to use when I was binding the default QT's framebuffer to do final rendering, but I just passed 0 and it was working, so I was thinking about it no more.