Why can't I see certain OpenGL ES charts in the 4.2 Simulator? - iphone

I am writing an application which contains some graphs drawn in OpenGL ES. each of these graphs are in a table cell, when I press some of those graphs, it is being opened in full screen mode.
Everything worked perfectly since I upgraded to iOS4.2. Now the problem is in simulator, I can't see the drawn graph in cells, but in full screen mode I do see the chart. There are no changes no the device, it is only on the simulator and only in a case.
The behavior is the same for other Mac's here.
Does anyone have a clue?

As explained in this answer to this similar question, there has been a change in the way that 4.2 handles renderbuffers in Core Animation layers. From the OpenGL ES Programming Guide:
In iOS 4.2 and later, the performance
of Core Animation rotations of
renderbuffers have been significantly
improved, and are now the preferred
way to rotate content between
landscape and portrait mode. For best
performance, ensure the renderbuffer’s
height and width are each a multiple
of 32 pixels.
It appears that if your renderbuffer isn't an even multiple of 32 pixels, it doesn't display in the Simulator. This is a bug in the Simulator, but you should probably make your renderbuffer a multiple of 32 in either dimension in any case to improve performance.

Same things with my App. My textures are broken sporadically on the simulator (4.2). On the hardware everything looks fine.

I don't know if this helps much, but I've seen all manner of strange behaviour on the simulator implementation of OpenGL ES: spurious images appearing; strange lighting on the first render pass; broken rendering to bitmaps, depending on when I call it. I'm no expert in OpenGL programming, so I could just be writing crap code, but there is definitely a noticeable difference in the behaviour of the simulator vs the real hardware.
Your experience suggests that maybe my problems aren't entirely my fault. :-)

Related

glDrawElements incorrectly renders points on iPhone

I am fairly new to OpenGL development on iOS. I'm working on software that will create 3D reconstructions of objects in the form of *.ply files. I'm trying to make an iOS app to visualize these simple vertex-only *.ply files. Everything works as intended on the iPhone and iPad Simulator, but when I run it on my iPhone, the points rendered in the view are glitchy and covered with large squares. Here's the comparison: iPhone and simulator. Has anyone run into similar issues with OpenGL?
It's important to understand that when running OpenGL ES code on the simulator, you're actually running it on the simulator's software implementation and not on the GPU.
The simulator's implementation is close to, but not identical to the implementation on the device GPU. This means that faulty code may render fine on the simulator. I've experienced it myself on a couple of occasions, like when using glbuffers and not allocating enough storage.
It's obviously hard to say where your code goes wrong, but I'd suggest you to go through your code and look for subtle errors.

Will images look different from the iPhone Simulator to an actual iDevice?

Images that I add to the layer in Cocos2d look pixelated around the edges of the image (i.e. a hillside, the rounded part of the hill, where the sky and the hill meet). I don't know if it's the image quality, or just because the graphics processor on my 'older' MacBook Pro is not as advanced as the iPhone 4 or iPod Touch 4 or iPad 2. Is it because of that?
I have ran into an instance where a large resolution image was being used in the context of a locally packaged HTML file in a UIWebView. The image looked fine in the simulator, but when ran on a hardware device, a bug was exposed in the rendering engine where it would invert the colors. Here's a bug report as an example of this. The solution was to scale the image down a bit in photo editing application.
While an extreme corner case, this is an example of the simulator not quite living up to how things will work on a hardware device.
The simulator usually does a pretty good job representing what the final image will look like. For the image quality on a normal computer to be worse than that of an iPhone for it to make a large enough difference, your MacBook Pro has to be really bad. So I doubt it.
However, if you really want to make sure, the best way to check would be to transfer the image you are using to another machine to see if it still looks pixelated. If it does, its a problem with your image.
Hope this helps and good luck!

iPhone & iPad: Is an OpenGL ES Universal App a pain to write for multiple devices?

