21 #ifndef ABSTRACTGLCURVE_H 22 #define ABSTRACTGLCURVE_H 28 #if defined(__APPLE__) 29 #include <OpenGL/gl.h> 35 #include <tulip/GlSimpleEntity.h> 36 #include <tulip/Color.h> 40 class GlShaderProgram;
43 class TLP_GL_SCOPE AbstractGlCurve :
public GlSimpleEntity {
47 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
49 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode,
const std::vector<Coord> &controlPoints,
50 const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints);
52 virtual ~AbstractGlCurve();
54 void draw(
float lod, Camera *camera);
56 void translate(
const Coord &move);
58 virtual void setTexture(
const std::string &texture) {
59 this->texture = texture;
62 virtual void setOutlined(
const bool outlined) {
63 this->outlined = outlined;
66 virtual void setOutlineColor(
const Color &outlineColor) {
67 this->outlineColor = outlineColor;
74 virtual void setOutlineColorInterpolation(
const bool outlineColorInterpolation) {
75 this->outlineColorInterpolation = outlineColorInterpolation;
81 void setLineCurve(
const bool lineCurve) {
82 this->lineCurve = lineCurve;
85 void setCurveLineWidth(
const float curveLineWidth) {
86 this->curveLineWidth = curveLineWidth;
89 void setCurveQuadBordersWidth(
const float curveQuadBorderWidth) {
90 this->curveQuadBordersWidth = curveQuadBorderWidth;
93 virtual void setBillboardCurve(
const bool billboardCurve) {
94 this->billboardCurve = billboardCurve;
97 virtual void setLookDir(
const Coord &lookDir) {
98 this->lookDir = lookDir;
101 void getXML(std::string &);
103 void setWithXML(
const std::string &,
unsigned int &);
105 virtual void drawCurve(std::vector<Coord> &controlPoints,
const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints=100);
109 virtual void setCurveVertexShaderRenderingSpecificParameters() {}
111 virtual void cleanupAfterCurveVertexShaderRendering() {}
113 virtual Coord computeCurvePointOnCPU(
const std::vector<Coord> &controlPoints,
float t) = 0;
115 virtual void computeCurvePointsOnCPU(
const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints,
unsigned int nbCurvePoints) = 0;
117 static void buildCurveVertexBuffers(
const unsigned int nbCurvePoints,
bool vboOk);
119 void initShader(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
121 static std::map<unsigned int, GLfloat *> curveVertexBuffersData;
122 static std::map<unsigned int, std::vector<GLushort *> > curveVertexBuffersIndices;
123 static std::map<unsigned int, GLuint* > curveVertexBuffersObject;
124 static std::map<std::string, GlShaderProgram *> curvesShadersMap;
125 static std::map<std::string, GlShaderProgram *> curvesBillboardShadersMap;
126 static GlShader *curveVertexShaderNormalMain;
127 static GlShader *curveVertexShaderBillboardMain;
128 static GlShader *fisheyeDistortionVertexShader;
129 static GlShader *curveFragmentShader;
130 static bool canUseGeometryShader;
131 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesGeometryShadersMap;
132 static GlShader *curveVertexGeometryShaderNormalMain;
133 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesBillboardGeometryShadersMap;
135 std::string shaderProgramName;
136 GlShaderProgram *curveShaderProgramNormal;
137 GlShaderProgram *curveShaderProgramBillboard;
138 GlShaderProgram *curveShaderProgram;
141 std::vector<Coord> controlPoints;
146 unsigned int nbCurvePoints;
150 float texCoordFactor;
154 float curveLineWidth;
155 float curveQuadBordersWidth;
156 bool outlineColorInterpolation;