Re: [osg-users] incorrectly imported TEXTURE_DIMENSION macro in osgText_Text.frag

11 views
Skip to first unread message

Robert Osfield

unread,
Dec 18, 2019, 6:11:09 AM12/18/19
to OpenSceneGraph Users
Hi Cory,

What version of the OSG, OS and hardware are you using?

Do you see the issue with any of the OSG examples?

What is you OS's default locale?

Looking the #defines, is this osgText related?  Or State that your application has set up?

Cheers,
Robert.


On Tue, 17 Dec 2019 at 16:34, Cory Riddell <co...@codeware.com> wrote:
This may be related to something having to do with my locale settings,
but for some reason the fragment shader is failing to compile. This is
the error from the log:

    FRAGMENT glCompileShader "" FAILED
    FRAGMENT Shader "" infolog:
    Fragment shader failed to compile with the following errors:
    ERROR: 1:184: error(#132) Syntax error: "024.0" parse error
    ERROR: error(#273) 1 compilation errors.  No code generated

When I look for the source that is echoed to the log, the problem is the
thousands separator on line 4:

    Compiling C: FRAGMENT source:
        1: #define BACKDROP_COLOR vec4(0.300, 0.300, 0.300, 1.000)
        2: #define GLYPH_DIMENSION 240.0
        3: #define OUTLINE 0.070
        4: #define TEXTURE_DIMENSION 1,024.0

I believe the line is generated from this pragma:

    #pragma import_defines( SIGNED_DISTANCE_FIELD, TEXTURE_DIMENSION,
GLYPH_DIMENSION)

At this point I'm stuck. What controls the generation of those #define
macros? How do I tell it to use the C locale?

Thanks for any help,
Cory Riddell



_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Dec 18, 2019, 6:14:39 AM12/18/19
to OpenSceneGraph Users
Hi Cory,

Looking at osgText there following line (152, OpenSceneGraph/src/osgText/Text.cpp sets up the TEXTURE_DIMENSION:

        ss.str("");
        ss << float(activeFont->getTextureWidthHint());
        defineList["TEXTURE_DIMENSION"] = osg::StateSet::DefinePair(ss.str(), osg::StateAttribute::ON);

Which makes me think that the std::stringstream ss used is defaulting to your locale and then GLSL is using the standard locale.

If this is so then setting the locale on the stringstream would be the appropriate thing to do.

Robert.

Robert Osfield

unread,
Dec 18, 2019, 9:30:41 AM12/18/19
to OpenSceneGraph Users
Hi Cory,

On Wed, 18 Dec 2019 at 14:21, Cory Riddell <co...@codeware.com> wrote:
Thank you for pointing me to exactly the right spot. I made a change at the top of that function rather than in the spot you indicated.

I set the locale immediately after the stringstream is constructed (line 104):

    std::stringstream ss;  
    ss.imbue(std::locale::classic());
    ss<<std::fixed<<std::setprecision(3);   


This is exactly the fix I wrote 20 minutes ago, and now checked in :-)


This fix is checked into OSG-3.6 branch and master.
 
I see that the method createStateSet() is virtual. Rather than edit the OSG source, would you advise creating a subclass and overriding this method?

This is something you could do if you had to for older versions of the OSG.  The best solution is to have it part of the stringstream setup in Text.cpp as I'm sure this issue will crop up for others that change don't have standard locale.

Cheers,
Robert.
 
Reply all
Reply to author
Forward
0 new messages