TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.09k stars 222 forks source link

Fixed shaders to work on old AMD graphic cards #48

Closed Gogsi closed 8 years ago

Gogsi commented 8 years ago

This is a fix for Issue #41

Older versions of GLSL don't support using variables as an array index. But as specified in the GLES specification in The Appendix, section 4

for loops are supported but with the following restrictions: • There is one loop index. • The loop index has type int or float. • The for statement has the form: for ( init-declaration ; condition ; expression ) statement • init-declaration has the form: type-specifier identifier = constant-expression Consequently the loop variable cannot be a global variable

And in section 4

The following are constant-index-expressions: • Constant expressions • Loop indices as defined in section 4 • Expressions composed of both of the above

Variables • Support for indexing with a constant-index-expression is mandated. • Support for indexing with other values is not mandated.

So I changed the default shader to loop until it reaches the desired texture (or mask) id and to use the loop index (named i) for the tid and than to break.

It does hurt performance a bit, but at least for me compatibility is more important than perfect performance.

TheCherno commented 8 years ago

Closed due to being obsolete. If you believe this is still an issue, please submit a new pull request.