

This means there is more setup code required to render than there was in desktop OpenGL using fixed function processing. For those of you not familiar with desktop OpenGL, you will also probably think this is a lot of code just to draw a triangle! Remember though, OpenGL ES 2.0 is fully shader based, which means you can't draw any geometry without having the appropriate shaders loaded and bound. For those readers familiar with fixed function desktop OpenGL, you will probably think this is a lot of code just to draw a simple triangle. Just make sure you back up the original triangle.c first.Let's take a look at the full source code for our Hello Triangle example program, which is listed in Example 2-1. The easiest way to get this to run is to download my file and copy it into the hello_triangle folder inside /opt/vc/src/hello_pi. The redraw_scene method is probably what you want to have a look at. I fear this may be some kind of nasty gotcha to do with how data types are held in memory and how the ogles API deals with them.Īnyway here is my code if anyone would like to take a look.

It appears that one of the vertexes in my triangle is way way off the edge of the screen, despite the code all looking correct. The aim is to just draw a red triangle on a grey background, but I can't seem to get my triangle to look right. I have got as far as stage 2 A Look at Simple Drawing and have run into a problem I am hoping someone can help me with. I removed everything to do with the cube but kept everything to do with setting up the screen and frame buffer etc. What I have done is heavily modified the hello_triangle example (supplied with the Debian SD card image) to create a basic OpenGL ES environment within which to try out his code. Although it has been written specifically for the iPhone the OpenGL ES API calls remain the same - so it has been possible for me to convert the code from objective c to c++ on the fly. I have been attempting to follow his guide. I'm trying to learn OpenGL ES from scratch and have been looking around on the net for various guides and one of the most "linked to" ones I found was Jeff LaMarche's OpenGL ES From the Ground Up.
