Refactored shader system
Description
Description
Details
Details
- Committed
Nim Sep 8 2016, 12:21 PM - Parents
- R37:8ae151f3d744: Fix the calculation for hasOpenGL3
- Branches
- Unknown
- Tags
Comment Actions
Instead of doing multiple string comparisons every redraw, why not make an enum for the different shaders?
Comment Actions
I assume you are talking about the uniforms. It is a trade-off as far as I can see.
Advantages of enum:
- You dont need to do string comparisons
- You can't accidentally misspell a uniform name
Disadvantages of enum:
- We need to keep track of updating the enum as we write new shaders to cover all names
- We need to create another file and include it everywhere we use shaders
Advantages of string:
- Needs no extra files or structures
- It is immediately clear which uniform it is pointing to
Disadvantages of string:
- Easy to misspell
- Some negligible time is spent on comparing strings (could be bad if we have a lot of uniforms)
It is worth noting that a string comparison takes the equivalent of 0.0001 milliseconds for normal uniform string values though.
I might implement the enum approach now though, I find the argument for it stronger. This commit is pretty rough around the edges still I should note, certainly some stuff to fix, but it's in a separate branch so.