# Custom geometry display : GR and triangles/quads

## Recommended Posts

Hi,

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,

RE_ARRAY_POINT, true);

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

{

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

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

if(pdata)

{

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;

}

Cheers

##### Share on other sites

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

myGeo->connectSomePrimsI()

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

Cheers

## Create an account

Register a new account