OpenGL ES 2: Are vertex and fragment shaders necessary for simple drawing?

纵然是瞬间 提交于 2019-12-04 10:25:50

As far as I know, yes, they are necessary. OpenGL ES 2.0 is not backward compatible with OpenGL ES 1.x and the main differences between the two are custom shaders.

The advantage of using shaders (2.0) or not (1.x) depends on your application's current and long-term functionality, but the fixed-function pipeline of 1.x is quickly becoming a thing of the past. The recently released OpenGL ES 3.0 specification is backward compatible with 2.0, but not 1.x.

OpenGL ES 2.0 uses a programmable pipeline, so you must always declare a vertex and a fragment shader. The simplest ones you can declare for geometry + color are:

// Vertex Shader

attribute vec3 position;

void main(void)
{
     gl_Position = vec4(position, 1.0);
}

and:

// Fragment Shader

uniform lowp vec3 color;

void main(void)
{
     gl_FragColor = vec4(color, 1.0);
}

Source: Khronos Website & Docs

"The significant change in the OpenGL ES 2.0 specification is that the OpenGL fixed function transformation and fragment pipeline is not supported."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!