more general beginShape()?

Is ofBeginShape() relegated to high-level things that need tessellation, or might it also be used in the same way Processing’s beginShape() is used?

I just tried something like this:

  
  
ofBeginShape(OF_POINTS);  
for(...) {  
  ofVertex(x, y, z);  
}  
ofEndShape();  
  

And noticed that ofBeginShape() doesn’t handle any of the GL primitives, and that ofVertex isn’t overloaded for 3 arguments to wrap glVertex3f.

Is this a situation where we should just be using GL instead of expecting OF to wrap the functionality? I feel like a call like glVertex3f(x, y, z) might scare some people more than ofVertex(x, y, z) just because of the name and non-overloaded form.

Nice request!!
:slight_smile:

Right now beginShape/endShape does one of two things.

If ofNoFill is specified it just draws a line (or line loop if endShape(true) is called).
If ofFill() is specified it draws a tessellated filled shape.

Currently there is no other options to specify drawing type.

This might be something we look at in 007 as people don’t always need tessellation and it is quite an expensive process. Especially for the iphone people too as you can’t do glBegin or glEnd in OpenGL ES and working with vertex arrays can be a little off-putting for people new to openGL.

Theo

yes, totally smart…

also, having OF_POLYGON (wrap of GL_POLYGON) and OF_TESSELATE would make sense, because with polygon you can draw convex shapes without the expense of tessellation.

also, a big win would be color and or texture per vertex, and making that easy to use (as easy as in open gl). then you should be able to bind a texture and do p5 style drawing with it.

thanks for the suggestion!
zach

These ideas sound great! I’d like a really powerful beginShape() routine, too. Good point about iPhones/other platforms: to write portable code, the shape-drawing functionality would need to be wrapped.

All of these would be nice as modes for beginShape():

  
  
OF_POINTS  
OF_LINES  
OF_LINE_STRIP  
OF_LINE_LOOP  
OF_TRIANGLES  
OF_TRIANGLE_STRIP  
OF_TRIANGLE_FAN  
OF_QUADS  
OF_QUAD_STRIP  
  

And additionally, either:

  
  
OF_POLYGON  
OF_TESSALATE  
  

Or, more intuitive, and easier to explain:

  
  
OF_POLYGON_CONVEX  
OF_POLYGON  
  

Which says to me, “OF_POLYGON draws any polygon (uses tessalation) but if you want speed improvement and are drawing a convex polygon you can use OF_POLYGON_CONVEX (uses GL_POLYGON)”.

yea I also originally thought that ofVertex was a wrapper for glVertex until I saw it did all the tessellation stuff. That tess stuff is super useful for drawing concave 2D shapes, but other times it can be costly for no reason if you aren’t aware.

I have http://www.memo.tv/ofxmsashape3d which does some of the mentioned stuff I think (colors, normals, texturecoordinates etc.). And wraps it up in vertex arrays (so works on iphone too, and theoretically faster on desktop, though i haven’t seen massive differences if you are updating the vertex data everyframe anyway).

code is quite minimal:
http://code.google.com/p/ofxmsaof/sourc-…-AShape3D.h

Theoretically it accepts all those opengl polygon modes, but I haven’t tried them all.

The header is a bit hard to read, I need to separate the implementations and add them to the bottom of the header (being inline makes a huge performance difference).

the IMMEDIATE_MODE define is just to text the performance difference between immediate and vertex arrays.

I know this is a rather old post, but I wanted to mention that I also have come across this confusion. I am working on creating some general ports of openGL tutorials for OF, and found myself under the same assumption briefly… Which leads to some, IMO, “scary” looking code, mixing OF and GL function calls. I would be willing to give it a shot/help out, if someone would like to tell me proper procedure.