N
N
Nikita Savinykh2018-02-07 00:06:51
Qt
Nikita Savinykh, 2018-02-07 00:06:51

Why does QOpenGLWidget crash (segmentation fault) when calling glDrawArrays(...)?

Good day.
There was a need to inject a working (!) OpenGL application into a Qt widget (QOpenGLWidget), but there was a problem - as soon as it comes to drawing (glDrawArrays), some absolutely working application crashes with a segmentation fault. Application code (I give the whole - just in case).
PS: If you comment out glDrawArrays, or glEnableVertexAttribArray(0) (Buffer with vertices), then the application starts, but, of course, nothing is drawn.
Model class:
Source code.
Header files
Resource loader:
Source code.
MainWindow header files
(Qt):
Source code.
Header files
QOpenGL widget file:
Source code.
Header files
Main.cpp:
Source code.
The very fragment where the application crashes:
Source code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Savinykh, 2018-02-07
@Ukio_G

Upd: It was necessary to add the openGL version and profile.

QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setVersion(3, 3);
    format.setProfile(QSurfaceFormat::CoreProfile);
    QSurfaceFormat::setDefaultFormat(format);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question