Pro OpenGL ES for iOS

(singke) #1

CHAPTER 8: Putting It All Together (^279)
Listing 8-15a. The header for creating a label texture
#import <Foundation/Foundation.h>
@interface OpenGLText : NSObject
{
GLuint m_Name;
NSUInteger m_Width;
NSUInteger m_Height;
GLfloat m_MaxS;
GLfloat m_MaxT;
}
-(id)initWithText:(NSString)string size:(CGSize)size
alignment:(UITextAlignment)alignment font:(UIFont
)font;
-(void)renderAtPoint:(CGPoint)point depth:(CGFloat)depth red:(float)red
green:(float)green blue:(float)blue alpha:(float)alpha;
-(void)drawAtPoint:(CGPoint)point depth:(GLfloat)depth red:(GLfloat)red
green:(GLfloat)green blue:(GLfloat)blue alpha:(GLfloat)alpha tname:(GLuint)tname;
@end
Listing 8-15b. The body for creating a label texture
#import "OpenGLSolarSystem.h"
#import "OpenGLText.h"
#import "OpenGLCreateTexture.h"
@implementation OpenGLText
-(id)initWithText:(NSString)string size:(CGSize)size
alignment:(UITextAlignment)alignment font:(UIFont
)font //1
{
NSUInteger width;
NSUInteger height;
NSUInteger i;
CGContextRef context;
void data;
CGColorSpaceRef colorSpace;
GLint saveName;
glEnable(GL_TEXTURE_2D);
width = size.width;
if((width != 1) && (width & (width - 1))) //2
{
i = 1;
while(i < width)
i
= 2;

Free download pdf