diff options
author | ccolin | 2021-01-03 19:55:04 +0100 |
---|---|---|
committer | ccolin | 2021-01-03 19:55:04 +0100 |
commit | 5326f294ceb95f1b535d145b5fdbdc221f560d53 (patch) | |
tree | a5d9dee2ebfa6413aedd764e901f3df994888614 /src/opengl_widget.cc | |
parent | ec4017bb0ff221c5c3e192a165c8d60a54f3bedc (diff) |
add option to draw trajectories
Diffstat (limited to 'src/opengl_widget.cc')
-rw-r--r-- | src/opengl_widget.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/opengl_widget.cc b/src/opengl_widget.cc index 29361c5..fb318ab 100644 --- a/src/opengl_widget.cc +++ b/src/opengl_widget.cc @@ -144,6 +144,20 @@ void OpenGLWidget::initializeGL() { main_program.setUniformValue("tex", 0); main_program.release(); + if (!line_program.addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/line.vert")) { + qFatal("Error compiling line.vert: %s", line_program.log().toLocal8Bit().constData()); + } + if (!line_program.addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/line.frag")) { + qFatal("Error compiling line.frag: %s", line_program.log().toLocal8Bit().constData()); + } + line_program.bindAttributeLocation("in_pos", 0); + if (!line_program.link()) { + qFatal("Error linking the line shader program: %s", line_program.log().toLocal8Bit().constData()); + } + line_program.bind(); + line_program.setUniformValue("color", 0, 0, 0); + line_program.release(); + loadSkybox(); loadGround(); @@ -183,6 +197,11 @@ void OpenGLWidget::paintGL() { glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); + line_program.bind(); + line_program.setUniformValue("proj", proj); + line_program.setUniformValue("view", view); + line_program.release(); + main_program.bind(); main_program.setUniformValue("proj", proj); main_program.setUniformValue("view", view); @@ -232,3 +251,7 @@ void OpenGLWidget::setPainter(const Painter *p) { QOpenGLShaderProgram *OpenGLWidget::getMainProgram() { return &main_program; } + +QOpenGLShaderProgram *OpenGLWidget::getLineProgram() { + return &line_program; +} |