Reputation: 35
recently I decided to pick up a game development project again that I started several years ago to submit to the iOS app store. I found out that my app displays a black screen on the iPhone5s and up even though it operates okay. I have a iPhone 3GS and have tested it on the iPhone 4s as well and it works properly.
There was a thread here where someone had a similar issue saying that the later versions of the iPhone are backwards compatible with OpenGLES 1.1 and that it was just errors within his code. But the actual thread did not specify how he solved it. Source: Similar Stack Overflow Thread
I know that all versions of the iPhone are supposed to be backwards compatible with OpenGLES 1.1 but it seems like something has changed with the new phones. (Perhaps it has to do with metal? I have noticed in my research that they implemented metal on the iPhone 5s and later versions.)
I've been searching for awhile on the subject and can't find anything, maybe it would be better just to port my project over to OpenGLES 2? Does anyone know anything about this weird iPhone version bug?
Upvotes: 1
Views: 375
Reputation: 100612
When you tell OpenGL that you're supplying GL_FLOAT
data, it expects GLfloat
data. GLfloat
is a typedef of float
.
CGFloat
is a typedef of float
on 32-bit devices and double
on 64-bit devices.
So the issue is a false assumption that GLfloat
and CGFloat
are different names for the same type. They're not.
This, incidentally, is partly why Apple now supplies GLKVector2
et seq. You should use that, its make function and all the rest of GLKit if you want convenience.
Upvotes: 1
Reputation: 35
This turned out to be an issue with OpenGL (not version specific) being much more strict on 64-bit devices: the iPhone5s+. CGFloats do work on these devices (This includes CGPoints because they contain CGFloats.) Use GLFloats because this is provided by the OpenGL library for this exact purpose.
So in my case I made some structs to replace CGFloats for example:
//structure to replace CG Point for 64-bit device compatability
typedef struct {
GLfloat x;
GLfloat y;
} GLPoint;
//returns a GLPoint to replace CGPoint structure to support 64-bit devices
static inline GLPoint GLPointMake(GLfloat x, GLfloat y) {
return (GLPoint) {x, y};
}
I used this instead of CGPoints in my code to fix this. This code will properly port over when using vertexes to render on 64-bit devices.
Upvotes: 1