简体   繁体   English

OpenGL ES着色器和64位iPhone 5S

[英]OpenGL ES Shaders and 64-bit iPhone 5S

I just started testing with the iPhone 5S and the 64bit architecture on an OpenGL ES app. 我刚开始在OpenGL ES应用程序上使用iPhone 5S和64位架构进行测试。 The problem I'm seeing is that (CGFloat) values are way wrong when they get to the shaders. 我看到的问题是(CGFloat)值到达着色器时出错了。 I pass in 0.8 and it changes to -1.58819e-23 when I debug the shader. 我传入0.8并在调试着色器时更改为-1.58819e-23。 I am using glUniform4fv() to pass in the value. 我正在使用glUniform4fv()来传递值。 Do I need to use a different data type or? 我需要使用不同的数据类型吗? or a different method to pass in the values? 或者传递价值的另一种方法? The value goes through fine when I test on 32bit 当我在32位上测试时,该值很好

CGFloat brushColor[4];

brushColor[0] = 0.8;
brushColor[1] = 0.1;
brushColor[2] = 0.1;
brushColor[3] = 0.3;

glUniform4fv(program[PROGRAM_POINT].uniform[UNIFORM_VERTEX_COLOR], 1, brushColor);

(some of you may notice this is from the GLPaint demo...) (有些人可能会注意到这是来自GLPaint演示......)

thanks, 谢谢,

austin 奥斯汀

CGFloat is a variable typedef. CGFloat是一个变量typedef。 On a 32-bit build environment it is single-precision, on 64-bit it is double-precision. 在32位构建环境中,它是单精度的,在64位上是双精度。 Normally this would not be a huge issue, but you are using glUniform4fv , which takes a GLfloat * . 通常情况下这不是一个大问题,但你使用的是glUniform4fv ,它需要一个GLfloat *

OpenGL ES 2.0 Specification - Basic GL Operation - p. OpenGL ES 2.0规范 - 基本GL操作 - p。 12 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. OpenGL规定GLfloat始终是单精度浮点值,当您使用此函数的非指针版本时,编译器可以处理从双精度到单精度的类型降级。 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. 当您使用指针时,不会发生此行为 - OpenGL期望传递一个单精度浮点数组,但是您传递一个双精度浮点数组而没有类型转换。

What you need to do is stop using CGFloat . 你需要做的是停止使用CGFloat Instead, use GLfloat . 相反,使用GLfloat OpenGL typedefs are provided to ensure this sort of thing never happens. 提供OpenGL typedef以确保从未发生过这种事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 iPhone 5s 64 位上运行 32 位库 - Run 32 bit library on iPhone 5s 64 bit iPhone 5S上的OpenGL ES 2.0片段着色器编译速度很慢 - OpenGL ES 2.0 fragment shader compilation slow on iPhone 5S AVPlayer无法在iPhone 5s 64bit iOS 7.0.3上运行 - AVPlayer not working on iPhone 5s 64bit iOS 7.0.3 32位应用程序可以在64位iPhone 5S上运行吗? - Could the app that's 32 bit run on 64 bit, iPhone 5S? 在iPhone 5s或64位模拟器上测试32位iOS应用 - Testing 32 bit iOS app on iPhone 5s or 64 bit simulator 如何配置必须在iOS 5.1.1上运行的通用应用程序,以便它也可以在iPhone 5S上以64位运行? - How to configure a universal app which must run on iOS 5.1.1 such that it also runs with 64 bit on iPhone 5S? Xcode不将Phonegap应用程序部署到64位模拟器或Iphone 5s - Xcode Not Deploying Phonegap App To 64bit Simulator Or Iphone 5s 在64位5s iPhone上安装时,为什么应用程序卡住 - Why does app get stuck when installing on 64 bit 5s iPhone IOS UITableViewCells在第一个小区,Iphone5S设备中都混乱,64位模拟器 - IOS UITableViewCells all jumbled in first cell, Iphone5S device only though, 64-bit simulator iPhone 6和iPhone 6 plus支持必须与64位和iOS 8一起使用? - iPhone 6 and iPhone 6 plus support is mandatory along with 64-bit and iOS 8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM