| 35 void buildShaders( |
35 void buildShaders( |
| 36 QOpenGLShaderProgram* shaderProgram, |
36 QOpenGLShaderProgram* shaderProgram, |
| 37 const char* vertexShaderSource, |
37 const char* vertexShaderSource, |
| 38 const char* fragmentShaderSource); |
38 const char* fragmentShaderSource); |
| 39 void checkForGLErrors(QWidget* parent); |
39 void checkForGLErrors(QWidget* parent); |
| |
40 inline glm::vec3 colorToVector3(const QColor& color) |
| |
41 { |
| |
42 return {toFloat(color.redF()), toFloat(color.greenF()), toFloat(color.blueF())}; |
| |
43 } |
| |
44 inline glm::vec4 colorToVector4(const QColor& color) |
| |
45 { |
| |
46 return {gl::colorToVector3(color), toFloat(color.alphaF())}; |
| |
47 } |
| 40 } |
48 } |
| 41 |
49 |
| 42 class gl::ShaderProgram : public QOpenGLShaderProgram |
50 class gl::ShaderProgram : public QOpenGLShaderProgram |
| 43 { |
51 { |
| 44 public: |
52 public: |
| 48 void setUniformMatrix(const char* uniformName, const glm::mat<4, 4, Float, Prec>& value) |
56 void setUniformMatrix(const char* uniformName, const glm::mat<4, 4, Float, Prec>& value) |
| 49 { |
57 { |
| 50 const float (*array)[4][4] = reinterpret_cast<const float(*)[4][4]>(glm::value_ptr(value)); |
58 const float (*array)[4][4] = reinterpret_cast<const float(*)[4][4]>(glm::value_ptr(value)); |
| 51 this->setUniformValue(uniformName, *array); |
59 this->setUniformValue(uniformName, *array); |
| 52 } |
60 } |
| 53 template<int N, typename Float, glm::qualifier Prec> |
61 template<typename Float, glm::qualifier Prec> |
| 54 void setUniformVector(const char* uniformName, const glm::vec<N, Float, Prec>& value) |
62 void setUniformVector(const char* uniformName, const glm::vec<4, Float, Prec>& value) |
| 55 { |
63 { |
| 56 const Float (*array)[N] = reinterpret_cast<const Float(*)[N]>(glm::value_ptr(value)); |
64 this->setUniformValue(uniformName, value.x, value.y, value.z, value.w); |
| 57 this->setUniformValue(uniformName, array); |
|
| 58 } |
65 } |
| 59 }; |
66 }; |
| 60 |
67 |
| 61 struct gl::Polygon |
68 struct gl::Polygon |
| 62 { |
69 { |