21 #ifndef ABSTRACTGLCURVE_H
22 #define ABSTRACTGLCURVE_H
28 #if defined(__APPLE__)
29 #include <OpenGL/gl.h>
30 #include <OpenGL/glu.h>
34 # if defined(__WIN32__)
35 # include <GL/glext.h>
39 #include <tulip/GlSimpleEntity.h>
40 #include <tulip/Color.h>
44 class GlShaderProgram;
47 class TLP_GL_SCOPE AbstractGlCurve :
public GlSimpleEntity {
51 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
53 AbstractGlCurve(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode,
const std::vector<Coord> &controlPoints,
54 const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints);
56 virtual ~AbstractGlCurve();
58 void draw(
float lod, Camera *camera);
60 void translate(
const Coord &move);
62 virtual void setTexture(
const std::string &texture) {
63 this->texture = texture;
66 virtual void setOutlined(
const bool outlined) {
67 this->outlined = outlined;
70 virtual void setOutlineColor(
const Color &outlineColor) {
71 this->outlineColor = outlineColor;
78 virtual void setOutlineColorInterpolation(
const bool outlineColorInterpolation) {
79 this->outlineColorInterpolation = outlineColorInterpolation;
85 void setLineCurve(
const bool lineCurve) {
86 this->lineCurve = lineCurve;
89 void setCurveLineWidth(
const float curveLineWidth) {
90 this->curveLineWidth = curveLineWidth;
93 void setCurveQuadBordersWidth(
const float curveQuadBorderWidth) {
94 this->curveQuadBordersWidth = curveQuadBorderWidth;
97 virtual void setBillboardCurve(
const bool billboardCurve) {
98 this->billboardCurve = billboardCurve;
101 virtual void setLookDir(
const Coord &lookDir) {
102 this->lookDir = lookDir;
105 void getXML(std::string &);
107 void setWithXML(
const std::string &,
unsigned int &);
109 virtual void drawCurve(std::vector<Coord> &controlPoints,
const Color &startColor,
const Color &endColor,
const float startSize,
const float endSize,
const unsigned int nbCurvePoints=100);
113 virtual void setCurveVertexShaderRenderingSpecificParameters() {}
115 virtual void cleanupAfterCurveVertexShaderRendering() {}
117 virtual Coord computeCurvePointOnCPU(
const std::vector<Coord> &controlPoints,
float t) = 0;
119 virtual void computeCurvePointsOnCPU(
const std::vector<Coord> &controlPoints, std::vector<Coord> &curvePoints,
unsigned int nbCurvePoints) = 0;
121 static void buildCurveVertexBuffers(
const unsigned int nbCurvePoints,
bool vboOk);
123 void initShader(
const std::string &shaderProgramName,
const std::string &curveSpecificShaderCode);
125 static std::map<unsigned int, GLfloat *> curveVertexBuffersData;
126 static std::map<unsigned int, std::vector<GLushort *> > curveVertexBuffersIndices;
127 static std::map<unsigned int, GLuint* > curveVertexBuffersObject;
128 static std::map<std::string, GlShaderProgram *> curvesShadersMap;
129 static std::map<std::string, GlShaderProgram *> curvesBillboardShadersMap;
130 static GlShader *curveVertexShaderNormalMain;
131 static GlShader *curveVertexShaderBillboardMain;
132 static GlShader *fisheyeDistortionVertexShader;
133 static bool canUseGeometryShader;
134 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesGeometryShadersMap;
135 static GlShader *curveVertexGeometryShaderNormalMain;
136 static std::map<std::string, std::pair<GlShaderProgram *, GlShaderProgram *> > curvesBillboardGeometryShadersMap;
138 std::string shaderProgramName;
139 GlShaderProgram *curveShaderProgramNormal;
140 GlShaderProgram *curveShaderProgramBillboard;
141 GlShaderProgram *curveShaderProgram;
144 std::vector<Coord> controlPoints;
149 unsigned int nbCurvePoints;
153 float texCoordFactor;
157 float curveLineWidth;
158 float curveQuadBordersWidth;
159 bool outlineColorInterpolation;