Muteking
Muteking

Reputation: 1513

Vertices in OpenGL es 2. Java for Android

I'm following this tutorial, to learn OpenGl es 2.0. Those informations (plus a lot of others tutorials) led me to this: vertices must be declared in an array, the array must be sent to the GPU memory with FloatBuffer operations, from there they must be picked up by openGL. What follows is a little bit obscure, to me. The question is: once the vertices are there (in the gpu memory) what part of a java program is meant to pick up these data? The shader and fragment code? The vertexattrib array commands?

Upvotes: 0

Views: 87

Answers (1)

Reto Koradi
Reto Koradi

Reputation: 54572

The way OpenGL works on a very basic level, not much really happens until you issue a draw call, like glDrawArrays or glDrawElements. Most other calls just set up state that will be used by the draw calls. The most important parts of state are what you have already seen:

  • glVertexAttribArray and related calls are used to specify the vertex data used for the draw call.
  • glUseProgram, and all the calls you use before that to build a program, specify what shaders will be run for your draw call.

Once you have all this state set up, and issue a draw call, you set the whole machinery in motion. If you want to read up on details on everything that happens here, you should be able to find good material with search terms like "OpenGL rendering pipeline", or in any OpenGL book. Very roughly, the main steps are the following:

  • A fixed function unit grabs the vertex data based on the state you set up with glVertexAttribArray and related calls, and feeds that data into the vertex shader.
  • The vertex shader you set up receives this vertex data in its attribute variables, and processes it.
  • The processed vertices produced by your vertex shader are rasterized by a fixed function unit, which decides which pixels need to be rendered.
  • Those pixels (aka fragments) are fed into the fragment shader.
  • The fragment shader you set up processes these fragments, and outputs the color for the fragments.
  • The colors produced by your fragment shader are written to the framebuffer.

There's more to it than what I listed here, but I hope this will help you understand the basics.

Upvotes: 1

Related Questions