Hi Johannes,

Am 01.03.2011 10:29, schrieb Johannes Baeuerle:
> Hi Ulrich ,
> 
> I tried to resolve the problem with minimal changes in my submission.
> 
> I agree to the thought of completely avoiding manual memory management. Is 
> the following portable over different stl implementations?
> 
> std::vector<GLint> formats;
> formats.reserve(numFormats);
> glGetIntegerv(GL_SHADER_BINARY_FORMATS, &formats[0]);

You should use "resize" because "reserve"
does not change the "logical" length of the
vector. After the call glGetIntegerv in you
original code formats.size() will still be 0.

> 
> The problem is that the elements have to use consecutive memory as the method 
> requires a pointer to a GLint array. I found hints that many stl 
> implementations write elements of vectors into a consecutive area of memory. 
> But I'm not quite sure.
> 
> With this solution the delete calls would be obsolete, when leaving the 
> method the std::vector is destroyed.
> 
> How would you use auto_ptr? As far as I discovered, an auto_ptr holds one 
> element. The call to glGetIntegerv needs a consecutive array. You would need 
> to create an array of auto_ptr which would lead to much overhead to just 
> iterate over the available binary formats.
> 
> 
> Cheers,
> Johannes

Cheers,

Peter

> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=37192#37192
> 
> 
> 
> 
> 
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
> 

-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 


_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to