CHAPTER 8: Putting It All Together (^277)
Note If you want to draw really big stars, there is a limit to the maximum size that varies
from machine to machine. You can check the size range using the glGetFloatv() call, in
line 7. The simulator shows a range from .1 to 511 pixels, while the iPad 1 shows it as 1 to
- Note that single pixel points are almost impossible to see on the Retina display.
Figure 8-7. From left to right, a close-up on an 8-pixel-wide unsmoothed point, with
smoothing, and with smoothing and blending
In line 8 we can finally draw the stars, followed by just some basic
cleanup stuff.
I decided to add a utilities object, because the project gets a little more complicated.
Create OpenGLUtils as a singleton, and add the contents of Listing 14.
Listing 8-14. A helper function to convert spherical coordinates to rectangular added to OpenGLUtils
#import "OpenGLSolarSystem.h"
#import "OpenGLUtils.h"
static OpenGLUtils *m_Singleton;
@implementation OpenGLUtils
+(OpenGLUtils *)getObject
{
@synchronized(self)
{
if(m_Singleton==nil)
{
[[self alloc]init];
}
}
return m_Singleton;
}