I've got an iPhone (OpenGL ES 1.1) app that does some rendering into textures. I'm setting up a framebuffer object and using glFramebufferTexture2D to attach the texture to it.
Everything works fine except that the light directions are reversed when drawing into this framebuffer object. I'm specifying light directions like this:
float theDirection[4] = { x, y, z, 0 }
glLightf( lightIndex, GL_POSITION, theDirection )
When rendering without the framebuffer object, all my light directions are correct. When rendering with the framebuffer object, I have to negate theDirection for things to look the same.
As a side note, the light directions are also reversed (with or without a framebuffer object) when I'm running on an iPhone 3G with iOS 3.2. If I'm running on an iPhone or iPad on 4.x, the light directions are not reversed.
Any ideas?
Strangely, the solution here was to enable GL_CULL_FACE. If GL_CULL_FACE is disabled in a MonoTouch project using OpenGL ES 1.1, then the GL lighting direction (for a directional GL_LIGHT0) will be negated on some of the devices or OS versions, I'm not sure which.
xcode-based C++ projects do not have this problem. OpenGL ES 1.1 xcode projects light consistently across all devices and OS versions that I've tested regardless of your GL_CULL_FACE setting.
As compared to the result of identical GL code in a C++ xcode project (which is consistent across devices regardless of GL_CULL_FACE), here are the devices that I see inverted lighting happening on in MonoTouch:
iPad running iOS 4.2.1
iOS simulator running iOS 4.2
iPhone4 running iOS 4.2.1
The lighting is correct on my iPhone 3G running iOS 3.1.2.
I posted a bug report to Novell: https://bugzilla.novell.com/show_bug.cgi?id=679896
Related
So I am using AIR to make a mobile version of a flash game. All the game graphics is transformed into Bitmaps, with the purpose of having high Frame Rates. Everything is fine, except for the iOS version of the game, specifically the iPhone version. On every iPhone I tested, the bitmaps have bad quality. If I play the game on any android device the quality of the game is perfect, same goes if I play on iPad.
I am open to any suggestion.
I am trying to draw some primitives with monogame. I am using the GraphicsDevice and the DrawUserPrimitives method. Although I can see the rectangle I am drawing in an Android device it is missing on the iPhone simulator. Am I missing something or is drawing primitives on the iPhone with monogame not supported?
Are you using the (develop3D branch)[https://github.com/mono/MonoGame/tree/develop3d]?
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. :-)
What are the necessary steps to update an existing OpenGL ES 1.1 based 2D iPhone game to be compatible w/ the iPhone 4's retina display? I'm still using the Texture2D class that came w/ Apple's CrashLanding (download) sample code.
After reading Apple's documentation, watching the WWDC video (session 134 "Optimize Your iPhone App for the Retina Display"), and looking at Cocos2D sample code I'm still confused.
I believe the required steps include:
passing high-res artwork (w/ "#2x" appended) to [UIImage imageNamed:#"image.png"]
changing the "contentScaleFactor" from 1.0 to 2.0 (where?)
updating the arguments to glOrthof to include the contentScaleFactor
adjusting the size of the glViewport
Please note that I'm relatively new to OpenGL.
Thanks for your help!
You should keep the 320x480 image, and provide the 640x960 image with a different name. Suppose the 320x480 image is called foo.png, then name the 640x960 one foo#2x.png.
The system will then automatically select the higher resolution one on iPhone 4, without any change in code — assuming you were using [UIImage imageNamed:#"foo.png"].
I'm running this sample code located here:
http://monoclestudios.com/cocos2d_whitepaper.html
using cocos 2d-iphone 0.7.2, and the sprites are being drawn coloured blue. But this is only happening on the simulator. On an actual device, everything looks fine.
Has anyone else run into this problem?
Don't test OpenGL ES on the simulator. It just isn't the same. The simulator renders slightly differently. Since cocos2d-iPhone is heavily based on OpenGL ES, your only choice is to test on the device!
Unfortunately the simulator isn't identical to the physical iPhone. I haven't encountered this particular bug, but I did have issues with sounds. Wouldn't play on the simulator but worked fine on the device. If you're only having problems on the simulator I'd suggest ignoring the bug and moving forward. The simulator is just for convenience after all.
Checkout #cocos2d-iphone on freenode if you have more questions like this.