Hi Kim,

The warning reported only gets reported is the type changes, so if you do:

  readShaderFile(osg::Shader::VERTEX,"myfile.vert"); it shouldn't emit
a warning, but if you do:

  readShaderFile(osg::Shader::FRAGMENT,"myfile.vert"); it will emit a warning.

The code that emits that warning in Shader.cpp looks like:

bool Shader::setType( Type t )
{
    if (_type==t) return true;

    if (_type != UNDEFINED)
    {
        osg::notify(osg::WARN) << "cannot change type of Shader" << std::endl;
        return false;
    }

    _type = t;
    return true;
}

So this suggest to me that in osgOcean there is a mix up on the
types/filenames some where along the line, or a bug in
OSG-2.9.x/svn/trunk Shader.cpp/ReaderWriterGLSL.cpp that we haven't
spotted yet.  To me the svn/trunk code looks OK.

Robert.



On Tue, Jun 16, 2009 at 11:57 AM, Kim C Bale<k.b...@hull.ac.uk> wrote:
> Hi Robert,
>
> Thank you, thank you.. hopefully there won't be too many bugs to fix.
>
> With regard to the shader type issue. I located the code you pointed out
> in the 2.9.3 source.
>
> It looks like the code in 2.9.3 sets the shader type twice if you load a
> shader with a .frag or .vert extension whilst also specifying the shader
> type using:
>
> inline osg::Shader* readShaderFile(osg::Shader::Type type, const
> std::string& filename) [include/osgDB/ReadFile]
>
> Which calls this:
>
> inline osg::Shader* readShaderFile(osg::Shader::Type type, const
> std::string& filename,const ReaderWriter::Options* options)
> {
>    osg::Shader* shader = readShaderFile(filename, options);
>    if (shader && type != osg::Shader::UNDEFINED) shader->setType(type);
>    return shader;
> }
>
> That function goes on to call the readShader in the ReaderWriterGLSL.
> This correctly identifies the shader type from the extension and assigns
> it. The plugin returns a valid shader with a vaid type, but
> readShaderFile will try and set it again because it's checking against
> the type passed in not the type already assigned to the shader by the
> plugin. The result is the "cannot change type of Shader" warning
> described.
>
> It's a harmless warning, but perhaps a bit misleading if you're
> migrating from 2.8.
>
>
> Regards,
>
>
> Kim.
>
> -----Original Message-----
> From: osg-users-boun...@lists.openscenegraph.org
> [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Robert
> Osfield
> Sent: 16 June 2009 10:01
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] osgOcean 1.0 (LGPL) Released
>
> Hi Kim,
>
> First up, congrats on the release :-)
>
> On Tue, Jun 16, 2009 at 9:45 AM, Kim C Bale<k.b...@hull.ac.uk> wrote:
>>> Why it cannot change type of Shader?
>>
>> I notice you're using osg 2.9.3, I've tested osgOcean against 2.8. I
> suspect that the registry in 2.9.3 can now differentiate between the
> shader extensions .frag and .vert and assigns the shader type
> automatically. Perhaps Robert could shout out on this one. Either way in
> osg2.8 at least that doesn't cause the shader to fail but rather flag a
> warning. I'll try and dig around in the osg 2.9.3 source to see if this
> is the case.
>
> The .glsl plugin does now set the shader type automatically based on
> whether the .frag or .vert extension is used.  The code in question is
> (from src/osgPlugins/glsl/ReaderWriterGLSL.cpp:
>
>                if (shader->getType() == osg::Shader::UNDEFINED)
>                {
>                    // set type based on filename extension, where
> possible
>                    if (ext == "frag")
> shader->setType(osg::Shader::FRAGMENT);
>                    if (ext == "vert")
> shader->setType(osg::Shader::VERTEX);
>                }
>
> I haven't merged this change into the OSG-2.8 branch, which is
> probably why you don't see the warning.  It would be odd to load a
> .vert shader and then set it to be a FRAGMENT shader type so this
> suggests a bug lurking in osgOcean or the resources.
>
> Robert.
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> *****************************************************************************************
> To view the terms under which this email is distributed, please go to 
> http://www.hull.ac.uk/legal/email_disclaimer.html
> *****************************************************************************************
> _______________________________________________
> 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

Reply via email to