1
\$\begingroup\$

While refreshing my mind on OpenGL ES, I decided to read a few of the books I brought a while back and search for some tutorials online.

Whilst doing so, I came across many beginner's tutorials that show how to draw a triangle using simply the followings:

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
....
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

or using simply:

glDrawElements

along with an index buffer.

However to my understanding, is that since OpenGL ES 2.0, one must supply both a vertex and a fragment shader and the modern rendering pipeline is:

Primitive Processing - Vertex Shader - Primitive Assembly - Rasterizer -   
Fragment Shader - Depth Stencil - Color Buffer Blend - Frame Buffer

So my question is, how is it possible for those tutorials to draw without having any vertex nor fragment shaders using just glDrawElements or glDrawArrays? Or, does the program supply them automatically when no shaders are in use and when it detects that either or both glDrawElements and glDrawArrays are in use?

In addition, does the aforementioned flow of pipeline withhold when no shaders are in use?

Thank you.

\$\endgroup\$
2
\$\begingroup\$

OpenGL ES 2.0 requires you to provide a set of shaders (vertex and fragment).

Those examples use the old shader-less OpenGL ES.

For an introduction use the old GLES1. Make sure you can draw something on screen. Then change the code to GLES2 adding the required shaders.

At least at that stage you'll know the issue will likely be in the shaders and not the rest of the draw calls.

Using shaders for 3D games effectively often requires first writing a shader code generator to generate many permutations (no light, 1 directional light, 2 directional lights, etc).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You're right; I guess I was reading between materials that were both GLES1 and GLES2 and got mixed up. Just a quick question, so in the GLES1 era with fixed pipeline, developers could draw only using the glDraw* functions? Thanks. \$\endgroup\$ – Unheilig Oct 1 '16 at 1:46
  • \$\begingroup\$ Technically you can draw rectangles using glClear as well but that's not what it is for. But yes, the main difference between GLES1 and 2 is that 2 requires you to provide shaders. GLES1 was either running on a truly fixed pipeline GPU or the drivers created the shaders for you according to the lights, textures, and other settings. \$\endgroup\$ – Stephane Hockenhull Oct 1 '16 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.