Ejemplo n.º 1
0
IndexBuffer IndexBuffer_new(e_mesh_mode mode)
{
    index_buffer* buffer = (index_buffer*)Malloc(sizeof(index_buffer));
    buffer->face_size = face_size(mode);
    buffer->index_buffer = (char*)SMalloc(DEFAULT_INDEX_BUFFER_SIZE);
    buffer->index_buffer_size = DEFAULT_INDEX_BUFFER_SIZE;
    buffer->index_buffer_tail = 0;
    buffer->dirty_flag = 1;
    buffer->mesh_mode = mode;
    glGenBuffers( 1, &buffer->id );
    glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffer->id );
    IndexBuffer ret;
    ret = buffer;
    return ret;
}
Ejemplo n.º 2
0
unsigned int ROMesh<Variable, VertexDim, Scalar, VertexOffset
                   >::edge_face_index( unsigned int face_index, 
                                       unsigned int v1, 
                                       unsigned int v2 
                                     ) const {
  //vertices of the face
  const unsigned int* verts = face(face_index) ;
  //size of the face
  unsigned int fsize = face_size(face_index) ;
  //loop over the vertices
  for(unsigned int i = 0; i < fsize; ++i) {
    unsigned int vi = verts[ i         ] ;
    unsigned int vj = verts[(i+1)%fsize] ;
    if(((vi==v1)&&(vj==v2))||((vi==v2)&&(vj==v1))) {
      return i ;
    }
  }
  //if no return was issued before, the edge was not found
  return NO_INDEX ;
}