55#include <ACG/GL/acg_glew.hh>
56#include "PointNode.hh"
57#include <ACG/GL/IRenderer.hh>
72 ConstPointIter p_it=points_.begin(), p_end=points_.end();
73 for (; p_it!=p_end; ++p_it) {
109 glDrawArrays(GL_POINTS, 0,
int(points_.size()));
116 if (points_.size() == normals_.size())
123 glDrawArrays(GL_POINTS, 0,
int(points_.size()));
131 if (points_.size() == colors_.size())
138 glDrawArrays(GL_POINTS, 0,
int(points_.size()));
140 std::cerr <<
"Mismatch size!" << std::endl;
154 if (!vbo_needs_update_)
158 glGenBuffers(1, &vbo_);
165 size_t elem_size = 3;
166 if (!normals_.empty())
168 assert(normals_.size() == points_.size());
172 if (!colors_.empty())
174 assert(colors_.size() == points_.size());
181 vbo_data_.reserve(elem_size * points_.size());
183 for (
size_t i=0; i < points_.size(); ++i) {
184 vbo_data_.push_back(
static_cast<float>(points_[i][0]));
185 vbo_data_.push_back(
static_cast<float>(points_[i][1]));
186 vbo_data_.push_back(
static_cast<float>(points_[i][2]));
187 if (!normals_.empty()) {
188 vbo_data_.push_back(
static_cast<float>(normals_[i][0]));
189 vbo_data_.push_back(
static_cast<float>(normals_[i][1]));
190 vbo_data_.push_back(
static_cast<float>(normals_[i][2]));
192 if (!colors_.empty()) {
193 vbo_data_.push_back(colors_[i][0]);
194 vbo_data_.push_back(colors_[i][1]);
195 vbo_data_.push_back(colors_[i][2]);
196 vbo_data_.push_back(colors_[i][3]);
199 assert(vbo_data_.size() == points_.size() * elem_size);
201 glBindBuffer(GL_ARRAY_BUFFER, vbo_);
202 glBufferData(GL_ARRAY_BUFFER, vbo_data_.size()*
sizeof(
float) , vbo_data_.data() , GL_STATIC_DRAW);
203 glBindBuffer(GL_ARRAY_BUFFER, 0);
204 vbo_needs_update_ =
false;
217 ro.debugName =
"PointNode";
222 for (
unsigned int i = 0; i < _drawMode.
getNumLayers(); ++i)
226 if (props->primitive() == DrawModes::PRIMITIVE_POINT)
230 ro.setMaterial(_mat);
235 ro.depthWrite =
true;
240 geomTemplate +=
"PointSize/geometry.tpl";
243 fragTemplate +=
"PointSize/fragment.tpl";
245 ro.
shaderDesc.geometryTemplateFile = geomTemplate;
246 ro.
shaderDesc.fragmentTemplateFile = fragTemplate;
252 ro.glDrawArrays(GL_POINTS, 0, (GLsizei)points_.size());
static void disableClientState(GLenum _cap)
replaces glDisableClientState, supports locking
static void colorPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glColorPointer, supports locking
static void vertexPointer(GLint _size, GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glVertexPointer, supports locking
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
static void normalPointer(GLenum _type, GLsizei _stride, const GLvoid *_pointer)
replaces glNormalPointer, supports locking
static void enableClientState(GLenum _cap)
replaces glEnableClientState, supports locking
int viewport_width() const
get viewport width
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
int viewport_height() const
get viewport height
virtual void addRenderObject(RenderObject *_renderObject)
Callback for the scenegraph nodes, which send new render objects via this function.
DrawModeProperties stores a set of properties that defines, how to render an object.
const DrawModeProperties * getLayer(unsigned int _i) const
returns the property set at layer i
size_t getNumLayers() const
returns the layer count
void pointSize(float _sz)
set point size (default: 1.0)
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
draw points and normals
void getRenderObjects(IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) override
draw points and normals via renderer plugin
static QString getShaderDir()
void addElement(const VertexElement *_pElement)
void setVertexStride(unsigned int _stride)
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
DrawMode POINTS_COLORED
draw colored, but not lighted points (requires point colors)
DrawMode POINTS
draw unlighted points using the default base color
DrawMode POINTS_SHADED
draw shaded points (requires point normals)
Namespace providing different geometric functions concerning angles.
VectorT< float, 2 > Vec2f
@ VERTEX_USAGE_NORMAL
"inNormal"
@ VERTEX_USAGE_COLOR
"inColor"
@ VERTEX_USAGE_POSITION
"inPosition"
Interface class between scenegraph and renderer.
ShaderGenDesc shaderDesc
Drawmode and other shader params.
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
void setupShaderGenFromDrawmode(const SceneGraph::DrawModes::DrawModeProperties *_props)
Fills out ShaderGenDesc parameters based on Drawmode properties.
int priority
Priority to allow sorting of objects.
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
void setUniform(const char *_name, GLint _value)
set values for int uniforms
void initFromState(GLState *_glState)
Initializes a RenderObject instance.
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..