On 19 April 2012 09:16, Joseph Stewart <joseph.stew...@gmail.com> wrote:
>
> Anyone here know if it's a model to learn from?


Another glance, and I'd say it's similar to the others (except for the
onXYZ style of programming).
Because GL is fairly big and complicated, everyone copies the original
interface conventions precisely.
That way you can look it up in the manual. Unfortunately, it means you
get FORTRAN in every language.
(The original target might have been C, but it looks like "FORTRAN in
any language". There are older
graphics interfaces in C that have data structures, so it's not impossible.)
Thus, you get



// Enabled the vertices buffer for writing and to be used during
// rendering.
                gl.glFrontFace(GL10.GL_CCW); // OpenGL docs
                // Enable face culling.
                gl.glEnable(GL10.GL_CULL_FACE); // OpenGL docs
                // What faces to remove with the face culling.
                gl.glCullFace(GL10.GL_BACK); // OpenGL docs

                // Enabled the vertices buffer for writing and to be used during
                // rendering.
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);// OpenGL docs.
                // Specifies the location and data format of an array of vertex
                // coordinates to use when rendering.
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, // OpenGL docs
                                 vertexBuffer);

                gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,// OpenGL 
docs
                                  GL10.GL_UNSIGNED_SHORT, indexBuffer);

                // Disable the vertices buffer.
                gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); // OpenGL docs
                // Disable face culling.
                gl.glDisable(GL10.GL_CULL_FACE); // OpenGL docs

Note the state, and the stylish "gl.gl...". Stutter and suffer!

"But wait!", I hear you cry. State, callbacks, no data structures to
speak of, ... why don't we look
at how they handle this stuff in ... Haskell! (Monads, and a learning
curve, though you can then build
up something that's not entirely graphics machine code.)

Reply via email to