21 #ifndef ABSTRACTGLCURVE_H
22 #define ABSTRACTGLCURVE_H
24 #include <tulip/GlSimpleEntity.h>
25 #include <tulip/Coord.h>
26 #include <tulip/Color.h>
27 #include <tulip/GlShaderProgram.h>
31 class TLP_GL_SCOPE AbstractGlCurve :
public GlSimpleEntity {
35 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
37 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode,
const std::vector<Coord> &controlPoints,
38 const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints);
40 virtual ~AbstractGlCurve();
42 void draw(
float lod, Camera *camera);
44 void translate(
const Coord &move);
46 virtual void setTexture(
const std::string &texture) {
47 this->texture = texture;
50 virtual void setOutlined(
const bool outlined) {
51 this->outlined = outlined;
54 virtual void setOutlineColor(
const Color &outlineColor) {
55 this->outlineColor = outlineColor;
62 virtual void setOutlineColorInterpolation(
const bool outlineColorInterpolation) {
63 this->outlineColorInterpolation = outlineColorInterpolation;
69 void setLineCurve(
const bool lineCurve) {
70 this->lineCurve = lineCurve;
73 void setCurveLineWidth(
const float curveLineWidth) {
74 this->curveLineWidth = curveLineWidth;
77 void setCurveQuadBordersWidth(
const float curveQuadBorderWidth) {
78 this->curveQuadBordersWidth = curveQuadBorderWidth;
81 virtual void setBillboardCurve(
const bool billboardCurve) {
82 this->billboardCurve = billboardCurve;
85 virtual void setLookDir(
const Coord &lookDir) {
86 this->lookDir = lookDir;
89 void getXML(std::string &);
91 void setWithXML(
const std::string &,
unsigned int &);
93 virtual void drawCurve(std::vector<Coord> &controlPoints,
const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints=100);
97 virtual void setCurveVertexShaderRenderingSpecificParameters() {};
99 virtual void cleanupAfterCurveVertexShaderRendering() {};
101 virtual Coord computeCurvePointOnCPU(
const std::vector<Coord> &controlPoints,
float t) = 0;
103 virtual void computeCurvePointsOnCPU(
const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints,
unsigned int nbCurvePoints) = 0;
105 static void buildCurveVertexBuffers(
const unsigned int nbCurvePoints,
bool vboOk);
107 void initShader(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
109 static std::map<unsigned int, GLfloat *> curveVertexBuffersData;
110 static std::map<unsigned int, std::vector<GLushort *> > curveVertexBuffersIndices;
111 static std::map<unsigned int, GLuint* > curveVertexBuffersObject;
112 static std::map<std::string, GlShaderProgram *> curvesShadersMap;
113 static std::map<std::string, GlShaderProgram *> curvesBillboardShadersMap;
114 static GlShader *curveVertexShaderNormalMain;
115 static GlShader *curveVertexShaderBillboardMain;
116 static GlShader *fisheyeDistortionVertexShader;
117 static bool canUseGeometryShader;
118 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesGeometryShadersMap;
119 static GlShader *curveVertexGeometryShaderNormalMain;
120 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesBillboardGeometryShadersMap;
122 std::string shaderProgramName;
123 GlShaderProgram *curveShaderProgramNormal;
124 GlShaderProgram *curveShaderProgramBillboard;
125 GlShaderProgram *curveShaderProgram;
128 std::vector<Coord> controlPoints;
133 unsigned int nbCurvePoints;
137 float texCoordFactor;
141 float curveLineWidth;
142 float curveQuadBordersWidth;
143 bool outlineColorInterpolation;