21 #ifndef ABSTRACTGLCURVE_H 22 #define ABSTRACTGLCURVE_H 24 #include <tulip/OpenGlIncludes.h> 26 #include <unordered_map> 28 #include <tulip/Color.h> 29 #include <tulip/Coord.h> 30 #include <tulip/GlSimpleEntity.h> 34 class GlShaderProgram;
37 class TLP_GL_SCOPE AbstractGlCurve :
public GlSimpleEntity {
40 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
42 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode,
43 const std::vector<Coord> &controlPoints,
const Color &startColor,
44 const Color &endColor,
const float startSize,
const float endSize,
45 const unsigned int nbCurvePoints);
47 ~AbstractGlCurve()
override;
49 void draw(
float lod, Camera *camera)
override;
51 void translate(
const Coord &move)
override;
53 virtual void setTexture(
const std::string &texture) {
54 this->texture = texture;
57 virtual void setOutlined(
const bool outlined) {
58 this->outlined = outlined;
61 virtual void setOutlineColor(
const Color &outlineColor) {
62 this->outlineColor = outlineColor;
69 virtual void setOutlineColorInterpolation(
const bool outlineColorInterpolation) {
70 this->outlineColorInterpolation = outlineColorInterpolation;
76 void setLineCurve(
const bool lineCurve) {
77 this->lineCurve = lineCurve;
80 void setCurveLineWidth(
const float curveLineWidth) {
81 this->curveLineWidth = curveLineWidth;
84 void setCurveQuadBordersWidth(
const float curveQuadBorderWidth) {
85 this->curveQuadBordersWidth = curveQuadBorderWidth;
88 virtual void setBillboardCurve(
const bool billboardCurve) {
89 this->billboardCurve = billboardCurve;
92 virtual void setLookDir(
const Coord &lookDir) {
93 this->lookDir = lookDir;
96 void getXML(std::string &)
override;
98 void setWithXML(
const std::string &,
unsigned int &)
override;
100 virtual void drawCurve(std::vector<Coord> &controlPoints,
const Color &startColor,
101 const Color &endColor,
const float startSize,
const float endSize,
102 const unsigned int nbCurvePoints = 100);
105 virtual void setCurveVertexShaderRenderingSpecificParameters() {}
107 virtual void cleanupAfterCurveVertexShaderRendering() {}
109 virtual Coord computeCurvePointOnCPU(
const std::vector<Coord> &controlPoints,
float t) = 0;
111 virtual void computeCurvePointsOnCPU(
const std::vector<Coord> &controlPoints,
112 std::vector<Coord> &curvePoints,
113 unsigned int nbCurvePoints) = 0;
115 static void buildCurveVertexBuffers(
const unsigned int nbCurvePoints,
bool vboOk);
117 void initShader(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
119 static std::unordered_map<unsigned int, GLfloat *> curveVertexBuffersData;
120 static std::unordered_map<unsigned int, std::vector<GLushort *>> curveVertexBuffersIndices;
121 static std::unordered_map<unsigned int, GLuint *> curveVertexBuffersObject;
122 static std::unordered_map<std::string, GlShaderProgram *> curvesShadersMap;
123 static std::unordered_map<std::string, GlShaderProgram *> curvesBillboardShadersMap;
124 static GlShader *curveVertexShaderNormalMain;
125 static GlShader *curveVertexShaderBillboardMain;
126 static GlShader *fisheyeDistortionVertexShader;
127 static GlShader *curveFragmentShader;
128 static bool canUseGeometryShader;
129 static std::unordered_map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *>>
130 curvesGeometryShadersMap;
131 static GlShader *curveVertexGeometryShaderNormalMain;
132 static std::unordered_map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *>>
133 curvesBillboardGeometryShadersMap;
135 std::string shaderProgramName;
136 GlShaderProgram *curveShaderProgramNormal;
137 GlShaderProgram *curveShaderProgramBillboard;
138 GlShaderProgram *curveShaderProgram;
140 std::vector<Coord> controlPoints;
145 unsigned int nbCurvePoints;
149 float texCoordFactor;
153 float curveLineWidth;
154 float curveQuadBordersWidth;
155 bool outlineColorInterpolation;