Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-15-2008, 05:25 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: London/Peterborough
Posts: 534
Question OpenGL ES text rendering as a block

Hi, I am trying just to draw some text on the screen with opengl es, I always however end up with the text as a huge green box...any ideas?

code:

- (void)drawView {

[EAGLContext setCurrentContext:context];

_textures[0] = [[Texture2D alloc] initWithString:@"hello" dimensions:CGSizeMake(1, 1) alignment:UITextAlignmentLeft fontName:@"Arial" fontSize:14];

//Set up OpenGL projection matrix
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);

//Initialize OpenGL states
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
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);

glLoadIdentity();

glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

GLfloat line[] = {
-0.5f, -0.5f, //point A
0.5f, -0.5f, //point B
};
GLfloat xxx[] = {
-0.0f, -0.5f, //point A
-0.5f, -0.2f, //point B
};

GLfloat spinline[] = {
-0.5f, 0.0f, //point A
0.5f, 0.0f, //point B
};

glColor4f(0.0f,1.0f,0.0f,1.0f);//Change the object color to green

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[_textures[0] drawAtPoint:CGPointMake(0, 0)];
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

glColor4f(1.0f,0.0f,0.0f,1.0f);

glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );

glVertexPointer(2, GL_FLOAT, 0, line);
glDrawArrays(GL_LINES, 0, 2);

glVertexPointer(2, GL_FLOAT, 0, xxx);
glDrawArrays(GL_LINES, 0, 2);

glVertexPointer(2, GL_FLOAT, 0, spinline);
glDrawArrays(GL_LINES, 0, 2);


glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
QuantumDoja is offline   Reply With Quote
Old 11-19-2008, 02:40 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: London/Peterborough
Posts: 534
Default *bump*

*bump* - anyone have any ideas?
QuantumDoja is offline   Reply With Quote
Old 11-19-2008, 04:43 PM   #3 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 802
Default

Try drawing a simple shape first to make sure your codes working as expect. Next load an image into a texture and use that. If you get those working then double check your usage of the text in texture calls.
scottiphone is offline   Reply With Quote
Old 12-20-2008, 06:36 PM   #4 (permalink)
New Member
 
Join Date: Dec 2008
Posts: 2
Default

Did anyone solve this ? I'm stuck exactly with that green box, and no text showing ...
papillon68 is offline   Reply With Quote
Old 01-13-2009, 10:23 PM   #5 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 1
Default

Try adding:

Code:
glDisableClientState(GL_COLOR_ARRAY);
To Texture2D's drawAtRect and drawAtPoint functions, that ended up working for me.
tophat02 is offline   Reply With Quote
Old 04-23-2009, 03:11 PM   #6 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 1
Default

The thread is now a little bit old, but I came across it while searching to solve the same problem. No luck finding info but I did manage to solve it anyway.

For me I ended up fixing it by figuring out that the GL renderstate was wrong...basically, texturing and blending states were the issues and solved by the first three lines of the following...

Code:
	glEnable(GL_BLEND);
	glEnable(GL_TEXTURE_2D );
	glEnableClientState( GL_TEXTURE_COORD_ARRAY );	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f( 0.0f, 1.0f, 0.5f, 1.0f );
	[texture drawAtPoint:CGPointMake( 0, 0 )];
ME_IS_NSFW is offline   Reply With Quote
Old 04-24-2009, 04:10 PM   #7 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 1
Default

Quote:
Originally Posted by tophat02 View Post
Try adding:

Code:
glDisableClientState(GL_COLOR_ARRAY);
To Texture2D's drawAtRect and drawAtPoint functions, that ended up working for me.
I am having the same problem. My string texture is rendering as a solid color block.

I have the correct blend mode enabled (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)) and I have added glDisableClientState(GL_COLOR_ARRAY); to my drawAtPoint function yet it continues to be a solid block of color

Any ideas on how to fix?

[EDIT]: hahahahahaha oh man, I was just missing glEnable(GL_BLEND); Thanks ME_IS, your post made me double check haha.

Last edited by Proxus; 04-24-2009 at 04:14 PM.
Proxus is offline   Reply With Quote
Old 05-05-2009, 07:33 AM   #8 (permalink)
Registered Member
 
Join Date: Apr 2009
Location: Madurai
Posts: 111
Send a message via MSN to lokidil Send a message via Yahoo to lokidil Send a message via Skype™ to lokidil
Default How to Rotate the text!!!

lBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

Texture2D *text=[[Texture2D alloc] initWithString:@"Hello" dimensions:CGSizeMake(256, 256) alignment:UITextAlignmentLeft fontName:@"Arial" fontSize:14];

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

To display the text above code is ok.Then how to rotate the text using the texture2d class!!!

Last edited by lokidil; 05-05-2009 at 07:40 AM.
lokidil is offline   Reply With Quote
Reply

Bookmarks

Tags
draw text, graphics, opengl es

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 329
21 members and 308 guests
@sandris, ADY, BrianSlick, dacapo, Dani77, dre, HDshot, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, themathminister, timle8n1, tomtom100, vogueestylee, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,883
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, vvenkatachallam
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0