2
$\begingroup$

I have different functions for example normalmapping which I use all the time... Now I thought about making a small glsl library.

My problem: I don't want to have all functions within the same "namespace".

I would like to have it like:

vec4 lighting::Phong(vec3 normal, vec3 color, vec3 lightPositionRelative)

The thing is, that I have tons of functions and sometimes multiple functions are related to the same thing, for example: A HashTable, AddKey, GetKey, HasKey...

So some kind of namespace or even better a class like structure. What are the options I have? How are you guys handle this?

$\endgroup$
3
$\begingroup$

GLSL does not support C++ style namespaces. You might want to do some regex magic before parsing the shader, replacing '::' with '_' or something. You might want to have a preprocessor of sorts - or just forget about it entirely.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.