alexjc / alexjc/shadertoy-render
Invalid call of undeclared identifier 'texture' , Invalid call of undeclared identifier 'round' (macOS)
- 主要語言
- Python
- 星號
- 254
- 分支
- 42
- PR 合併指標
- 30 天內沒有已合併 PR
描述
When trying to make this script compatible with macOS openGL (for example [this fork](github.com/GonzaloHirsch/shadertoy-to-video)), one may be still left with errors such as this:
```
main.glsl(334): error: Invalid call of undeclared identifier 'texture'
main.glsl(334): error: Invalid call of undeclared identifier 'round'
```
As a workaround, I defined compatible versions of these functions in *Common.glsl* (see below).
The first line switches the functions between the standard versions and compatibility versions at compile time.
Make sure to comment it out when you're not using the rendering script.
``` glsl
#define RUN_COMPATIBILITY
// Texture function compatible with older desktop openGL
vec4 texture_compat(sampler2D tex, vec2 uv) {
#ifndef RUN_COMPATIBILITY
return texture(tex, uv);
#else
return texture2D(tex, uv);
#endif
}
// Round function compatible with older desktop openGL
float round_compat(float x) {
#ifndef RUN_COMPATIBILITY
return round(x);
#else
return floor(x + 0.5);
#endif
}
vec2 round_compat(vec2 x) {
#ifndef RUN_COMPATIBILITY
return round(x);
#else
return floor(x + 0.5);
#endif
}
vec3 round_compat(vec3 x) {
#ifndef RUN_COMPATIBILITY
return round(x);
#else
return floor(x + 0.5);
#endif
}
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。