Monday, December 29, 2008

Where Am I?

I've spent the day figuring out where I am.  No, not where I am in the project.  So far, I'm 25 days into this project and I know where I am, and actually ahead of where I had set goals for myself.  No, the where I am that I have spent the day on is, where I am when I go from iPhone screen coordinates to OpenGl ES coordinates.  

The iPhone is 320x480, but really 320x460 (the top 20 pixels is used for the iPhone Status Bar), with its origin at the top, left. OpenGl's origin is bottom, left.  So, that translation isn't difficult, but when I flipped the phone to landscape mode (which my game will be playing in) and I want the display to orient itself properly if the player rotates the device left or right, this is so if a left-handed player likes the thumb stop button in his/her right hand, then the change in viewport coordinates, and the OpenGl coordinates get all funky.  

On Windows or Mac OpenGL programming you have at your disposal "gluUnProject," to handle the conversions for you.  You just have to pass it the modelview, projection, and viewport matrices, along with screen coordinates, and it spits back to you the OGL coordinates.  However, in OpenGL ES none of the glu, glut, or glui is available.  So, I had to scrounge around to find the source(s) for the "gluUnProject," and hammer it into my test code.  

I'm glad to say that it is passing back coordinates that look reasonable.  Next up, I will code up the handling of the "touch," events, so that I can verify for sure when I flip the iPhone (I have an iTouch), and touch the screen that I am getting the correct coordinates.

I've also been testing things out in OpenGl and learning the changes, what I can and can't do in Opengl ES.

So, where am I, in regards to my early, high level, tasks I gave myself when I began...

Key (red = task completed, green = in progress, black = not started)
Tasks/Status

1) Learn the iPhone Tech
* Download/install iPhone
SDK
* Upgrade Mac OS $130

* Join iPhone Dev $99
* Read iPhone Docs/Samples
** iPhone OS Technology Overview
** Cocoa Fundamentals Guide
** iPhone Application Programming Guide
** iPhone Human Interface Guidelines
** iPhone Development Guide

** The Objective-C 2.0 Programming Language
** Write little tests programs to learn the iPhone Capabilities (memory allocation, file I/O, iPhone audio, WiFi, graphics, etc...) - (sprite displayed by Dec. 15th)

2) Test my game concepts out on the iPhone
3) Build tool(s) if needed
4) Solidify Game Design
5) Architect the game code
6) Develop game w/ scratch art
7) Drop in real assets
8) Test/Debug
9) Ship It

This is the high view of where am I.  The milestones I had set for myself this month I have met, and still have a week to go, so I am ahead.  My goal for the end of next month is to have a basic prototype of the game running with scratch art, have all the general mechanics figured out and working.  The prototype code is "throw away," code, it is quick and dirty code so I know that what I want to do I can do.  When I am confident I know all I need to, to do the game, then I will design the architecture and begin coding my engine.

Now, where's my bed?

2 comments:

xenon said...

I'm trying to solve the gluUnProject migration problem. I got the source code from MESA CVS and had to change the GLdouble to GLFloat, and also changed any fabs to fabsf. However it is still giving me incorrect results. It's always giving me back the middle of the screen. How did you convert the code for Opengl ES?

xenon said...

I have found the solution to my problem. I had to project twice, once from the far plane and another for the near plane and then get the intersection with a plane. I have posted the code on my blog.