Is anybody else out there developing for OpenGL ES 2 and/or GLKit, and having success?
I've got a fair amount of experience in OpenGL for the Mac, but I'm tackling my first project in OpenGL ES.
I'm using OpenGL ES 2.0, and it's driving me nuts.
The first problem is that none of the simple drawing commands that I'm used to work any more. Everything is do-it-yourself with shaders. Ok, I can get through that. It's just a (very steep) learning curve that I am having to climb.
The more serious problem I'm facing relates to setup and configuration.
I've got an app that's working quite well, doing mesh warping and rendering a texture onto a warped mesh. However, nothing but glClear appears on the screen when I run the app on my iPad. My other commands (either drawing my mesh using textures and GL_TRIANGLE_STRIPS) or simple line strips or even GL_LINES, don't appear at all.
Everything works perfectly on the simulator.
There must be something I'm doing wrong, but I'm darned if I can figure out what it is.
I've built test apps using both a subclass of UIVIew with a backing CAEAGLLayer, and the new GLKView. (My GLKView needs to be stand-alone, and not contained in a GLKViewController, since I need to draw 2 OpenGL Views, along with UIKit views, in a single view controller, and GLKViewController forces you to make the view controller's main view a GLKView.)
Both the GLKView approach and the custom UIView approach fail to draw anything but a glClear on my development iPad, and I am at a loss despite flogging at this problem full time for over a week.
I just went back and tried the GLKView approach again, and got a dirt simple "draw a blue square" app working with GLKView on the simulator, but it still won't draw on the device. Arghhhhh!!!!!!
This is an app I'm developing for a client, so I need to get this resolved. I logged a tech support "incident" on it with apple last Friday, only to find out that Apple was closed the entire week of Thanksgiving, and I expect them to take a number of days to get to me even after they reopen on Monday. I'm still slogging away to find the problem in the meantime.
Can anybody out there suggest things that I might be doing wrong? Is anybody willing to take a look at my test program and figure out what I'm doing wrong?
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Post your project and I'll take a look. I can't promise anything though as I am porting my own engine to ES 2.0 and having my fair share of problems. Anyway I may be able to help.
Post your project and I'll take a look. I can't promise anything though as I am porting my own engine to ES 2.0 and having my fair share of problems. Anyway I may be able to help.
Here's a link to the dirt-simple GLKView project from my public dropbox
It's based on the design for my real project, so the shader has a uniform that lets me turn textured drawing on and off.
The sample project just draws a blue square against a red background. It works perfectly on the simulator, but not on the device. On the device (my iPad 1) only the glClear is visible.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I am getting a yellow square on a white background with a blue square inside on the iPad 5 simulator.
On the iPad 2 I get a yellow square on a white background.
Same here.
The yellow square is the glClear, filling the entire GLKView view with yellow. The blue square, which only appears on the simulator, is drawing that's done using GL_LINE_STRIP commands.
As I said, only the glClear command actually does anything on the device. Drawing commands (like GL_LINE_STRIP) are not appearing on the device.
If it was working correctly, it would look the same on the simulator and the iPad.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
OMG, thank you! Thank you thank you thank you! You have no idea how nuts this has been making me. I've been flailing at this problem (on a more complex app) for about 2 weeks now, with absolutely no progress.
Why do you suppose the projection matrix works on the sim, but not the device? And why does your projection matrix need to have a Z volume for 2D rendering?
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
OMG, thank you! Thank you thank you thank you! You have no idea how nuts this has been making me. I've been flailing at this problem (on a more complex app) for about 2 weeks now, with absolutely no progress.
Sometimes some fresh eyes can pick up things easily missed. Anyway I'm glad I could help out
Quote:
Originally Posted by Duncan C
Why do you suppose the projection matrix works on the sim, but not the device? And why does your projection matrix need to have a Z volume for 2D rendering?
Yes you would think an ortho view wouldn't need any depth but I set my ortho depth range 0.0 - 1.0 so that is what I tried. I find that the depth buffers on devices can vary so that might be the reason it worked on the simulator and not on hardware. I'm not entirely sure though.
Sometimes some fresh eyes can pick up things easily missed. Anyway I'm glad I could help out
Yes you would think an ortho view wouldn't need any depth but I set my ortho depth range 0.0 - 1.0 so that is what I tried. I find that the depth buffers on devices can vary so that might be the reason it worked on the simulator and not on hardware. I'm not entirely sure though.
It's especially odd since I don't have depth buffers enabled at all.
I have another one for you.
How do you enable drawing with alpha? In my code, I either draw a texture where there's no blending of source color and fragment color, or I want to be able to draw into the color buffer using a source color with alpha. If the alpha is less than 1.0, I want the color to blend with the existing pixel color.
If you change the code in my sample project to set my source color uniform to a color with an alpha of .5, it still draws the primitives as fully opaque.
I pass the color in as a vec4 uniform (including an alpha) and use the color in my fragment shader.
When I'm not drawing with a texture, my fragment shader simply does this:
Code:
gl_FragColor = DestinationColor;
From the reading I've done, the driver should blend the color I draw with the current color in the render buffer at that location.
I tried calling glEnable(GL_ALPHA) and/or glEnable(GL_BLEND) but both of those return an error, making me think those calls aren't supported in OpenGL 2.
I know quite a bit about the fixed rendering pipeline for Desktop OpenGL, but I'm more than a little lost in OpenGL 2.0.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
You don't need depth buffers unless you're doing depth testing. An ortho matrix is just a way of setting up your projection matrix. You are still using what is essentially 3d hardware.
You don't need depth buffers unless you're doing depth testing. An ortho matrix is just a way of setting up your projection matrix. You are still using what is essentially 3d hardware.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
It works for me using your own example on both simulator and hardware.
Curious. It works for me too on the example project, but not in my "real" project. Odd, that.
The real project creates an OpenGL view manually as a subclass of UIView with an EAGLLayer, and sets it up manually. Can you think of any configuration I might be missing that would enable alpha blending?
Edit: Never mind. Bonehead mistake on my part. There was an additional line to set the color (to an opaque value) that I missed. It was overriding my code to set a partly transparent color.
Once I set GL_BLEND then glBlendFunc, it works (I had those two lines in reversed order, which apparently DOESN'T work.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.