OpenGlにて文字列を表示したいです。
そこでテクスチャに文字列を貼って、描画しようとしております。
参考URLを見ながら実装しているのですが、
描画すると白いテクスチャが表示されるだけどなってしまいます。
何とかして文字列を表示したいのですが
修正箇所などお分かりの方はおりませんでしょうか。
参考URL
http://objective-audio.jp/2008/12/post-11.html
CGRect imageRect; //文字列用の画像の大きさ
CGContextRef bitmapContext; //文字列用のコンテキスト
Byte *bitmapBuffer; //コンテキストのバッファ
GLuint loadFont(){
// コンテキストの生成
imageRect.size.width = 128;
imageRect.size.height = 128;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef bitmapContext = CGBitmapContextCreate(NULL,
imageRect.size.width, imageRect.size.height, 8,
imageRect.size.width * 4, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
// 文字列を描画
UIGraphicsPushContext(bitmapContext);
UIFont *tFont = [UIFont systemFontOfSize:40];
[[UIColor blackColor] set];
[@"Test String 1234567890" drawAtPoint:CGPointMake(0, 0) withFont:tFont];
[@"日本語もOK!" drawAtPoint:CGPointMake(0, 44) withFont:tFont];
UIGraphicsPopContext();
// イメージを取り出す
CGImageRef image = CGBitmapContextCreateImage(bitmapContext);
CGContextRelease(bitmapContext);
// テクスチャの生成
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
imageRect.size.width, imageRect.size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
CGImageRelease(image);
return texture;
}