I've had experience writing a cocoa touch app as a universal app (for ipad, iphone) and it wasn't too hard. I only needed to use different .xib for each device but atleast it was the same binary.
Is it possible to have a universal opengl es app as well? Is it difficult given I have to have the resolution different for each devices (iphone 3gs, iphone 4, ipad)? So most probably my code would be different for each device???
While difficulty is a subjective measure, I would argue that it is a simpler process to develop an OpenGL-ES-centric application for the various devices than one based on more standard user interface elements. Where an iPad version of a standard iPhone application may require a completely different interface layout, if you are doing fullscreen OpenGL ES drawing, you just simply need to have the rendering layer scale to the appropriate screen size.
For example, take a look at the code to my Molecules application (it's available under a BSD license). It is a universal iPhone / iPad application and shares a lot of code between the two interfaces. In fact, almost none of the OpenGL ES portion changes based on the platform.
When it comes to something like the Retina displays, you just need to add one little bit of code in your CAEAGLLayer-hosting view's initialization to account for the new scale factor:
if ([self respondsToSelector:#selector(setContentScaleFactor:)])
{
self.contentScaleFactor = [[UIScreen mainScreen] scale];
}
Nothing else needs to change, and your OpenGL ES content will now render at the higher resolution.
Probably the biggest issue you will encounter is that by going to the higher-resolution displays you may find yourself being fill rate limited where you weren't before on the older iPhones. If you see the Renderer Utilization getting near 100% in the OpenGL ES instrument, that's what is happening. For the Retina displays, you may then want to not render at the full 2X scale factor, but something a little lower.
I can't speak to your particulars, but I have a universal app and it uses OpenGL-ES. For my purposes, glViewport() call takes care of things.

App is fast on 3GS but slow on 3G

I'm new to computer coding and have just finished coding an app and tested it on both 3G and 3GS. On 3GS, it worked as normal as on the simulator. However, when I tried to run it on 3G, the app becomes extremely slow. I'm not sure what's the reason and I hope someone could shed some light on me.
Generally, my app has a couple of view controller classes, with one of them being the title page, one being the main page, one is setting, etc. I used a dissolve to transition from the title page to the main page. But even this simple transition shows un-smooth performance on a 3G! My other part of the app involves zooming in to some images by scaling up the images, switching images by push or dissolve upon receiving touch events, saving photos into photo library and storing and retrieving some photos in a folder and some data in a SQlite database, each showing un-smooth actions.
Compared with some heavy graphic or heavy maths app, I think mine is pretty simple. I totally have no clue why the app would behave so slow and un-smooth that it is barely useful on a 3G. Any help/ direction would be much appreciated. Thanks for helping out.
You might want to try profiling your application with Shark to find out where the performance bottlenecks are.
I don't know how relevant it is to your case, but my game (shameless plug) MultiMaze is quite undemanding graphically, and worked beautifully on my 3GS. But when I tried it on a 3G, the frame rate dropped to a glacial 10-20 fps. I ported the whole code base from CoreGraphics to OpenGL ES, and that made a world of difference. It now runs at the limit (60 fps) on my 3GS and very close to it on the 3G.
Are you using a lot of memory? 3G has 128MB while the 3GS has 256MB RAM.
Are you getting memory warnings? In my debug builds I have an NSLog in didReceiveMemoryWarning so I can see if/when I get warnings.
EDIT: Check the size of your photos, are they resized for the iPhone screen or are they original sized?
OK, finally found the problem and got the solution. The problem was that I have about a dozens of transparent images laying on each other to form my main view. So when in any animation, the system needs to redraw on every single layer and calculate their transparent effect and so on. (actually I'm not quite sure, but that's what I think)
The solution I have is to make a temporary composite view containing of them all, and placing the composite as an image in a full screen view before starting any animation. It delays starting the fade a moment, but the fade itself is a lot smoother now.

Can the iPhone simulator handle PVR textures?

I have a really weird problem with PVR textures on the iPhone simulator- the framerate falls through the floor on the iPhone simulator, but on the iPhone itself it works just fine. Has anyone had any experiences similar to this? I'm using SDK 3.1.2
The iPhone simulator is known to be extremely slow for certain rendering scenarios.
One especially bad case we experienced was that creating (glGenTextures+glTexImage2D) and destroying (glDeleteTextures) a big texture (title screen) will kill all performance until a hard simulator restart.
Testing your "logic" on the simulator and "assuming" it will be fast on the device has been working pretty good for us.
As always: Try avoiding state changes!
And yes: PVR textures are supported, but simulated in the shader.
Yes, simulator supports PVRTC textures, but probably does decompression into RGB format during upload or when texture is used for the first time. In my game it causes big slowdown until every PVR texture is shown at least once. Of course, those slowdowns appear in simulator only and on actual device PVRTC textures are very very fast.
The iPhone simulator is notorious about being almost like the iPhone.
I cannot speak about PVR textures, as I am not sure. But, from other things I have done (and from what I read on the internet) most developers give up on the simulator rather quickly due to its minor differences from the real thing.
In the end if it works on the iPhone, then the simulator doesn't matter.