Wednesday, May 26, 2010

Working on Blobs&Globs

I have decided to work on OpenGL by porting a game one of my friends and I designed to the iPhone. The game, called Blobs&Globs, will utilize the iPhone's accelerometer to move onscreen objects through tilt controls.

Other than for a few minor glitches (some flickering and texture overlaps), I have completed the OpenGL portion of the game. Below, I have listed each of the stages I went through to develop the App (I apologize for the odd video sizes; they got stretched somehow):

1. Stagecast Mockup
(Stagecast Creator, a graphical programming environment, was used for prototyping)

2. Starting the App:
-Setting up an orthogonal viewport
-Drawing a moving square from two triangles
-Making multiple squares all use the same geometry to save memory

3. Accelerometer input
-Setting object velocity based on device tilt


4. Handling basic collisions
-Idealist method (test every object for collisions with every object; prevent objects from moving if doing so would make them collide)

5. Texturing
-Making every object appear to be a circle rather than a square

6. Improved Collisions
-Creating a collision grid to prevent slow frame-rates (only objects within the same grid square are tested for collisions)

Future Plans:
-Improve collisions so that they are based on vectors properly
-Finish implementing Blobs&Globs gameplay

My most valuable resources were Beginning iPhone Development: Exploring the iPhone SDK by Dave Mark and Jeff LaMarche and http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

Sunday, January 17, 2010

Textures, Lighting, and Future Approach

I had intended to make updates much more frequently, yet I encountered several difficulties revolving around accessing OpenGL with Objective C. While OpenGL itself is relatively straightforward and is very similar regardless of operating system, performing tasks such as loading textures for use by OpenGL is very complicated. Furthermore, most online OpenGL tutorials are intended for Windows only or are outdated.

By using the "NeHe" OpenGL tutorials and adapting them to the Mac OS X desktop platform, I was able to create a rotating cube and map a texture onto it. However, I was unable to load the texture into the program. I contacted a fellow iPhone programmer I met over the summer, and he helped me find the error in my code.


He also suggested that I switch from the desktop version of OpenGL to OpenGL ES through the iPhone, which uses most of the same OpenGL commands but simplifies the Objective C aspect of OpenGL programming. Many more relevant tutorials exist for the iPhone platform, such as http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html.

Since then, I learned how to apply lighting to a 3D scene:


Next, I will explore materials and textures with OpenGL ES on the iPhone.