Hi Chris, It's not possible to determine what error you have made from the snippets included. The snippet of code you did include didn't show how or whether you added the osg::Program to the StateSet, or whether you attached a vertex shader.
I would recommend starting from one of the examples like osgshaders and the shaders in the OpenSceneGraph-Data/shaders set. Robert. On 26 January 2015 at 14:51, Chris Hidden <ch...@erghis.com> wrote: > Hey Robert, thanks for answer, hope you had a great weekend! > > I've been trying to read up on vertex shaders and fragment shaders and > maybe I am not quite understanding. > > Im trying to attach a very basic fragment shader, but I can't seem to get > it to work and I am not sure why. > > I keep getting the error "Duplicate function definitions for "main"; > prototype: "main()" found. > > I've looked at 2 or 3 of the examples and it seems perfectly fine to > attach two shader files, one .vert and one .frag to a single program. > > Specifically the program in osghardwareanimation example. I only added > these lines of code to the existing example to get the duplicate main error: > > > Code: > > osg::ref_ptr<osg::Shader> fragshader; > osg::ref_ptr<osg::Image> image = > osgDB::readImageFile("Images/PNG/Erghis_Hands_Texture.png"); > osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D(); > texture->setImage(image); > > osg::ref_ptr<osg::StateSet> ss = new osg::StateSet; > ss->setTextureAttributeAndModes(0, texture, > osg::StateAttribute::ON); > > osg::ref_ptr<osg::Uniform> unifo = new > osg::Uniform("Hand_Texture", texture.get()); > fragshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, > "C:/OpenSceneGraph/files/shaders/rain.frag"); > > if (!fragshader.valid()) > osg::notify(osg::WARN) << "RigTransformHardware can't load > FragmentShader" << std::endl; > program->addShader(fragshader.get()); > > ss->addUniform(unifo); > > > > > I added this block right before the state change applications at the end > of the init() function. I must be missing something stupid because I've > googled the error and looked at the other examples and no one seems to be > having this problem. What am I doing wrong? > > This happens with any .frag shader I load. Not just the one I wrote which > for the sake of showing you is simply: > > uniform sampler2D myTexture; > > void main(void) > { > vec4 color = texture2D(myTexture, gl_TexCoord[0].st); > gl_FragColor = color; > } > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=62482#62482 > > > > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org