That's true, there is quite a lot of code to do something simple

Actually, I mixed up my samples a bit,
hello_triangle is simpler! I'm also a complete beginner, but I'll try to walk you through what I have learnt so far
Looking at the makefile in
hello_triangle, it basically sets the specifics of the project, namely the object files generated and the name of the output binary. What is really important is the fourth line, that includes the standard makefile for all of the
hello_pi samples. It is this makefile,
Makefile.include, that provides all of the information about the libraries etc. and how to compile with them. You can use
Makefile.include as is.
What I would do, is copy the
hello_triangle directory somewhere and then start playing around with the copie. You'll need to change that fourth line in
Makefile to make sure it can find
Makefile.include. Also if you create more .c files that need to be linked together, or change their names, you'll need to edit
OBJS, and maybe even
BIN, if you'd like the output binary to be called something else.
So, now looking at the source code, starting with the
main function at the end of the file. Basically, it does some initialization and then starts a loop which repeatedly moves and draws the cube. What is important, is the call to
bcm_host_init: this is specific to the pi, and must be called before any OpenGL function (or maybe it should be called in any program?).
The
init_ogl function is almost entirely for setting up a native window: the first half is concerned with the egl side of things, the second half with wiring it up to the vc side of things. The function finishes with code to clear the newly created surface. Notice also that all of the specifics are saved in the custom
CUBE_STATE_T structure to make it easy to pass them around.
The remaining functions do pretty much what they say they do, although they are not really super simple: setting the projection, loading the textures etc.... I'm still studying them myself. To continue with simple stuff, I'm working through the basics presented in
OpenGL® ES 2.0 Programming Guide,
http://opengles-book.com/, in particular the chapter 2 sample, which you can find here:
http://code.google.com/p/opengles-book- ... Triangle.c