Reflecting GLBase in shaders
Posted: Mon Jun 10, 2013 9:34 pm
The basic problem here is to write a shader which would work for both ZApplication.GLBase settings, for the Compatible mode and for the ES/GL3 mode.
The most effective way, is to obtain this information in the form of preprocessor macro/variable, because it should influence shader code compilation; a uniform variable does not seem to be an optimal solution. If we look at what is already available in GLSL, we can use GL_ES and __VERSION__. I tried the following:
but these shaders do not work on Android. Could you please tell me where's the problem?
Anyway, even if __VERSION__ and GL_ES macros are used, they do not reflect setting of the ZApplication.GLBase propety; but just what version of the shading language is available on the device.
The desired solution would be to write code like this:
Of course, there is no ES2_GL3 macro defined (yet). Isn't it possible to define this (or similar) macro in ZGE used to reflect the ZApplication.GLBase property in its shaders?
The most effective way, is to obtain this information in the form of preprocessor macro/variable, because it should influence shader code compilation; a uniform variable does not seem to be an optimal solution. If we look at what is already available in GLSL, we can use GL_ES and __VERSION__. I tried the following:
Code: Select all
#if defined GL_ES || __VERSION__ >= 130
#define ES2_GL3
#endif
#ifdef ES2_GL3
...
Anyway, even if __VERSION__ and GL_ES macros are used, they do not reflect setting of the ZApplication.GLBase propety; but just what version of the shading language is available on the device.
The desired solution would be to write code like this:
Code: Select all
#ifdef ES2_GL3
...
#endif
...