【问题标题】:Why only set the precision if GL_ES is defined?如果定义了 GL_ES,为什么只设置精度?
【发布时间】:2022-09-19 08:14:54
【问题描述】:

为片段着色器编写代码时,开始如下:

#ifdef GL_ES
precision mediump float;
#endif

为什么precision mediump float; 行必须取决于是否定义了 GL_ES?

【问题讨论】:

    标签: opengl opengl-es glsl fragment-shader glsles


    【解决方案1】:

    它不是“必须”;它就是这样。

    Desktop GL 将忽略任何 precision 声明。所以没有必要在它周围ifdef

    话虽如此,如果想与非常旧版本的桌面 GLSL(1.20 或之前)共享 GLSL 代码,那么 #ifdef 很有用,因为这些版本不允许 precision 声明。

    【讨论】:

      猜你喜欢
      • 2013-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      相关资源
      最近更新 更多