• Save
ACM Mid-Southeast Slides
Upcoming SlideShare
Loading in...5
×
 

ACM Mid-Southeast Slides

on

  • 537 views

 

Statistics

Views

Total Views
537
Views on SlideShare
537
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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 ACM Mid-Southeast Slides Presentation Transcript

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