21 #ifndef ABSTRACTGLCURVE_H 22 #define ABSTRACTGLCURVE_H 24 #include <tulip/OpenGlIncludes.h> 27 #include <tulip/GlSimpleEntity.h> 28 #include <tulip/Color.h> 32 class GlShaderProgram;
35 class TLP_GL_SCOPE AbstractGlCurve :
public GlSimpleEntity {
38 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
40 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode,
41 const std::vector<Coord> &controlPoints,
const Color &startColor,
42 const Color &endColor,
const float startSize,
const float endSize,
43 const unsigned int nbCurvePoints);
45 ~AbstractGlCurve()
override;
47 void draw(
float lod, Camera *camera)
override;
49 void translate(
const Coord &move)
override;
51 virtual void setTexture(
const std::string &texture) {
52 this->texture = texture;
55 virtual void setOutlined(
const bool outlined) {
56 this->outlined = outlined;
59 virtual void setOutlineColor(
const Color &outlineColor) {
60 this->outlineColor = outlineColor;
67 virtual void setOutlineColorInterpolation(
const bool outlineColorInterpolation) {
68 this->outlineColorInterpolation = outlineColorInterpolation;
74 void setLineCurve(
const bool lineCurve) {
75 this->lineCurve = lineCurve;
78 void setCurveLineWidth(
const float curveLineWidth) {
79 this->curveLineWidth = curveLineWidth;
82 void setCurveQuadBordersWidth(
const float curveQuadBorderWidth) {
83 this->curveQuadBordersWidth = curveQuadBorderWidth;
86 virtual void setBillboardCurve(
const bool billboardCurve) {
87 this->billboardCurve = billboardCurve;
90 virtual void setLookDir(
const Coord &lookDir) {
91 this->lookDir = lookDir;
94 void getXML(std::string &)
override;
96 void setWithXML(
const std::string &,
unsigned int &)
override;
98 virtual void drawCurve(std::vector<Coord> &controlPoints,
const Color &startColor,
99 const Color &endColor,
const float startSize,
const float endSize,
100 const unsigned int nbCurvePoints = 100);
103 virtual void setCurveVertexShaderRenderingSpecificParameters() {}
105 virtual void cleanupAfterCurveVertexShaderRendering() {}
107 virtual Coord computeCurvePointOnCPU(
const std::vector<Coord> &controlPoints,
float t) = 0;
109 virtual void computeCurvePointsOnCPU(
const std::vector<Coord> &controlPoints,
110 std::vector<Coord> &curvePoints,
111 unsigned int nbCurvePoints) = 0;
113 static void buildCurveVertexBuffers(
const unsigned int nbCurvePoints,
bool vboOk);
115 void initShader(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
117 static std::map<unsigned int, GLfloat *> curveVertexBuffersData;
118 static std::map<unsigned int, std::vector<GLushort *>> curveVertexBuffersIndices;
119 static std::map<unsigned int, GLuint *> curveVertexBuffersObject;
120 static std::map<std::string, GlShaderProgram *> curvesShadersMap;
121 static std::map<std::string, GlShaderProgram *> curvesBillboardShadersMap;
122 static GlShader *curveVertexShaderNormalMain;
123 static GlShader *curveVertexShaderBillboardMain;
124 static GlShader *fisheyeDistortionVertexShader;
125 static GlShader *curveFragmentShader;
126 static bool canUseGeometryShader;
127 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *>>
128 curvesGeometryShadersMap;
129 static GlShader *curveVertexGeometryShaderNormalMain;
130 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *>>
131 curvesBillboardGeometryShadersMap;
133 std::string shaderProgramName;
134 GlShaderProgram *curveShaderProgramNormal;
135 GlShaderProgram *curveShaderProgramBillboard;
136 GlShaderProgram *curveShaderProgram;
138 std::vector<Coord> controlPoints;
143 unsigned int nbCurvePoints;
147 float texCoordFactor;
151 float curveLineWidth;
152 float curveQuadBordersWidth;
153 bool outlineColorInterpolation;