Hi,

I don't know of a way to pass #define values, other than composing a
shader of multiple strings:

(enableSimple ? "#define SIMPLE\n" : "#undef SIMPLE\n"),
"#ifdef SIMPLE\n"
"vec4 Color = vec4(1.0);\n"
"#else if NOT_SO_SIMPLE\n"
"vec4 Color = unimaginableComplicatedColorFunction(...)\n"
"#endif\n"

OpenGL doesn't have an interface analogous to compiler commandline
parameters (eg: "gcc -DSIMPLE")

Perhaps this is an area OSG could formalize and provide a value-add?  

Of course, the preprocessor is a compile-time conditional, and so
probably wont be an issue beyond app startup; runtime conditionals
should be expressed using uniforms.

cheers
-- mew




> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:osg-users-
> [EMAIL PROTECTED] On Behalf Of Sebastian Messerschmidt
> Sent: Monday, February 25, 2008 4:02 AM
> To: [email protected]
> Subject: [osg-users] GLSL Preprocessor
> 
> Hello,
> 
> I was wondering if the preprocessor language in GLSL is somehow
useable
> for osg.
> Imagine I had a shader with
> 
> ..
> #ifdef SIMPLE
> vec4 Color = vec4(1.0);
> #else if NOT_SO_SIMPLE
> vec4 Color = unimaginableComplicatedColorFunction(...)
> #endif
> 
> Can I pass those defines to osg::Shader? I didn't find anything.
> So the only way to achive this is to modify the shader-code before
> loading, right?
> 
> cheers
> Sebastian
> 
> 
> ..
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to