I’m trying (and trying and trying) to display some text on an Iphone using OpenGL ES.
I’m using a Texture2D Class that transform the text in a texture, which is later applied to a quad. What I get on screen is just the quad, with no text inside. Googling around I have found other guys having exactly the same issue, so I’m wondering if anybody here has a hint.
Thanks for any help, the code I’m using is this:
Texture2D* _textures[1];
_textures[0] = [[Texture2D alloc] initWithString:@"0123456789" dimensions:CGSizeMake(1,1) alignment:UITextAlignmentLeft fontName:@"Arial" fontSize:12];
//Set up OpenGL projection matrix
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
//Initialize OpenGL states
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClearDepthf(1.0f);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glViewport(0, 0, backingWidth, backingHeight);
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -10.0f, 10.0f);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0, 0, -9);
glColor4f(0.0f,1.0f,0.0f,1.0f);//Change the object color to green
glBindTexture(GL_TEXTURE_2D, [_textures[0] name]);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[_textures[0] drawAtPoint:CGPointMake(0, 0)];
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];