Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitehexagon

macrumors regular
Original poster
May 12, 2007
147
0
I'm not interested in the iPhone ES2 template. I'm looking for doing OpenGL ES2 on the desktop, possibly targeting 'Mac App Store'.

Firstly is ES2 supported on the desktop via Xcode? Is there a template someplace for this?

I've tried porting a sample iOS ES2 project to a desktop project and I'm currently looking at 1500+ errors and have no idea what I'm doing really.

Ideally I'm looking for a sample desktop OpenGL ES2 project, or an xcode template for generating such a project. It must be ES2, not regular OpenGL or ES1.
 
It must be ES2, not regular OpenGL or ES1.

OpenGL ES 2 is just a subset of OpenGL 2. So using the standard OpenGL on Mac OS X (at the time of writing OpenGL 2.1) should be fine. Mac OS X does not have a specific OpenGL ES framework so no matter what you do you'll have to link against the regular OpenGL framework. You'll then just need to make sure you stick to the parts of the OpenGL spec which are supported in OpenGL ES 2.
 
thanks.
Interesting, do you know if the shaders are still going to be compatible back to ES2 then? I'm thinking to use ES2 so I have a good starting point to port to mobile devices later.

Also is there even a standard desktop OpenGL template for XCode then?
 
thanks.
Interesting, do you know if the shaders are still going to be compatible back to ES2 then? I'm thinking to use ES2 so I have a good starting point to port to mobile devices later.

There will most likely be differences. Particularly in what the devices can handle since mobile devices are significantly slower than desktop machines and significantly more memory restrained.

Also is there even a standard desktop OpenGL template for XCode then?

No. Not hard to do though. Just add the OpenGL framework to the project and possibly the GLUT project (not recommended) then just include the OpenGL/OpenGL.h header file and away you go.

Using something like GLEW might be a good idea as well. OpenGL on the desktop is a bitch to get all the extensions done correctly.
 
I'm not interested in the iPhone ES2 template. I'm looking for doing OpenGL ES2 on the desktop, possibly targeting 'Mac App Store'.

Firstly is ES2 supported on the desktop via Xcode? Is there a template someplace for this?

The Mac version of OpenGL is roughly at version 3.0. OpenGL 3 is not cross compatible with OpenGL ES 2.0, but you'll find that it is nearly compatible. OpenGL 4.0 will be fully compatible with OpenGL ES 2.0.

OpenGL ES 2.0 is basically the subset of OpenGL 2.0 that form "best practices" ... plus a few things extra. For that reason porting from OpenGL desktop version to OpenGL ES 2.0 can be a nightmare (if deprecated functions are used), but porting from OpenGL ES 2.0 to the desktop version is straightforward.

The main things you'll have to do in your code is change a handful of function names (eg glBindVertexArrayOES -> glBindVertexArrayAPPLE) and remove the precision qualifiers from your OpenGL ES 2.0 shaders (delete "lowp", "mediump", "highp", etc).

I've tried porting a sample iOS ES2 project to a desktop project and I'm currently looking at 1500+ errors and have no idea what I'm doing really.

Ideally I'm looking for a sample desktop OpenGL ES2 project, or an xcode template for generating such a project. It must be ES2, not regular OpenGL or ES1.

Just create a Mac project with an NSOpenGLView and put your OpenGL ES 2.0 code there. It should be straightforward to make the small number of changes necessary for the code to run on Mac. The setup for OpenGL on Mac is simpler than the setup for OpenGL ES 2.0 on iPhone because there is no need to set up render buffer or frame buffer objects.
 
Last edited:
You should be interested in the iOS Open GL ES 2 template. Not for making an iOS app. But for checking the compatibility of the cross-platform portion of your Open GL code. Check the errors and warnings, forget the rest of the iOS build, and then use the compatibility-checked code in your Mac template.
 
Thanks all. I found a simple project for the desktop and it's starting to make more sense. ie I hadn't realised Touch? was mostly duplicated in OSX but under different names UI vs NS etc. They don't like to make things easy! (well apart from garbage collection under desktop which i guess I also have to avoid to stay portable). But actually the OpenGL stuff doesn't look too bad... I might take the route of developing under iOS for now then since that is what I'm most familiar with. Hopefully I can abstract the rendering out of everything else and maybe work out how to generate two targets from the same XCode project... well maybe I'm getting ahead of myself there. First I want to work out fullscreen mode for the desktop :)

Somehow it would be nice the the iOS code just ran on the desktop, I mean the simulator can handle it, so why not just make the simulator part of OSX :)

anyway thanks again all.
 
Thanks all. I found a simple project for the desktop and it's starting to make more sense. ie I hadn't realised Touch? was mostly duplicated in OSX but under different names UI vs NS etc. They don't like to make things easy! (well apart from garbage collection under desktop which i guess I also have to avoid to stay portable). But actually the OpenGL stuff doesn't look too bad... I might take the route of developing under iOS for now then since that is what I'm most familiar with. Hopefully I can abstract the rendering out of everything else and maybe work out how to generate two targets from the same XCode project... well maybe I'm getting ahead of myself there. First I want to work out fullscreen mode for the desktop :)

Somehow it would be nice the the iOS code just ran on the desktop, I mean the simulator can handle it, so why not just make the simulator part of OSX :)

anyway thanks again all.

The simulator renders OpenGL ES using a software renderer (that's why we can't just run OpenGL ES code on Mac). GPU support would require OpenGL version 4. Perhaps eventually we will be able to run iOS code on some Mac ... maybe in 5 years, who knows (I'm imagining a tiny touchscreen Mac that runs ARM and can run an ARM version of Mac OS X and also iPad / iPhone applications).
 
WebGL manages to run fine on a mac and I'm fairly sure that isn't software rendered?
 
WebGL manages to run fine on a mac and I'm fairly sure that isn't software rendered?

The browser is simply putting a wrapper around OpenGL. It's not using OpenGL ES. Also WebGL doesn't support compressed textures, but OpenGL ES 2.0 is required to support certain formats -- formats that normally don't exist on a desktop. So there are small enough differences that make supporting OpenGL ES 2.0 on a desktop require special driver support. This will likely come soon.
 
Last edited:
Interesting, so we are basically waiting on Apple to update to OpenGL 4.1 at which point the cross device OpenGL ES2 becomes more of a reality. Which probably means a new OS release and at this rate a new MBP (well, if they switch back to NVidia) :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.