本文介绍了在iOS上使用OpenGL ES 2.0进行实例化绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简而言之:

任何人都可以确认是否可以使用内置变量 gl_InstanceID (或 gl_InstanceIDEXT )在iOS上使用OpenGL ES 2.0且启用了 GL_EXT_draw_instanced 的顶点着色器?

Can anyone confirm whether it is possible to use the built-in variable gl_InstanceID (or gl_InstanceIDEXT) in a vertex shader using OpenGL ES 2.0 on iOS with GL_EXT_draw_instanced enabled?

更长:

我想使用绘制对象的多个实例和,我希望我的应用程序能够运行多个平台,包括iOS。

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

规范明确指出这些功能需要ES 3.0。根据 ES 3.0仅适用于少数设备(基于A7 GPU;因此适用于iPhone 5s,但不适用于iPhone 5或更早版本)。

The specification clearly says that these features require ES 3.0. According to the iOS Device Compatibility Reference ES 3.0 is only available on a few devices (those based on the A7 GPU; so iPhone 5s, but not on iPhone 5 or earlier).

所以我的第一个假设是我需要避免在较旧的iOS设备上使用实例绘图。

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

然而,在兼容性参考文档中,它表示所有SGX Series 5处理器均支持扩展(包括iPhone 5和4s)。

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

这让我觉得我确实可以在旧的iOS设备上使用实例绘图,通过查找并使用适当的扩展功能(EXT或ARB)来实现。

This makes me think that I could indeed use instanced drawing on older iOS devices too, by looking up and using the appropriate extension function (EXT or ARB) for glDrawArraysInstanced.

我目前正在使用和所以我还没有在iOS上测试任何东西。

I'm currently just 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'm having trouble using the gl_InstanceID built-in variable in a vertex shader. I'm getting the following error message:

在GLSL中启用draw_instanced扩展名无效:

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

#extension GL_ARB_draw_instanced : enable
#extension GL_EXT_draw_instanced : enable

错误消失时我特别声明我需要ES 3.0(GLSL 300 ES):

The error goes away when I specifically declare that I need ES 3.0 (GLSL 300 ES):

#version 300 es

虽然在ES 2.0上下文中我的Windows桌面计算机似乎运行正常但我怀疑这适用于iPhone 5。

Although that seem to work fine on my Windows desktop machine in an ES 2.0 context I doubt that this would work on an iPhone 5.

那么,我是否应该放弃能够在较旧的iOS设备上使用实例绘图的想法?

So, shall I abandon the idea of being able to use instanced drawing on older iOS devices?

推荐答案

来自:

它们可用于所有GPU,PowerVR SGX,Apple A7,A8。

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

(看起来@ Shammi没有回来......如果他们这样做,你可以改变接受的答案:)

(Looks like @Shammi's not coming back... if they do, you can change the accepted answer :)

这篇关于在iOS上使用OpenGL ES 2.0进行实例化绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:29