0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / OpenGl / OpenGl_PrimitiveArray.cxx
index 087bb80..70aa0f2 100755 (executable)
@@ -641,18 +641,34 @@ draw_array( call_def_parray p, Tint hflag,
     // OCC22236 NOTE: draw for all situations:
     // 1) draw elements from p->bufferVBO[VBOEdges] indicies array
     // 2) draw elements from vertice array, when bounds defines count of primitive's verts.
-    //end bindings
+    // 3) draw primitive by vertexes if no edges and bounds array is specified
     if(  p->flagBufferVBO == VBO_OK ){
       if ( p->num_edges > 0 && p->bufferVBO[VBOEdges] ) {
         glVBOBindBufferARB(GL_ELEMENTS_ARRAY_BUFFER_ARB, p->bufferVBO[VBOEdges]); // for edge indices
-        glDrawElements( draw_mode, p->num_edges , GL_UNSIGNED_INT, 0);
+        
+        // draw primitives by vertex count with the indicies
+        if( p->num_bounds > 0 ) {
+          Tint* offset = 0;
+          for( i = 0, offset = 0 ; i < p->num_bounds ; i++ ) {
+            glDrawElements(draw_mode, p->bounds[i], GL_UNSIGNED_INT, offset);
+            offset += p->bounds[i]; 
+          }
+        }
+        // draw one (or sequential) primitive by the indicies
+        else {
+          glDrawElements(draw_mode, p->num_edges , GL_UNSIGNED_INT, 0);
+        }
       }
-      else {
+      else if( p->num_bounds > 0 ) {
         for( i = n = 0 ; i < p->num_bounds ; i ++ ){
-          glDrawArrays( draw_mode, n, p->bounds[i]);
+          glDrawArrays(draw_mode, n, p->bounds[i]);
           n += p->bounds[i];
         }
       }
+      else {
+        glDrawArrays(draw_mode, 0, p->num_vertexs);
+      }
+
       //bind with 0
       glVBOBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 
       glVBOBindBufferARB(GL_ELEMENTS_ARRAY_BUFFER_ARB, 0); 
@@ -823,8 +839,8 @@ draw_edges ( call_def_parray p, tel_colour edge_colour )
 
   // OCC22236 NOTE: draw edges for all situations:
   // 1) draw elements with GL_LINE style as edges from p->bufferVBO[VBOEdges] indicies array
-  // 2) draw elements with GL_LINE style as edges from vertice array,
-  //    when bounds defines count of primitive's verts.
+  // 2) draw elements from vertice array, when bounds defines count of primitive's verts.
+  // 3) draw primitive's edges by vertexes if no edges and bounds array is specified
   if(p->flagBufferVBO == VBO_OK)
   { 
     glVBOBindBufferARB( GL_ARRAY_BUFFER_ARB, p->bufferVBO[VBOVertices] );
@@ -832,14 +848,31 @@ draw_edges ( call_def_parray p, tel_colour edge_colour )
     glColor3fv( edge_colour->rgb );
     if ( p->num_edges > 0 && p->bufferVBO[VBOEdges] ) {
       glVBOBindBufferARB(GL_ELEMENTS_ARRAY_BUFFER_ARB, p->bufferVBO[VBOEdges]); 
-      glDrawElements( draw_mode, p->num_edges, GL_UNSIGNED_INT, 0);
+      
+      // draw primitives by vertex count with the indicies
+      if( p->num_bounds > 0 ) {
+        Tint* offset = 0;
+        for( i = 0, offset = 0 ; i < p->num_bounds ; i++ ) {
+          glDrawElements( draw_mode, p->bounds[i], GL_UNSIGNED_INT, offset);
+          offset += p->bounds[i];
+        }
+      }
+      // draw one (or sequential) primitive by the indicies
+      else {
+        glDrawElements( draw_mode, p->num_edges , GL_UNSIGNED_INT, 0);
+      }
     }
-    else {
-      for( i = n = 0 ; i < p->num_bounds ; i ++ ) {
-        glDrawArrays( draw_mode , n , p->bounds[i]);
+    else if( p->num_bounds > 0 ) {
+      for( i = n = 0 ; i < p->num_bounds ; i ++ ){
+        glDrawArrays( draw_mode, n, p->bounds[i]);
         n += p->bounds[i];
       }
     }
+    else {
+      glDrawArrays( draw_mode, 0, p->num_vertexs);
+    }
+
+    // unbind buffers
     glDisableClientState(GL_VERTEX_ARRAY);
     glVBOBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
     glVBOBindBufferARB(GL_ELEMENTS_ARRAY_BUFFER_ARB, 0);