Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OpenGL commands only in paintGL() #261

Open
wants to merge 1 commit into
base: grbl_1_1
Choose a base branch
from

Conversation

hannesweisbach
Copy link

I compiled Candle from source on MacOS High Sierra and experienced a lot of crashes when launching the application. Upon debugging the issue I found that an assert inside glClearColor() within paintevent() triggered. The assert was checking whether OpenGL had been initialized. Indeed, initializeGL() was NOT called before the paintEvent appeared.

I read the documentation on QtOpenGL and the way I understand it is, that OpenGL commands have to be put inside paintGL(), which is called by the paintEvent() handler of the base class, which also takes care of properly calling initializeGL().

So I removed paintEvent() and renamed it in non-GLES code to paintGL(). That fixed the issue. OpenGL is now properly initialized and drawing works. (Sometimes Candle was able to launch without that change, but things were not drawn correctly. Maybe this fixes also some of the other reported drawing-related bugs.)

I don't really understand why there are OpenGL calls being issued in paintEvent(), but I believe this is wrong.

I'm also not sure why GLWidget inherits from QOpenGLWidget with GLES and from QGLWidget otherwise. My understanding is that QGLWidget is for backwards-compatibility with older Qt-Versions and QOpenGLWidget is its modern substitute. So I think QOpenGLWidget can always be used.

I'm new to the Candle code base and I'm happy to discuss this issue and make further fixes, if necessary.

See documentation of QOpenGLWidget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant