Hello Sajjad,
You seem to be confused on the usage of pointers and when you're
required to make a copy of an object. I suggest you review a good C++
book to get a good grasp of these concepts, because writing good OSG
code kind of requires that you know how to write good C++ code.
ref_ptr<Shader> capsuleVertexObject = new
Shader(*(Shader::**readShaderFile(Shader::VERTEX,**"shaderSRC/gooch.vert")));
ref_ptr<Shader> capsuleFragmentObject = new
Shader(*(Shader::**readShaderFile(Shader::**FRAGMENT,"shaderSRC/gooch.**vert")));
This would be sufficient:
osg::ref_ptr<osg::Shader> capsuleVertexObject =
osg::Shader::readShaderFile(osg::Shader::VERTEX,
"shaderSRC/gooch.vert");
or
osg::ref_ptr<osg::Shader> capsuleVertexObject =
new osg::Shader(osg::Shader::VERTEX);
capsuleVertexObject->loadShaderSourceFromFile(
"shaderSRC/gooch.vert");
In your original code, you were calling readShaderFile() (which creates
the osg::Shader object and returns a pointer) and then creating a new
(empty) shader, and copying the other shader into it. This is not only
unnecessary, but it would probably introduce a memory leak because the
shader returned by readShaderFile() is never put into a ref_ptr, so it
will never be deleted.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay [EMAIL PROTECTED]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org