i currently doing some level-of-detail thing.
i rendered a perfect hierarchical world with almost “primitives” on the lowest level (there may be ~6 levels or more)
every “node” is nested in other ones of which the dimensions (eg radius or bounding box) are known
now i make heavy use of gl matrix stack, to draw all these nested transforms like:
glPushMatrix(); pp=object.getPosition(); glTranslatef(pp.x,pp.y,pp.z); if (DETAIL_IS_VISIBLE) RENDER CHILD NODES RENDER PRIMITIVES, IF ANY glPopMatrix();
now the problem is to determine DETAIL_IS_VISIBLE.
in fact this is done by comparing the bounds of the nodes to the actual distance to the viewer…
which is gathered by
now as the code looks somewhat as
glPushMatrix(); pp=object.getPosition(); glTranslatef(pp.x,pp.y,pp.z); glGetFloat(GL_MODELVIEW_MATRIX, matrix); if (DETAIL_IS_VISIBLE(matrix)) RENDER CHILD NODES RENDER PRIMITIVES, IF ANY glPopMatrix();
the main question now uprises:
if i use gl for all transforming (as i do) because if want to let the GPU do all the job, what about the glGetFloat?? I am in fear that optimisations of gl will vanish. in fact, the glGetFloat forces gl to do all transforms happen to that point, beeing a kind of “glFinish”. maybe its no problem because states/textures/other things are much more costly, and transfrom is done in sync fast, but maybe i synchronize gpu and cpu fully pulling the gpu on a very short chain, eleminating reordering optimisations…
as in fact, the whole geometry buildup relies on that detail mechanism, i cannot just “switch it of” to compare performance
what i would have to do is to render a frame while “recording” the visibility states of all nodes, then rendering them without the call to glGetFloat in the exact same configuration… which seems quite to complicated, modifing the whole thing just for a performance test.
so is there any experience on this like you would say “damn guy, NEVER pull transform data back from gl” or something else?
thanks & greets