Hi Dominik, nice and handy piece of code! Thank you for that. We have also extended the GLSL compiler in order to retrieve the uniform parameters, I don't recommend doing that, it took some time! But the results should be more reliable...
Cheers, Toni > Hi. > I had a similar problem and solved it with this small func. As long as > your declaration is in one line and comments are only after the ";" it > works. _uniforms is std::map<string,string>, with the variable name as > key and the type as value. Because std::map does not allow multiple > keys, you can use the same map for vertex and fragment shader programs > with common uniform variables. > > HTH, yours, > Dominik > > void GLSLModifier::getUniformValues(const string& shaderAsString){ > stringstream s(shaderAsString); > string tmp,varname,type; > while(s.good()){ > s>>tmp; > if(tmp=="uniform"){ > s>>type>>varname; > //Get rid of the ";" > int index=varname.find(";"); > if(index!=string::npos){ > varname.resize(index); > } > cout<<"Found uniform variable "<<varname<<" ("<<type<<")"<<endl; > _uniforms[varname]=type; > } > } > } > > > Marcus Lindblom schrieb: > > > Antonio Bleile wrote: > > > >> Hi Marcus, > >> > >>> No. One needs to parse the shader code by oneself to do that. > >>> > >>> However, it shouldn't be that hard. Search and extract data matching > >>> the > >>> string "\nuniform <type> <name>;\n" (whitespace handling is optional > >>> :). > >>> > >>> Boost has some good regex & string-algorithm support that should make > >>> this quite easy (it's on my todo-list.) > >> > >> > >> Yep, but that does not take into account the context... (comments etc). > > > > > > True. Boost has a c-preprocessor though (wave) that could help, > > although that might be overkill as well. > > > >> But one could download the glsl compiler and use the parser: > >> > >> http://developer.3dlabs.com/downloads/glslcompiler/index.htm > >> > >> Bit of overkill perhaps. > > > > > > Probably. Writing a very small specific parser for just this shouldn't > > be that hard. I was thinking of making something quite simple just to > > check my own shaders, so I can live with some restrictions on > > comments/formatting. Making it generic would take a bit more time, but > > not overly much so, methinks. > > > > /Marcus > > > > > > ------------------------------------------------------- > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make your job > > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > > Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Opensg-users mailing list > > Opensg-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/opensg-users > > > > > > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Opensg-users mailing list > Opensg-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/opensg-users ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users