Screen Drawing with OpenGL ES 2.0 on iOS

In short:

Can anyone confirm if it is possible to use inline variable gl_InstanceID

(or gl_InstanceIDEXT

) in a vertex shader using OpenGL ES 2.0 on iOS with GL_EXT_draw_instanced

enabled?


longer:

I want to draw multiple instances of an object using glDrawArraysInstanced and gl_InstanceID and I want my app to run on multiple platforms including iOS.

The spec clearly states that these features require ES 3.0. As per the device compatibility link, iOS ES 3.0 is only available on a handful of devices (powered by A7 GPU, so iPhone 5s, but not iPhone 5 or earlier).

So my first guess was that I needed to avoid using inline drawing on older iOS devices.

However, further down in the compatibility reference document, it says that EXT_draw_instanced is supported for all SGX Series 5 processors (including iPhone 5 and 4).

This leads me to think that I could actually use instantiated drawing on older iOS devices by browsing and using the appropriate extension function (EXT or ARB) for glDrawArraysInstanced .

I am currently running some test code using SDL and GLEW on Windows, so I haven't tested anything on iOS yet.

However, in my current setup, I am having a problem using the built-in gl_InstanceID variable in the vertex shader. I am getting the following error:

'gl_InstanceID': variable not available in current GLSL version

Enabling the "draw_instanced" extension in GLSL has no effect:

#extension GL_ARB_draw_instanced : enable
#extension GL_EXT_draw_instanced : enable

      

The error disappears when I specifically state that I need ES 3.0 (GLSL 300 ES):

#version 300 es

      

While this seems to work fine on my Windows desktop machine in an ES 2.0 context, I doubt it will work on an iPhone 5.

So, should I ditch the idea of ​​using instantiated drawing on older iOS devices?

+3


source to share


1 answer


From here :

Screen drawing is available primarily in the OpenGL ES 3.0 API and in OpenGL ES 2.0 through the EXT_draw_instanced and EXT_instanced_arrays extensions.



You can see that it is available on all of their GPUs, PowerVR SGX, Apple A7, A8.

(Looks like @Shammi won't return ... if they do, you can change the accepted answer :)

+3


source







All Articles