Pro OpenGL ES for iOS

(singke) #1

272 CHAPTER 8: Putting It All Together^


Note A star’s magnitude is its apparent brightness; the larger the value, the dimmer the star
is. The brightest star in the sky is Sirius, at a visual magnitude of -1.46. The dimmest stars
visible to the naked eye are about magnitude 6.5. Binoculars top out at about 10th magnitude,
while the Hubble Space Telescope reaches way out to magnitude 31.5. Each whole number is
a difference of about 2.5 times in actual brightness, so a star of magnitude 3 is about 2.5 times
brighter than one that is magnitude 4.

Besides the triangular faces that OpenGL ES uses for creating solid models, you can
also specify that each vertex of your model be rendered as a point image of a given
magnitude and size. This proves a natural fit for our own little star field. Since this will
eventually be paired up with a number of constellation outlines, let’s create a new object
that will support both kinds of data, as shown in Listings 8-12a and 8-12b. And while
you’re at it, ensure you have OpenGLOutlines.h and .mm from the site.
Listing 8-12a. The Constellation Collection header

#import <Foundation/Foundation.h>
#import "OpenGLOutlines.h"
#import "OpenGLStars.h"

@interface OpenGLConstellations : NSObject
{
OpenGLOutlines *m_Outlines;
OpenGLStars *m_Stars;

}

-(void)execute:(BOOL)constOutlinesOn names:(BOOL)constNamesOn;

@end

Listing 8-12b. The Constellation Collection body

#import "OpenGLConstellations.h"

@implementation OpenGLConstellations


  • (id)init
    {
    self = [super init];


if (self)
{
m_Outlines=[[OpenGLOutlines alloc]init];
m_Stars=[[OpenGLStars alloc]init];
}

return self;
}
Free download pdf