ACM Mid-Southeast Slides


Published on

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Goals of this project was to explore and asses the iPod touch as a development platform for future inclusion in the Games Development track at CSU.We specifically selected OpenGL ES as one of our environments.Foreshadows: Quartz, Apple’s 2D drawing package was probably a better idea.
  • Apple’s marketing materials for the fall of 2009 specifically spin the iPod touch as a gaming device in addition to it’s pocket computer and music playing capabilities.Over 75,000 games on the Apple App StoreRelevance to students, both in interest and marketable skills
  • Objective-C is the preferred development language for the iPhone OS.However, you may also use C/C++, though the documentation on using the Core Foundation data structures are much more complex.
  • Next 4 slidesTalkabout relation between Rectangle * and id types.Interleave arguments and labelsField access is actually a message, as we’ll see.
  • all fields/members are private.access is granted through @propertyoptions include nonatomic, readonly, and custom names of the methods called upon assignment/read.defaults allow you to define your own get or set messages-/+ methods (class/instance)
  • synthesize completes the @property directive.discuss initialization methods, self pointer, super pointerinitialization methods are not really special
  • Give a few minutes to memory function.
  • no rendering directly to screenTile Based Diferred Rendering (TBDR)rendering is “lazy”, polygons are culled early and pixels are calculated in tiles laid out like a grid on the screenEAGL is a companion API that connects OpenGL ES to core AnimationOpenGL ES talks to 3D hardware, PowerVR MBX/SGX, it does the math and produces a bunch of pixels.pixels go back to main memory, then get pulled through Core Animation to be displayed.
  • Talking points:C API: extrapolate, no extra slidesGLU functions: perspective, Mesa3DObject Selection: addressed directlyFramework: express what you wanted out of the framework and what sorts of design missteps you found
  • Problems:Requires an entirely new set of frame buffer objects to be allocated, rendered to, read from, and deallocated.FBO’s are documented sparsely on Khronos’s site, requireing you to reference SGI’s full EXT_framebuffer_object documentation.There is little in the way of example code or discussion to be found past “How do you do it” and “draw into a side framebuffer and read the pixel data.
  • Way too much computation for the iPhone.
  • Discussion:This does present a bit of cheating. It breaks the whole re-useable framework idea, making it specific to the world. However, taps are handled in the Game class tree, so perhaps by delegating the tap handling to the custom code, it’s still a framework. Just not as reusable.
  • ACM Mid-Southeast Slides

    1. 1. Adventures in OpenGL ES<br />Or: What Not To Expect From OpenGL ESPresented by: David Kolb, Undergrad, Columbus State University<br />
    2. 2. Why iPhone/iPod Touch?<br />Copyright Apple, 2009. Source:<br />
    3. 3. Requirements<br />Requirements:<br />An Intel Mac<br />An iPod Touch<br />Development License<br />iPhone Developer University Program<br />Free for degree-granting institutions<br />Allows for a development team of up to 200 student developers.<br />
    4. 4. Programming for iPhone OS<br />Objective-C<br />The OpenGL ES Pipeline<br />
    5. 5. Objective-C<br />
    6. 6. Obj-C Crashcourse<br />Creating a new object:<br />Rectangle *rect = [[Rectangle alloc] init];<br />id rect = [Rectangle alloc];<br />Sending a message:<br />[rectinitWithWidth: 30 andHeight: 45<br />int area = [rect area];<br />Accessing a field<br />rect.width = 10;<br />
    7. 7. Obj-C Crashcourse<br />Defining a class:<br />@interface Rectangle : NSObject {int width;int height;}@property (nonatomic) int width, height;-(id) init;-(id) initWithHeight: (int) handWidth: (int) w;-(int) area;@end<br />
    8. 8. Obj-C Crashcourse<br />Implementing a class<br />@implementation Rectangle@synthesize width, height;-(id) init{ self = [super init]; if (self) {self.width = 0;self.height = 0; } return self;}@end<br />
    9. 9. Obj-C Crashcourse<br />SelectorsSEL draw = @selector(“draw”);SEL init = @selector(“initWithHeight:andWidth:”);if([rectrespondsToSelector:draw]) {...}<br />Can freely mix in C-style arrays, pointers, calls to malloc() and free().<br />Obj-C class pointers managed through retain, release, autorelease messages[rect release];<br />
    10. 10. OpenGL ES<br />Source: iPhone Game Development Technologies, Part 1<br /><br />
    11. 11. OpenGL ES Continued<br />Geometry<br />glVertexPointer, glNormalPointer, glTexCoordPointer<br />Points, Lines, Triangles, Triangle Fans, Triangle Strips<br />glDrawArrays, glDrawElement<br />Textures<br />8888, 4444, and more.<br />PVRTC<br />2D only<br />iPhone hardware optimized for floats, not double’s or fixed.<br />
    12. 12. The Game<br />A clone of other “block” exploding games.<br />Select an orb of a particular color, if it neighbors at least one orb of the same color, all orbs of the same color connected to that orb will be removed from the game.<br />The remaining orbs fall into the space remaining.<br />Simple enough concept to give experience in the OpenGL ES API and interacting with touches.<br />
    13. 13. The Experience<br />Wrapping a C API in a set of Objective-C classes<br />Lack of glu functions<br />Object selection when receiving a touch event.<br />Writing a framework from scratch<br />
    14. 14. Program Structure<br />Vector3D<br />Required for nearly any work in a 3D space.<br />Supports add and copy operations.<br />Sphere<br />Contains the geometry for the Bubble class.<br />Vertices are computed ahead of time, at application load.<br />
    15. 15. Program Structure<br />Bubble<br />Main “game piece”<br />Maintains a reference to a Sphere<br />Provides bounding boxes and drawing functions<br />Receives an update message for future animation<br />Scene3D<br />Manages, updates, draws objects<br />Manages lights and camera, which have their own objects.<br />
    16. 16. Program Structure<br />BubblesGame<br />Root of game logic and drawing.<br />Receives regular update calls via EAGLView’sdrawView message<br />Receives “taps” via EAGLView’stouchesEnd:Event: message<br />Contains the “game board” and game logic.<br />
    17. 17. Selection<br />No rendering in selection mode.<br />Most commonly suggested solution:<br />Generate and bind an entirely new set of buffers (color, depth, etc.)<br />Disable lighting, fog, and any other features that may change the color of a pixel.<br />Render the entire scene into the buffers, making each object a slightly different color.<br />Read the pixel located under the touch and match the color to one of the objects.<br />
    18. 18. Another Solution<br />Produce the projection and model/view matrices.<br />Multiply the matrices together.<br />Invert the resulting matrix.<br />Multiply the screen coordinates by the inverted matrix, generating a line.<br />Compute the intersection of the line with an object.<br />
    19. 19. My Solution<br /><ul><li>It’s a 2D game.
    20. 20. Use an orthographic projection that aligns 0,0 with one corner of the screen and matches a distance of 1.0 with the length of a pixel.
    21. 21. Simply use screen coordinates as 2D world coordinates with simple adjustments as needed.
    22. 22. Cheating?</li></li></ul><li>Game Logic<br />After selection:<br />Each material has a “name” (an int).<br />Store the name of selected bubble’s material<br />Check all neighbors for matching material names.<br />Anytime a match is found, remove the bubble from the game board and continue searching that bubble’s neighbors for matches.<br />Compact the board, notifying specific bubble’s to animate themselves to new positions on the board.<br />
    23. 23. Foundation Collections<br />NSArray/NSMutableArray<br />Does not accept nil object references.<br />A deletion at n adjusts all elements at valid indices greater than n down by one.<br />The game board needs to accept empty slots.<br />Solution is to use a dictionary with NSNumber objects as keys and the actual Bubble objects as values.<br />
    24. 24. Conclusions<br />Even for very active and animated 2D games, Quartz should be seriously considered and fully discounted before selecting OpenGL ES.<br />Consider using one of the available iPhone game frameworks.<br />Cocos2D<br />Sio2Engine<br />Oolong Engine<br />
    25. 25. Next Steps<br />Complete logic and animations<br />Control the direction of falling/compacting with accelerometer<br />Scoring<br />Endless mode<br />
    26. 26. Demo<br />
    27. 27. Questions<br />
    28. 28. The End<br />