Hey all
I’m trying to draw a point cloud but I cant find a method to draw points
is there anything efficient out there or do i have to use ofRect with width=0 or 1?
be nice if there was a point drawmode for ofVertex. something like that exists?
thanks
elliot
edit: see Arturo’s post below
Right now this is just done with straight up OpenGL:
glBegin(GL_POINTS);
glVertex2f(x, y);
glVertex2f(x, y);
...
glEnd();
There is some talk of extending ofBeginShape to work more like Processing’s beginShape, but right now the more basic things are just handled with OpenGL.
cheers
that’s pretty elegant anyway
you the kyle who did the talk at madlab a couple of weeks back over skype?
arturo
March 20, 2010, 7:57pm
#5
indeed you need to use ofBeginShape() and ofEndShape()
in previous versions glBegin/End would work but since 006 that’s internally using a vertex array so the gl functions won’t work.
so:
ofBeginShape(GL_POINTS);
ofVertex(x, y);
ofVertex(x, y);
...
ofEndShape();
ofPushStyle();
ofSetColor(0,0,255);
glBegin(GL_POINTS);
for (int iMarker=0; iMarker < _nMarkers; iMarker++)
{
xMarker = (*_markers)[iMarker].x * width + x;
yMarker = (*_markers)[iMarker].y * height + y;
ofVertex(xMarker, yMarker);
}
glEnd();
ofPopStyle();
doesn’t seem to draw anything
but
ofPushStyle();
ofNoFill();
ofSetColor(0,0,255);
for (int iMarker=0; iMarker < _nMarkers; iMarker++)
{
xMarker = (*_markers)[iMarker].x * width + x;
yMarker = (*_markers)[iMarker].y * height + y;
ofRect(xMarker, yMarker, 1, 1);
}
ofPopStyle();
and
ofPushStyle();
ofNoFill();
ofSetColor(0,0,255);
ofBeginShape();
for (int iMarker=0; iMarker < _nMarkers; iMarker++)
{
xMarker = (*_markers)[iMarker].x * width + x;
yMarker = (*_markers)[iMarker].y * height + y;
ofVertex(xMarker, yMarker);
}
ofEndShape(false);
ofPopStyle();
do
…
i’ve missed a trick?
Ah, nice. That’s great to hear.
If I understand correctly, it’s not that glBegin/glEnd won’t work, it’s just that you can’t mix it with ofVertex?
So these are both ok:
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
ofBeginShape(GL_POINTS);
ofVertex(x, y);
ofEndShape();
But these aren’t:
glBegin(GL_POINTS);
ofVertex(x, y);
glEnd();
ofBeginShape(GL_POINTS);
glVertex2f(x, y);
ofEndShape();
wow
2 replies whilst i posted that message
anyway…
i’m using 006 but i get a too many argument error with
ofBeginShape(GL_POINTS);
is it 0061?
glBegin(GL_POINTS);
for (int iMarker=0; iMarker < _nMarkers; iMarker++)
{
xMarker = (*_markers)[iMarker].x * width + x;
yMarker = (*_markers)[iMarker].y * height + y;
glVertex2f(xMarker, yMarker);
}
glEnd();
is working great
arturo
March 20, 2010, 8:15pm
#9
oh yes, its:
ofSetPolyMode(GL_POINTS);
ofBeginShape();
ofVertex(x, y);
ofEndShape();
kyle: yes, both will work, is just glBegin/End dowsn’t exist anymore in opengl es and are deprecated in opengl 3. also vertex arrays are faster.
Hmm, as I don’t normally draw polys, ofSetPolyMode is a bit weird to me. That’s be great if it could get moved into the ofBeginShape call.
arturo
March 20, 2010, 8:28pm
#11
oh sorry is not even that, polymode is for the winding, being OF_POLY_WINDING_ODD the default.
you need to use opengl calls to specify GL_POINTS