aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_widget.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl_widget.cc')
-rw-r--r--src/opengl_widget.cc23
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;
+}