Thursday, July 1, 2010

Day Four: First major shift, but for the better

This morning started out a little rough. At the end of the day yesterday I had been messing around with some OpenGL examples, just trying to figure out how to get my own shapes to render. I had found a tutorial on OpenGL ES, but it basically required I use a template provided by the author which I could not get to compile to the correct target device, and wouldn't recognize the SDK changes I made, so I was trying to merge that with the template in XCode. It was getting pretty rough, I could not get the desired results, and I knew the problem. I didn't have a strong enough understanding of the OpenGL pipeline and its ties to the iPhone's view environment.

So, I started to look for a better starting point. I had seen a book while browsing on bn.com, Iphone 3D Programming, so I did a google search for the corresponding site to try and find some sample code. It turns out the entire book is available online, and is updated to the newer APIs! Even better, the book forces the reader to start programming from the base iPhone windowed application, which provides nothing except a basic view. From here, all the OpenGL dependencies are added, and the linking view necessary with OpenGL are created. The pipeline has to be instantiated by hand as well. Those who know the CS side of me know I don't like taking anything granted. I appreciate the low level side of programming, and I prefer to implement as much as I can myself.

So, the book starts off with drawing a simple triangle to the screen. This is much more than just a drawTriangle function. Basically, the API is defined, and a RenderEngine interface is created, and a rendering engine is implemented for API V1.1 and V2.0. From here vertices are defined an objects are built out of vertices and triangles. After implementing this the second chapter takes you through the OpenGL ES methodologies and reintroduces the linear algebra needed for 3D graphics, and than starts on converting the simple triangle example to a 3D cone. Here is where I got to today and will continue with tomorrow.

I plan to work through this entire book, and basically get much more graphics knowledge than needed so as to get as much out of OpenGL as I can. I still plan to do a 2D top-down game, but I think there will be much more of a 3D backend controlling the whole thing. There are lots of optimizations that I would like to get from the book as well. In the end I'll be better off, especially for game number two.

No comments:

Post a Comment