I'm currently working on some drawing routines using geometry generated at runtime and only flat colored. While searching for a minimal GL setup to do my drawing (I'm matching the screen resolution and on I'm iOS, but the question holds for other ES 2 platforms as well), I'm seeing that most examples use vertex and fragment shaders, but not all of them.
If I don't plan to use any textures or lighting (just direct color copying/blending) and I don't plan on doing any transformations that can't be done by manipulating the view matrix, do I really need to set up vertex and/or fragment shaders? If not, is there any advantage to using shaders over a shader-less approach?
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."
来源:https://stackoverflow.com/questions/15513414/opengl-es-2-are-vertex-and-fragment-shaders-necessary-for-simple-drawing