Jump to content
Sign in to follow this  

Custom geometry display : GR and triangles/quads

Recommended Posts



  I am studying the tetprim example code.


  I see the following code and would like to find out if the returned GL buffer always expect one to fill them in with triangles ? Therefore if we have quads, we need to split it up into two triangles per quads ?


  If I have misunderstood the GL buffer returned by pos->map() and that it supports n-gon, where should one specify the per-polygon vertex count ?


  I have had a look at the GT code and it has the concept of vertex_order[] so I am fine with that. I want to test out a GR implementation hence the above question.


============= CODE =======================

    // Initialize the number of points in the geometry.

    myGeo->setNumPoints( 12 * num_tets);



    // Fetch P (point position). If its cache version matches, no upload is

    // required.

    pos = myGeo->findCachedAttribOrArray(r, posname, RE_GPU_FLOAT32, 3,


    if(pos->getCacheVersion() != p.geo_version)


// map() returns a pointer to the GL buffer

UT_Vector3F *pdata = static_cast<UT_Vector3F *>(pos->map®);



    for(int t=0; t<num_tets; t++)


pdata[0] = pt(t*4);

pdata[1] = pt(t*4+1);

pdata[2] = pt(t*4+2);


pdata[3] = pt(t*4);

pdata[4] = pt(t*4+2);

pdata[5] = pt(t*4+3);


pdata[6] = pt(t*4+1);

pdata[7] = pt(t*4+2);

pdata[8] = pt(t*4+3);


pdata[9] = pt(t*4);

pdata[10] = pt(t*4+3);

pdata[11] = pt(t*4+1);


pdata += 12;




Share this post

Link to post
Share on other sites

Answering my own post. The usage of the points to draw geometry is determined in the call




  There are a variety of options closely related to OpenGL primitives GL_* enums.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this