Hi, Jason

I generally agree with your post that binding per primitive is a scene graph thing, but I would disagree with such BIND_PER_PRIMITIVE interpretation:

BIND_PER_PRIMITIVE is a scene graph thing, it has nothing to do with pure OpenGL. All BIND_PER_PRIMITIVE means is this:
glBegin(GL_TRIANGLE_STRIP);
  glNormal3f(...);
 glVertex3f(...);
 glVertex3f(...);
   ...
  glVertex3f(...);
glEnd();

OpenGL argument against your example: you may also write similar glBegin(GL_TRIANGLE)/glEnd() code with 2 triangles and one normal. It will be correct OpenGL code. Would you say that two triangles correspond to one OSG primitive or two OSG primitves in this case ? And if you do not pass normal before second triangle, OpenGL will use last normal passed (ie the one from first triangle):

glBegin(GL_TRIANGLE);
  glNormal3f(...);
  glVertex3f(...); //1
  glVertex3f(...); //2
  glVertex3f(...); //3
 // no normal and its no error !
 glVertex3f(...); //4
 glVertex3f(...); //5
 glVertex3f(...); //6
glEnd();

In the same way OpenGL assumes that last passed normal is used for the triangle in triangle strip. Triangle Srip is just another method of passing vertices to OpenGL and each triangle may have its own unique normals/colors. If you don't agree, just do a reverse test: see if below would render both triangles with the same color or different colors. They will differ, and this is also correct OpenGL code:

glShadeModel( GL_FLAT );
glBegin(GL_TRIANGLE_STRIP);
  glColor4f( 1, 0, 0, 1 ); // RED
  glVertex3f(0, 0, 0);
  glVertex3f(0, 1, 0);
  glVertex3f(1, 0, 0);
  glColor4f( 0, 1, 0, 1 ); // GREEN
  glVertex3f(1, 1, 0);
glEnd();

Last argument is actually a postulate for OSG clarity. We have BIND_PER_PRIMITIVE_SET flag. Shouldn't this flag be rather used for the situation where we want to one normal / one color etc for all triangles in tristrip ?

Wojtek Lewandowski

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to