Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct FontGlyph
- {
- u32 char_code;
- u32 m_x; // base x position on tpage
- u32 m_y; // base y position on tpage
- u32 m_width; // glyph width
- u32 m_height; // glyph height
- i32 m_horiBearingX; // Distance to X shift
- i32 m_horiBearingY; // Distance to Y shift
- u32 m_horiAdvance; // Total Horizontal advance this character requires
- u32 m__tpage_index; // Which tpage does this glyph use?
- };
- UIGraphicsBeginImageContext(yourLabel.frame.size);
- [yourLabel.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage *layerImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- Font font("Verdena");
- font.print("Hello World!", x, y, z);
- font.print(x, y, z) << "fps: " << fps;
- - (void) drawText:(NSString*)theString AtX:(float)X Y:(float)Y {
- // Use black
- glColor4f(0, 0, 0, 1.0);
- // Set up texture
- Texture2D* statusTexture = [[Texture2D alloc] initWithString:theString dimensions:CGSizeMake(150, 150) alignment:UITextAlignmentLeft fontName:@"Helvetica" fontSize:11];
- // Bind texture
- glBindTexture(GL_TEXTURE_2D, [statusTexture name]);
- // Enable modes needed for drawing
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- // Draw
- [statusTexture drawInRect:CGRectMake(X,Y-1,1,1)];
- // Disable modes so they don't interfere with other parts of the program
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
- }
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_ALPHA)
Add Comment
Please, Sign In to add comment