OpenGL ES From the Ground Up - Vertex way off
Posted: Wed Jun 27, 2012 4:59 pm
Hi everyone;
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.
I have been attempting to follow his guide. 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.
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. I removed everything to do with the cube but kept everything to do with setting up the screen and frame buffer etc.
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. 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.
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. 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.
Anyway here is my code if anyone would like to take a look.
triangle.c
The redraw_scene method is probably what you want to have a look at.
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. Just make sure you back up the original triangle.c first.
Any help would be really appreciated!
Thanks!
Dave
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.
I have been attempting to follow his guide. 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.
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. I removed everything to do with the cube but kept everything to do with setting up the screen and frame buffer etc.
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. 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.
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. 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.
Anyway here is my code if anyone would like to take a look.
triangle.c
The redraw_scene method is probably what you want to have a look at.
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. Just make sure you back up the original triangle.c first.
Any help would be really appreciated!
Thanks!
Dave