OpenGL ES Shaders and 64-bit iPhone 5S

早过忘川 提交于 2019-11-30 13:50:20

CGFloat is a variable typedef. On a 32-bit build environment it is single-precision, on 64-bit it is double-precision. Normally this would not be a huge issue, but you are using glUniform4fv, which takes a GLfloat *.

                     OpenGL ES 2.0 Specification - Basic GL Operation - p. 12

              

OpenGL stipulates that GLfloat is always a single-precision floating point value and compilers can deal with type demotion from double-precision to single-precision when you use the non-pointer version of this function. When you use pointers, this behavior does not occur - OpenGL expects to be passed an array of single-precision floats, but you pass it an array of double-precision floats with no type conversion.

What you need to do is stop using CGFloat. Instead, use GLfloat. OpenGL typedefs are provided to ensure this sort of thing never happens.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!