开发者

Android + GL ES 2.0 multi-colored code sample?

开发者 https://www.devze.com 2023-03-11 02:52 出处:网络
Years ago I learned a bit of OpenGL (version 2.0). The basic examples were all very easy. One could draw a colored triangle with a few batch commands (such as glVertex[...]).

Years ago I learned a bit of OpenGL (version 2.0). The basic examples were all very easy. One could draw a colored triangle with a few batch commands (such as glVertex[...]).

Now I get to know, that OpenGL ES 2.0 deprecates the usage of such commands. All examples which I find contain custom shaders, written in some shader language. While it might be gr开发者_运维百科eat for writing high-customizable high-performance apps, it doesn't help a lot when you start learning GL ES 2.0.

Long story short: please provide link or code of the most simple Android GL ES 2.0 app which would draw a multi-colored triangle (and do nothing else).

Thank you!


The fixed-function pipeline APIs (glVertex, et al) are not allowed in OpenGL ES 2.0+.

Here's a link to a multi-colored triangle rendering sample, using OpenGL ES 2.0: http://www.badadev.com/opengl-es-2-0-on-bada-shaders-and-programs/

What differentiates the tutorial above from simpler 'hello world' ones is the slightly more complex vertex shader and how vertex colors are passed to the shader.

If you are working with the Android NDK, a good starting point is the 'hello-gl2' sample that comes with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消