Commit de44d2ff authored by Pierre Kraemer's avatar Pierre Kraemer

update PointSprite shader + change selected points rendering in surface deformation plugin

parent 7893575b
......@@ -114,6 +114,7 @@ void Viewer::cb_initGL()
m_pointSprite = new Utils::PointSprite() ;
m_pointSprite->setAttributePosition(m_positionVBO) ;
m_pointSprite->setColor(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)) ;
registerShader(m_phongShader) ;
registerShader(m_flatShader) ;
......@@ -126,11 +127,8 @@ void Viewer::cb_redraw()
{
if(m_drawVertices)
{
float size = vertexScaleFactor ;
m_pointSprite->setSize(size) ;
m_pointSprite->predraw(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)) ;
m_pointSprite->setSize(vertexScaleFactor) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
m_pointSprite->postdraw() ;
}
if(m_drawEdges)
......
......@@ -129,6 +129,7 @@ void MyQT::cb_initGL()
m_sprite = new Utils::PointSprite();
m_sprite->setAttributePosition(m_positionVBO);
m_sprite->setColor(Geom::Vec4f(1.0f, 0.0f , 0.0f, 1.0f));
m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f));
storeVerticesInfo();
......@@ -200,9 +201,7 @@ void MyQT::cb_redraw()
if (render_balls)
{
m_sprite->predraw(Geom::Vec4f(1.0f, 0.0f , 0.0f, 1.0f));
m_render->draw(m_sprite, Algo::Render::GL2::POINTS);
m_sprite->postdraw();
}
if (render_vectors)
......
......@@ -99,9 +99,8 @@ void RenderPlugin::redraw(View* view)
{
m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * p->verticesScaleFactor);
m_pointSprite->setAttributePosition(p->positionVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
m->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
m_pointSprite->postdraw();
}
if(p->renderEdges)
{
......
#ifndef _SURFACEDEFORMATION_PLUGIN_H_
#define _SURFACEDEFORMATION_PLUGIN_H_
#include "Utils/drawer.h"
#include "plugin.h"
#include "surfaceDeformationDockTab.h"
......@@ -45,8 +43,11 @@ struct PerMapParameterSet
CellMarker<VERTEX>* lockingMarker;
CellMarker<VERTEX>* handleMarker;
SelectionMode verticesSelectionMode;
std::vector<unsigned int> locked_vertices;
std::vector<unsigned int> handle_vertices;
std::vector<PFP2::VEC3> lockedVertices;
std::vector<PFP2::VEC3> handleVertices;
std::vector<unsigned int> handleVerticesId;
Utils::VBO* lockedVerticesVBO;
Utils::VBO* handleVerticesVBO;
VertexAttribute<PFP2::VEC3> positionInit;
VertexAttribute<PFP2::VEC3> vertexNormal;
......@@ -113,7 +114,6 @@ protected:
QHash<View*, ParameterSet*> h_viewParams;
Utils::PointSprite* m_pointSprite;
Utils::Drawer* m_drawer;
Utils::VBO* selectionSphereVBO;
......
......@@ -39,6 +39,9 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
lockingMarker = new CellMarker<VERTEX>(*map);
handleMarker = new CellMarker<VERTEX>(*map);
lockedVerticesVBO = new Utils::VBO();
handleVerticesVBO = new Utils::VBO();
positionInit = mh->getAttribute<PFP2::VEC3, VERTEX>("positionInit", false) ;
if(!positionInit.isValid())
positionInit = mh->addAttribute<PFP2::VEC3, VERTEX>("positionInit", false) ;
......@@ -74,6 +77,8 @@ PerMapParameterSet::~PerMapParameterSet()
{
delete lockingMarker;
delete handleMarker;
delete lockedVerticesVBO;
delete handleVerticesVBO;
nlDeleteContext(nlContext);
}
......@@ -115,9 +120,6 @@ bool SurfaceDeformationPlugin::enable()
m_pointSprite = new CGoGN::Utils::PointSprite();
registerShader(m_pointSprite);
m_drawer = new Utils::Drawer();
registerShader(m_drawer->getShader());
connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*)));
connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(viewUnlinked(View*, Plugin*)));
connect(m_window, SIGNAL(currentViewChanged(View*)), this, SLOT(currentViewChanged(View*)));
......@@ -128,20 +130,54 @@ bool SurfaceDeformationPlugin::enable()
void SurfaceDeformationPlugin::disable()
{
delete m_pointSprite;
delete m_drawer;
}
void SurfaceDeformationPlugin::redraw(View* view)
{
ParameterSet* params = h_viewParams[view];
MapHandlerGen* mh = params->selectedMap;
if(mh)
{
PerMapParameterSet* perMap = params->perMap[mh->getName()];
if(!perMap->lockedVertices.empty() || !perMap->handleVertices.empty())
{
m_pointSprite->setAttributePosition(perMap->lockedVerticesVBO);
m_pointSprite->setSize(mh->getBBdiagSize() / 250.0f);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 0.75f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_POINTS, 0, perMap->lockedVertices.size());
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
m_pointSprite->setAttributePosition(perMap->handleVerticesVBO);
m_pointSprite->setSize(mh->getBBdiagSize() / 250.0f);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 1.0f, 0.0f, 0.75f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDrawArrays(GL_POINTS, 0, perMap->handleVertices.size());
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
}
}
if(selecting)
{
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(selectionCenter);
selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setSize(selectionRadius);
m_pointSprite->setAttributePosition(selectionSphereVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f));
m_pointSprite->setSize(selectionRadius);
m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f));
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glEnable(GL_BLEND);
......@@ -149,34 +185,6 @@ void SurfaceDeformationPlugin::redraw(View* view)
glDrawArrays(GL_POINTS, 0, 1);
glDisable(GL_BLEND);
m_pointSprite->disableVertexAttribs();
m_pointSprite->postdraw();
}
ParameterSet* params = h_viewParams[view];
MapHandlerGen* mh = params->selectedMap;
if(mh)
{
PerMapParameterSet* perMap = params->perMap[mh->getName()];
if(!perMap->locked_vertices.empty() || !perMap->handle_vertices.empty())
{
glDisable(GL_LIGHTING) ;
m_drawer->newList(GL_COMPILE_AND_EXECUTE) ;
m_drawer->pointSize(4.0f) ;
m_drawer->begin(GL_POINTS) ;
m_drawer->color3f(1.0f, 0.0f, 0.0f) ;
for(unsigned int i = 0; i < perMap->locked_vertices.size(); ++i)
{
if (!perMap->handleMarker->isMarked(perMap->locked_vertices[i]))
m_drawer->vertex(perMap->positionAttribute[perMap->locked_vertices[i]]) ;
}
m_drawer->color3f(0.0f, 0.0f, 1.0f) ;
for(unsigned int i = 0; i < perMap->handle_vertices.size(); ++i)
m_drawer->vertex(perMap->positionAttribute[perMap->handle_vertices[i]]) ;
m_drawer->end() ;
m_drawer->endList() ;
}
}
}
......@@ -229,29 +237,31 @@ void SurfaceDeformationPlugin::mousePress(View* view, QMouseEvent* event)
PFP2::VEC3 rayA(orig.x, orig.y, orig.z);
PFP2::VEC3 AB(dir.x, dir.y, dir.z);
Dart d ;
Dart d;
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(params->selectedMap)->getMap();
Algo::Selection::vertexRaySelection<PFP2>(*map, perMap->positionAttribute, rayA, AB, d) ;
Algo::Selection::vertexRaySelection<PFP2>(*map, perMap->positionAttribute, rayA, AB, d);
if(d != NIL)
{
Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, perMap->positionAttribute, selectionRadius) ;
neigh.collectAll(d) ;
const std::vector<Dart>& insideV = neigh.getInsideVertices() ;
Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, perMap->positionAttribute, selectionRadius);
neigh.collectAll(d);
const std::vector<Dart>& insideV = neigh.getInsideVertices();
for(unsigned int i = 0; i < insideV.size(); ++i)
{
unsigned int v = map->getEmbedding<VERTEX>(insideV[i]) ;
unsigned int v = map->getEmbedding<VERTEX>(insideV[i]);
if (!perMap->lockingMarker->isMarked(v))
{
perMap->locked_vertices.push_back(v) ;
if(perMap->verticesSelectionMode == LOCKED)
perMap->lockedVertices.push_back(perMap->positionAttribute[v]);
perMap->lockingMarker->mark(v);
}
if(perMap->verticesSelectionMode == HANDLE)
{
if(!perMap->handleMarker->isMarked(v))
{
perMap->handle_vertices.push_back(v) ;
perMap->handleVertices.push_back(perMap->positionAttribute[v]);
perMap->handleVerticesId.push_back(v);
perMap->handleMarker->mark(v);
}
}
......@@ -260,6 +270,10 @@ void SurfaceDeformationPlugin::mousePress(View* view, QMouseEvent* event)
nlMakeCurrent(perMap->nlContext) ;
nlReset(NL_FALSE) ;
perMap->lockedVerticesVBO->updateData(perMap->lockedVertices);
if(perMap->verticesSelectionMode == HANDLE)
perMap->handleVerticesVBO->updateData(perMap->handleVertices);
view->updateGL() ;
}
}
......@@ -277,13 +291,13 @@ void SurfaceDeformationPlugin::mousePress(View* view, QMouseEvent* event)
dragging = true ;
dragZ = 0;
for(unsigned int i = 0; i < perMap->handle_vertices.size(); ++i)
for(unsigned int i = 0; i < perMap->handleVertices.size(); ++i)
{
const PFP2::VEC3& p = perMap->positionAttribute[perMap->handle_vertices[i]] ;
const PFP2::VEC3& p = perMap->handleVertices[i] ;
qglviewer::Vec q = view->camera()->projectedCoordinatesOf(qglviewer::Vec(p[0],p[1],p[2]));
dragZ += q.z ;
}
dragZ /= perMap->handle_vertices.size() ;
dragZ /= perMap->handleVertices.size() ;
qglviewer::Vec p(event->x(), event->y(), dragZ);
dragPrevious = view->camera()->unprojectedCoordinatesOf(p);
......@@ -294,9 +308,7 @@ void SurfaceDeformationPlugin::mousePress(View* view, QMouseEvent* event)
void SurfaceDeformationPlugin::mouseRelease(View* view, QMouseEvent* event)
{
if(event->button() == Qt::RightButton)
{
dragging = false ;
}
dragging = false;
}
void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
......@@ -313,10 +325,14 @@ void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
qglviewer::Vec vec = q - dragPrevious;
PFP2::VEC3 t(vec.x, vec.y, vec.z);
for(unsigned int i = 0; i < perMap->handle_vertices.size(); ++i)
perMap->positionAttribute[perMap->handle_vertices[i]] += t ;
for(unsigned int i = 0; i < perMap->handleVertices.size(); ++i)
{
perMap->handleVertices[i] += t;
perMap->positionAttribute[perMap->handleVerticesId[i]] += t;
}
perMap->handleVerticesVBO->updateData(perMap->handleVertices);
dragPrevious = q ;
dragPrevious = q;
// matchDiffCoord(view, map);
asRigidAsPossible(view, params->selectedMap);
......@@ -335,13 +351,13 @@ void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
PFP2::VEC3 rayA(orig.x, orig.y, orig.z);
PFP2::VEC3 AB(dir.x, dir.y, dir.z);
Dart d ;
Dart d;
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(params->selectedMap)->getMap();
Algo::Selection::vertexRaySelection<PFP2>(*map, perMap->positionAttribute, rayA, AB, d) ;
Algo::Selection::vertexRaySelection<PFP2>(*map, perMap->positionAttribute, rayA, AB, d);
if(d != NIL)
{
selectionCenter = perMap->positionAttribute[d] ;
view->updateGL() ;
selectionCenter = perMap->positionAttribute[d];
view->updateGL();
}
}
}
......
......@@ -46,13 +46,13 @@ protected:
CGoGNGLuint m_uniform_maxValue;
CGoGNGLuint m_uniform_expansion;
VBO* m_vboPos;
VBO* m_vboScal;
float m_minValue;
float m_maxValue;
int m_expansion;
VBO* m_vboPos;
VBO* m_vboScal;
void getLocations();
void sendParams();
......
......@@ -4,15 +4,16 @@ uniform mat4 ProjectionMatrix;
uniform vec3 lightPos;
uniform vec3 ambiant;
uniform float size;
#ifdef WITH_PLANE
uniform vec3 eyePos;
VARYING_FRAG vec3 shiftedEye;
uniform vec3 eyePos;
VARYING_FRAG vec3 shiftedEye;
#endif
#ifdef WITH_COLOR_PER_VERTEX
VARYING_FRAG vec3 colorsprite;
VARYING_FRAG vec4 colorsprite;
#else
uniform vec4 colorsprite;
uniform vec4 colorsprite;
#endif
VARYING_FRAG vec2 spriteCoord;
......@@ -43,7 +44,6 @@ void main(void)
vec3 frag_position_eye = ray_direction * t ;
#endif
vec4 pos = ProjectionMatrix * vec4(frag_position_eye, 1.0);
gl_FragDepth = (pos.z / pos.w + 1.0) / 2.0;
......
......@@ -3,40 +3,40 @@
uniform float size;
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
#ifdef WITH_PLANE
uniform vec3 eyePos;
VARYING_OUT vec3 shiftedEye;
uniform vec3 eyePos;
VARYING_OUT vec3 shiftedEye;
#endif
VARYING_OUT vec2 spriteCoord;
VARYING_OUT vec3 sphereCenter;
#ifdef WITH_COLOR_PER_VERTEX
VARYING_IN vec3 color[1];
VARYING_OUT vec3 colorsprite;
VARYING_IN vec4 color[1];
VARYING_OUT vec4 colorsprite;
#endif
#ifdef WITH_PLANE
void corner( vec4 center, vec3 planeX, vec3 planeY, float x, float y)
{
spriteCoord = vec2(x,y);
vec4 pos = center + size*( x*vec4(planeX,0.0) + y*vec4(planeY,0.0)+ vec4(0.0,0.0,0.5,0.0));
gl_Position = ProjectionMatrix * pos;
EmitVertex();
}
void corner( vec4 center, vec3 planeX, vec3 planeY, float x, float y)
{
spriteCoord = vec2(x,y);
vec4 pos = center + size*( x*vec4(planeX,0.0) + y*vec4(planeY,0.0)+ vec4(0.0,0.0,0.5,0.0));
gl_Position = ProjectionMatrix * pos;
EmitVertex();
}
#else
void corner( vec4 center, float x, float y)
{
spriteCoord = vec2(x,y);
vec4 pos = center + vec4(size*x, size*y, 0.0, 0.0);
gl_Position = ProjectionMatrix * pos;
EmitVertex();
}
void corner( vec4 center, float x, float y)
{
spriteCoord = vec2(x,y);
vec4 pos = center + vec4(size*x, size*y, 0.0, 0.0);
gl_Position = ProjectionMatrix * pos;
EmitVertex();
}
#endif
void main()
{
#ifdef WITH_COLOR_PER_VERTEX
colorsprite = color[0];
#endif
......@@ -63,6 +63,7 @@ void main()
corner(posCenter, 1.4, 1.4);
corner(posCenter, 1.4,-1.4);
#endif
EndPrimitive();
}
......@@ -36,100 +36,66 @@ namespace CGoGN
namespace Utils
{
class PointSprite: public Utils::GLSLShader
class PointSprite : public Utils::GLSLShader
{
protected:
static const unsigned int WIDTHSPRITE = 64;
static std::string vertexShaderText;
static std::string geometryShaderText;
static std::string fragmentShaderText;
static unsigned char* m_ptrSphere;
static PointSprite* m_instance0;
// compute the sphere instead of storing it in image file.
static void computeSphere();
bool colorPerVertex;
bool plane;
CGoGNGLuint m_uniform_size;
CGoGNGLuint m_uniform_color;
CGoGNGLuint m_idTexture;
CGoGNGLuint m_uniform_texture;
CGoGNGLuint m_uniform_EyePos;
// CGoGNGLuint m_uniform_EyeY;
CGoGNGLuint m_uniform_ambiant;
CGoGNGLuint m_uniform_lightPos;
CGoGNGLuint m_uniform_eyePos;
public:
/**
* init shaders, texture and variables
* @param withColorPerVertex if true use setAttributeColor for per vertex color, else use predraw(color) for global color
* @param radius of sphere
*/
PointSprite(bool withColorPerVertex=false, float radius=1.0f, bool with_plane=false);
VBO* m_vboPos;
VBO* m_vboColor;
/**
* clean shaders, texture and variables
*/
~PointSprite();
float m_size;
Geom::Vec4f m_color;
Geom::Vec3f m_lightPos;
Geom::Vec3f m_ambiant;
Geom::Vec3f m_eyePos;
/**
* call once before sending points to gpu
* @param color set global color of sprites
*/
void predraw(const Geom::Vec4f& color);
void getLocations();
/**
* call once before sending points to gpu
*/
void predraw();
void sendParams();
/**
* call once after sending points to gpu
*/
void postdraw();
void restoreUniformsAttribs();
public:
/**
* set the radius of sphere
* @param radius
* init shaders & variables
* @param withColorPerVertex if true use setAttributeColor for per vertex color, else use setColor(color) for global color
* @param withPlane
*/
void setSize(float radius);
/**
* set the plane of rendering for VR rendering
*/
void setEyePosition(const Geom::Vec3f& ep);
PointSprite(bool withColorPerVertex = false, bool withPlane = false);
/**
* set position attribute
*/
unsigned int setAttributePosition(VBO* vbo);
/**
* set color attribute
*/
unsigned int setAttributeColor(VBO* vbo);
void setSize(float size);
void setColor(const Geom::Vec4f& color);
void setLightPosition(const Geom::Vec3f& pos);
void setAmbiantColor(const Geom::Vec3f& amb);
/**
* set the plane of rendering for VR rendering
*/
void setEyePosition(const Geom::Vec3f& ep);
};
} // namespace Utils
} // namespace CGoGN
#endif
......@@ -2,14 +2,14 @@
ATTRIBUTE vec3 VertexPosition;
#ifdef WITH_COLOR_PER_VERTEX
ATTRIBUTE vec3 VertexColor;
VARYING_VERT vec3 color;
ATTRIBUTE vec4 VertexColor;
VARYING_VERT vec4 color;
#endif
void main ()
{
gl_Position = vec4(VertexPosition,1.0);
gl_Position = vec4(VertexPosition, 1.0);
#ifdef WITH_COLOR_PER_VERTEX
color = VertexColor; //VertexColor;
color = VertexColor;
#endif
}
......@@ -33,12 +33,11 @@ namespace Utils
#include "shaderScalarField.vert"
#include "shaderScalarField.frag"
ShaderScalarField::ShaderScalarField()
ShaderScalarField::ShaderScalarField() :
m_minValue(0.0f),
m_maxValue(0.0f),
m_expansion(0)
{
m_nameVS = "ShaderColorPerVertex_vs";
m_nameFS = "ShaderColorPerVertex_fs";
m_nameGS = "ShaderColorPerVertex_gs";
std::string glxvert(*GLSLShader::DEFINES_GL);
glxvert.append(vertexShaderText);
......@@ -90,30 +89,33 @@ unsigned int ShaderScalarField::setAttributeScalar(VBO* vbo)
void ShaderScalarField::setMinValue(float f)
{
m_minValue = f;
bind();
glUniform1f(*m_uniform_minValue, f);
m_minValue = f;
unbind();
}
void ShaderScalarField::setMaxValue(float f)
{
m_maxValue = f;
bind();
glUniform1f(*m_uniform_maxValue, f);
m_maxValue = f;
unbind();
}
void ShaderScalarField::setExpansion(int f)
{
m_expansion = f;
bind();
glUniform1i(*m_uniform_expansion, f);
m_expansion = f;
unbind();
}
void ShaderScalarField::restoreUniformsAttribs()
{
getLocations();
sendParams();
bind();
bindVA_VBO("VertexPosition", m_vboPos);
bindVA_VBO("VertexScalar", m_vboScal);
......
......@@ -34,192 +34,147 @@ namespace Utils
#include "pointSprite.frag"
#include "pointSprite.geom"
unsigned char* PointSprite::m_ptrSphere = NULL;
PointSprite* PointSprite::m_instance0 = NULL;
PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane)
PointSprite::PointSprite(bool withColorPerVertex, bool withPlane) :
colorPerVertex(withColorPerVertex),
plane(withPlane),
m_size(1.0f),
m_color(Geom::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)),
m_lightPos(Geom::Vec3f(100.0f, 100.0f, 100.0f)),
m_ambiant(Geom::Vec3f(0.1f, 0.1f, 0.1f)),
m_eyePos(Geom::Vec3f(0.0f, 0.0f, 0.0f))
{
std::string defineColor("#define WITH_COLOR_PER_VERTEX 1\n");
std::string glxvert(*GLSLShader::DEFINES_GL);
if (withColorPervertex)
glxvert.append(defineColor);
if (withColorPerVertex)
glxvert.append("#define WITH_COLOR_PER_VERTEX 1\n");
glxvert.append(vertexShaderText);
std::string glxgeom = GLSLShader::defines_Geom("points","triangle_strip",4);
if (withColorPervertex)
glxgeom.append(defineColor);
if (with_plane)
std::string glxgeom = GLSLShader::defines_Geom("points", "triangle_strip", 4);
if (withColorPerVertex)
glxgeom.append("#define WITH_COLOR_PER_VERTEX 1\n");
if (withPlane)
glxgeom.append("#define WITH_PLANE 1\n");
glxgeom.append(geometryShaderText);
std::string glxfrag(*GLSLShader::DEFINES_GL);
if (withColorPervertex)
glxfrag.append(defineColor);
if (with_plane)
if (withColorPerVertex)
glxfrag.append("#define WITH_COLOR_PER_VERTEX 1\n");
if (withPlane)
glxfrag.append("#define WITH_PLANE 1\n");
glxfrag.append(fragmentShaderText);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_POINTS, GL_TRIANGLE_STRIP,4);
loadShadersFromMemory(glxvert.c_str(), glxfrag.c_str(), glxgeom.c_str(), GL_POINTS, GL_TRIANGLE_STRIP, 4);
// get and fill uniforms
getLocations();
sendParams();
}
void PointSprite::getLocations()
{
bind();
*m_uniform_size = glGetUniformLocation(program_handler(),"size");
*m_uniform_color = glGetUniformLocation(program_handler(),"colorsprite");
glUniform1f(*m_uniform_size, radius);
unbind();
// load texture
if (m_ptrSphere == NULL)
{
computeSphere();
m_instance0 = this;
glGenTextures(1, &(*m_idTexture));
glBindTexture(GL_TEXTURE_2D, *m_idTexture);
glTexImage2D(GL_TEXTURE_2D, 0,