OpenGL ES 2.0的VS OpenGL的3 - 异同 [英] OpenGL ES 2.0 vs OpenGL 3 - Similarities and Differences

查看:265
本文介绍了OpenGL ES 2.0的VS OpenGL的3 - 异同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我读过,看来OpenGL ES 2.0的不是的什么的,比如OpenGL 2.1,这是我从以前承担。

什么我很想知道的是OpenGL的3是否比得上的OpenGL ES 2.0。换句话说,因为我打算做一个游戏引擎为台式机和Android外,还有什么区别,我应该做到心中有数,特别是有关的OpenGL 3.x的+和OpenGL ES 2.0?

这也可以包括的OpenGL 4.x的版本也是如此。

例如,如果我开始阅读本书,我在浪费我的时间,如果我打算端口(当然使用NDK)发动机的Andr​​oid?)

解决方案
  

这是我读过,看来OpenGL ES 2.0的不喜欢的OpenGL 2.1,这是我从以前假设任何事情。

定义是不是像什么吧。桌面GL 2.1有一堆的ES 2.0不具备的功能。但有两个,将工作在两个(但你必须捏造的东西纹理图像加载,因为有一些显著差异有)一个主要公共子集。

桌面GL 3.x提供了很多功能,取消扩展ES 2.0根本没有。帧缓冲区对象是核心3.x中,而他们在扩展2.0(即使在那时,你只能得到没有其他分机一个目的地形象)。有变换的反馈,整数纹理,统一缓冲对象和几何着色器。这些都是具体的硬件特性,要么不在ES 2.0中可用,或者只能通过扩展。其中一些可能是特定于平台的。

不过也有适用于台式机GL 3.x的一些很好的API,方便等特点明确属性的位置(布局(位置=#)),VAOs等。

  

例如,如果我开始读这本书,我在浪费我的时间,如果我打算端口发动机的Andr​​oid(当然使用NDK))

它,而取决于你有多少工作打算做,你就ppared做,使其工作$ P $什么。最起码,你应该什么OpenGL ES 2.0的不读了,这样就可以知道它是如何不同于桌面GL。

可以很容易地避免了实际的硬件功能。渲染到纹理(或多个纹理)的东西,是由你的算法要求。由于是改造的反馈,几何着色器等,所以你需要多少就取决于你想要做什么,并有可能会根据算法的替代品。

您很可能会被逮住的事情是的便利的桌面GL 3.x的功能例如:

 布局(位置= 0)vec4位置;
 

这是不可能的ES 2.0。类似的定义是:

 属性vec4位置;
 

这将工作在ES 2.0,但它的没有的导致位置属性要与属性索引0有关联通过code来完成,使用 glBindAttribLocation 前该程序链接。桌面GL还允许这一点,但是这本书您链接到不这样做。由于显而易见的原因(这是一个3.3为基础的书,而不是一个试图维持与旧GL版本的兼容性)。

统一缓冲区是另一回事。这本书使的自由主义的利用起来,尤其是对于共享的视角矩阵。这是一个简单而有效的技术为那个。但是ES 2.0不具备该功能;它只有在每个程序的制服。

同样,你可以code到公共子集,如果你喜欢。也就是说,你可以故意放弃使用显式属性的位置,统一缓冲区,顶点数组对象等。但是,这本书是不完全会帮助你要么做到这一点。

会不会是在浪费你的时间?那么,这本书不是教你对OpenGL 3.3 API(它确实做到这一点,但是这不是问题的关键)。这本书教你的图形编程;它只是恰巧使用3.3 API。你学的技能有(除了那些基于硬件的那个)转让给任何API或系统,您使用的是涉及着色器。

这样说吧:如果你不知道图形编程非常多,这不要紧,你用什么样的API来学习。一旦你掌握的概念,你可以阅读各种文档,了解如何将这些概念应用到任何新的API很轻松了。

From what I've read, it appears that OpenGL ES 2.0 isn't anything like OpenGL 2.1, which is what I assumed from before.

What I'm curious to know is whether or not OpenGL 3 is comparable to OpenGL ES 2.0. In other words, given that I'm about to make a game engine for both desktop and Android, are there any differences I should be aware of in particular regarding OpenGL 3.x+ and OpenGL ES 2.0?

This can also include OpenGL 4.x versions as well.

For example, if I start reading this book, am I wasting my time if I plan to port the engine to Android (using NDK of course ;) )?

解决方案

From what I've read, it appears that OpenGL ES 2.0 isn't anything like OpenGL 2.1, which is what I assumed from before.

Define "isn't anything like" it. Desktop GL 2.1 has a bunch of functions that ES 2.0 doesn't have. But there is a mostly common subset of the two that would work on both (though you'll have to fudge things for texture image loading, because there are some significant differences there).

Desktop GL 3.x provides a lot of functionality that unextended ES 2.0 simply does not. Framebuffer objects are core in 3.x, whereas they're extensions in 2.0 (and even then, you only get one destination image without another extension). There's transform feedback, integer textures, uniform buffer objects, and geometry shaders. These are all specific hardware features that either aren't available in ES 2.0, or are only available via extensions. Some of which may be platform-specific.

But there are also some good API convenience features available on desktop GL 3.x. Explicit attribute locations (layout(location=#)), VAOs, etc.

For example, if I start reading this book, am I wasting my time if I plan to port the engine to Android (using NDK of course ;) )?

It rather depends on how much work you intend to do and what you're prepared to do to make it work. At the very least, you should read up on what OpenGL ES 2.0 does, so that you can know how it differs from desktop GL.

It's easy to avoid the actual hardware features. Rendering to texture (or to multiple textures) is something that is called for by your algorithm. As is transform feedback, geometry shaders, etc. So how much you need it depends on what you're trying to do, and there may be alternatives depending on the algorithm.

The thing you're more likely to get caught on are the convenience features of desktop GL 3.x. For example:

layout(location = 0) in vec4 position;

This is not possible in ES 2.0. A similar definition would be:

attribute vec4 position;

That would work in ES 2.0, but it would not cause the position attribute to be associated with the attribute index 0. That has to be done via code, using glBindAttribLocation before the program is linked. Desktop GL also allows this, but the book you linked to doesn't do it. For obvious reasons (it's a 3.3-based book, not one trying to maintain compatibility with older GL versions).

Uniform buffers is another. The book makes liberal use of them, particularly for shared perspective matrices. It's a simple and effective technique for that. But ES 2.0 doesn't have that feature; it only has the per-program uniforms.

Again, you can code to the common subset if you like. That is, you can deliberately forgo using explicit attribute locations, uniform buffers, vertex array objects and the like. But that book isn't exactly going to help you do it either.

Will it be a waste of your time? Well, that book isn't for teaching you the OpenGL 3.3 API (it does do that, but that's not the point). The book teaches you graphics programming; it just so happens to use the 3.3 API. The skills you learn there (except those that are hardware based) transfer to any API or system you're using that involves shaders.

Put it this way: if you don't know graphics programming very much, it doesn't matter what API you use to learn. Once you've mastered the concepts, you can read the various documentation and understand how to apply those concepts to any new API easily enough.

这篇关于OpenGL ES 2.0的VS OpenGL的3 - 异同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