<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16809" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=562051920-19032009><FONT face=Arial size=2>Hi Robert -- I have
a question about how the DrawElements* family of PrimitiveSets handles the
pointer to the indices.</FONT></SPAN></DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial size=2>In OpenGL, data is
bound/copied at call time, so if I were writing a plain ol' OpenGL app and
calling glDrawElements, I'd pass in a pointer to my index data, and when the
call returns, I'd know the indices had been copied and I could safely delete the
array of indices.</FONT></SPAN></DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial size=2>In OSG it's a bit
different. Even after I create the DrawElements PrimitiveSet, I need to hang on
to the index data memory, as the memory will be accessed during subsequent
rendering and/or write operations. Unlike other OSG objects, the index array
isn't reference counted internally. Indeed, the interface looks a lot like the
glDrawElements call in that the index data parameter is a plain pointer,
but it does not act like glDrawElements as it doesn't immediately copy the index
data. This forces my app to keep the data around and ensure it isn't
deleted.</FONT></SPAN></DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=562051920-19032009><FONT face=Arial size=2>This is cumbersome
in modular programming situations. Imagine I have a NodeVisitor that converts
DrawArrays to DrawElements and therefore allocates memory to hold the index
data. The processed scene graph could have a life that extends far beyond the
scope of the NodeVisitor, so it doesn't make sense to keep the addresses stored
in the NodeVisitor (where the memory was allocated). So who should keep track of
the index data memory addresses? Who should own deleting that
memory?</FONT></SPAN></DIV>
<DIV><SPAN class=562051920-19032009></SPAN><FONT face=Arial
size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=562051920-19032009>This isn't the first
time I've encountered this situation, and I thought perhaps you had encountered
it as well and maybe had a good solution that I was not aware of. If so, please
let me know. Thanks in advance.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV align=left><FONT face=Helvetica size=2>Paul Martz</FONT></DIV>
<DIV align=left><FONT face=Helvetica><STRONG>Skew Matrix Software
LLC</STRONG></FONT></DIV>
<DIV align=left><FONT face=Helvetica size=2><A
href="http://www.skew-matrix.com/">http://www.skew-matrix.com</A></FONT></DIV>
<DIV align=left><FONT face=Helvetica size=2>+1 303 859 9466</FONT></DIV>
<DIV> </DIV></BODY></HTML>