Blobalizer
Loading...
Searching...
No Matches
ChemStructureShader.h
Go to the documentation of this file.
1#include <Corrade/Utility/Resource.h>
2#include <Magnum/GL/AbstractShaderProgram.h>
3#include <Magnum/GL/Shader.h>
4#include <Magnum/GL/Texture.h>
5#include <Magnum/GL/Version.h>
6
7using namespace Magnum;
8
10class ChemStructureShader : public GL::AbstractShaderProgram {
11public:
12
13 enum : UnsignedInt {
16 MaskOutput = 2
17 };
18
21 Utility::Resource rs("data");
22
23 GL::Shader vertShader{GL::Version::GL460, GL::Shader::Type::Vertex};
24 GL::Shader fragShader{GL::Version::GL460, GL::Shader::Type::Fragment};
25 vertShader.addSource(rs.getString("ChemStructureShader.vert"));
26 fragShader.addSource(rs.getString("ChemStructureShader.frag"));
27
28 CORRADE_INTERNAL_ASSERT_OUTPUT(vertShader.compile());
29 CORRADE_INTERNAL_ASSERT_OUTPUT(fragShader.compile());
30
31 this->attachShaders({vertShader, fragShader});
32 CORRADE_INTERNAL_ASSERT(this->link());
33
34 this->modelMatrixUniform = this->uniformLocation("modelMatrix");
35 this->modelViewMatrixUniform = this->uniformLocation("modelViewMatrix");
36 this->viewMatrixUniform = this->uniformLocation("viewMatrix");
37 this->projectionMatrixUniform = this->uniformLocation("projectionMatrix");
38 //this->cameraPositionUniform = this->uniformLocation("cameraPosition");
39 }
40
43 void ChemStructureShader::setModelMatrix(const Matrix4& matrix) {
44 this->setUniform(this->modelMatrixUniform, matrix);
45 }
46
49 void ChemStructureShader::setModelViewMatrix(const Matrix4& matrix) {
50 this->setUniform(this->modelViewMatrixUniform, matrix);
51 }
52
55 void ChemStructureShader::setProjectionMatrix(const Matrix4 &matrix) {
56 this->setUniform(this->projectionMatrixUniform, matrix);
57 }
58
61 void ChemStructureShader::setViewMatrix(const Matrix4 &matrix) {
62 this->setUniform(this->viewMatrixUniform, matrix);
63 }
64
67 //void ChemStructureShader::setCameraPosition(const Vector3 &position) {
68 // this->setUniform(this->cameraPositionUniform, position);
69 //}
70
71private:
72 enum : Int { TextureUnit = 0 };
73
78 //Int cameraPositionUniform;
79};
A class representing the shader responsible for the rasterization of the internal structure of the mo...
Definition ChemStructureShader.h:10
ChemStructureShader()
Loads the shader files from disk, then compiles and links them.
Definition ChemStructureShader.h:20
void setModelViewMatrix(const Matrix4 &matrix)
Update the model view matrix uniform of this shader.
Definition ChemStructureShader.h:49
@ MaskOutput
Definition ChemStructureShader.h:16
@ PosOutput
Definition ChemStructureShader.h:15
@ ColorOutput
Definition ChemStructureShader.h:14
void setViewMatrix(const Matrix4 &matrix)
Update the view matrix uniform of this shader.
Definition ChemStructureShader.h:61
@ TextureUnit
Definition ChemStructureShader.h:72
Int modelViewMatrixUniform
Definition ChemStructureShader.h:75
void setProjectionMatrix(const Matrix4 &matrix)
Update the projection matrix uniform of this shader.
Definition ChemStructureShader.h:55
Int projectionMatrixUniform
Definition ChemStructureShader.h:77
void setModelMatrix(const Matrix4 &matrix)
Update the model matrix uniform of this shader.
Definition ChemStructureShader.h:43
Int modelMatrixUniform
Definition ChemStructureShader.h:74
Int viewMatrixUniform
Definition ChemStructureShader.h:76