MNE-CPP  0.1.9
A Framework for Electrophysiology
pervertextessphongalphamaterial.cpp
Go to the documentation of this file.
1 //=============================================================================================================
35 //=============================================================================================================
36 // INCLUDES
37 //=============================================================================================================
38 
40 
41 //=============================================================================================================
42 // QT INCLUDES
43 //=============================================================================================================
44 
45 #include <Qt3DRender/qeffect.h>
46 #include <Qt3DRender/qtechnique.h>
47 #include <Qt3DRender/qshaderprogram.h>
48 #include <Qt3DRender/qparameter.h>
49 #include <Qt3DRender/qrenderpass.h>
50 #include <Qt3DRender/qgraphicsapifilter.h>
51 
52 #include <QUrl>
53 
54 //=============================================================================================================
55 // USED NAMESPACES
56 //=============================================================================================================
57 
58 using namespace DISP3DLIB;
59 using namespace Qt3DRender;
60 
61 //=============================================================================================================
62 // DEFINE MEMBER METHODS
63 //=============================================================================================================
64 
66 : AbstractPhongAlphaMaterial(bUseSortPolicy, parent)
67 , m_pInnerTessParameter(new QParameter("innerTess", 1.0f))
68 , m_pOuterTessParameter(new QParameter("outerTess", 1.0f))
69 , m_pTriangleScaleParameter(new QParameter("triangleScale", 1.0f))
70 , m_pVertexGL4Technique(new QTechnique())
71 , m_pVertexGL4RenderPass(new QRenderPass())
72 , m_pVertexGL4Shader(new QShaderProgram())
73 {
74  init();
75  setShaderCode();
76 }
77 
78 //=============================================================================================================
79 
80 void PerVertexTessPhongAlphaMaterial::init()
81 {
82  //Set OpenGL version - This material can only be used with opengl 4.0 or higher since it is using tesselation
83  m_pVertexGL4Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
84  m_pVertexGL4Technique->graphicsApiFilter()->setMajorVersion(4);
85  m_pVertexGL4Technique->graphicsApiFilter()->setMinorVersion(0);
86  m_pVertexGL4Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
87 
88  m_pVertexGL4Technique->addFilterKey(m_pDrawFilterKey);
89 
90  m_pVertexGL4Technique->addRenderPass(m_pVertexGL4RenderPass);
91 
92  m_pEffect->addTechnique(m_pVertexGL4Technique);
93 
94  m_pEffect->addParameter(m_pDiffuseParameter);
95  m_pEffect->addParameter(m_pSpecularParameter);
96  m_pEffect->addParameter(m_pShininessParameter);
97  m_pEffect->addParameter(m_pAlphaParameter);
98  m_pEffect->addParameter(m_pInnerTessParameter);
99  m_pEffect->addParameter(m_pOuterTessParameter);
100  m_pEffect->addParameter(m_pTriangleScaleParameter);
101 
102  this->setEffect(m_pEffect);
103 }
104 
105 //=============================================================================================================
106 
107 void PerVertexTessPhongAlphaMaterial::setShaderCode()
108 {
109  m_pVertexGL4Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha.vert"))));
110  m_pVertexGL4Shader->setTessellationControlShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha.tcs"))));
111  //m_pVertexGL4Shader->setTessellationEvaluationShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha_simple.tes"))));
112  m_pVertexGL4Shader->setTessellationEvaluationShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha_pn_triangles.tes"))));
113  m_pVertexGL4Shader->setGeometryShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha.geom"))));
114  m_pVertexGL4Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/engine/model/materials/shaders/gl4/pervertextessphongalpha.frag"))));
115 
116  m_pVertexGL4RenderPass->setShaderProgram(m_pVertexGL4Shader);
117 }
118 
119 //=============================================================================================================
DISP3DLIB::AbstractPhongAlphaMaterial::m_pSpecularParameter
QPointer< Qt3DRender::QParameter > m_pSpecularParameter
Definition: abstractphongalphamaterial.h:161
pervertextessphongalphamaterial.h
PerVertexTessPhongAlphaMaterial class declaration.
DISP3DLIB::AbstractPhongAlphaMaterial::m_pAlphaParameter
QPointer< Qt3DRender::QParameter > m_pAlphaParameter
Definition: abstractphongalphamaterial.h:163
DISP3DLIB::AbstractPhongAlphaMaterial::m_pEffect
QPointer< Qt3DRender::QEffect > m_pEffect
Definition: abstractphongalphamaterial.h:158
DISP3DLIB::AbstractPhongAlphaMaterial::m_pDiffuseParameter
QPointer< Qt3DRender::QParameter > m_pDiffuseParameter
Definition: abstractphongalphamaterial.h:160
DISP3DLIB::AbstractPhongAlphaMaterial::m_pShininessParameter
QPointer< Qt3DRender::QParameter > m_pShininessParameter
Definition: abstractphongalphamaterial.h:162
DISP3DLIB::AbstractPhongAlphaMaterial
This abstract class is used as a base class for all materials that are using the phong alpha lightini...
Definition: abstractphongalphamaterial.h:84
DISP3DLIB::PerVertexTessPhongAlphaMaterial::PerVertexTessPhongAlphaMaterial
PerVertexTessPhongAlphaMaterial(bool bUseSortPolicy=false, Qt3DCore::QNode *parent=nullptr)
Definition: pervertextessphongalphamaterial.cpp:65
DISP3DLIB::AbstractPhongAlphaMaterial::m_pDrawFilterKey
QPointer< Qt3DRender::QFilterKey > m_pDrawFilterKey
Definition: abstractphongalphamaterial.h:165