In my previous post I discussed how I separated my .NET solution into multiple projects with the goal of having the bulk of my code 100% platform independent. The initial goal of this was to allow me to easily develop with in Visual Studio (VS), but a second and important benefit is it sets me up well to port my game to other .NET platforms like Android and Windows Mobile 7. I also mentioned that the graphics framework I'm targeting is OpenGL ES version 1.1. Although iPhone 4 supports OpenGL ES 2.0, older iPhones do not and I want to support them as well.
To get the full benefits of developing in VS I not only want to be able to compile, but also run my game. To do that I need to be able to render using Open GL ES 1.1. The problem is that this is a version of OpenGL that is for mobile devices. Fortunately, there are a few emulators available for the PC.
After some web searching I found an emulator by from Mali, but when I tried to use it I kept getting this error:
[Error] Failed to create EGL window surface, error 12293. I did a lot of searching and investigation to fix it, but was never able to. I did see one person describe that they were successful, but their suggestions weren't working for me, so I eventually gave up and tried to find another emulator.
Next I found this one from Khronos. It still had a few minor issues, but when I followed the steps described in this thread I got it to work. The thread said that they also managed to get the Mali emulator working, and I don't know why it didn't work for me.
One interesting thing I found with this emulator was that it isn't 100% compatible with the OpenGL ES 1.1 that runs on the iPhone. Specifically the
internalFormatargument passed to
GL.TexImage2Dseems different. In my original iPhone version I passed
All.Rgbafor this, but when I ran this on the PC my textures' colors were strange. After a lot of investigation I finally discovered that changing this to
All.Bgrafixes the problem. I currently have a hack to set this depending on the OS.
bool isWindows = System.Environment.OSVersion.Platform == PlatformID.Win32NT;All format = isWindows ? All.Bgra : All.Rgba;GL.TexImage2D(All.Texture2D, 0, (int)format, width, height, 0, format, All.UnsignedByte, textureData);
I'm not enough of a OpenGL expert to know which is actually correct. It will also be interesting to see how other platforms like Android and Windows Mobile 7 handle this. For now I'm just pretty happy that this was the only platform-dependent adjustment I've had to make.
Next time: OpenAL on Windows.