Texture2D problem
        Posted  
        
            by Anders Karlsson
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Anders Karlsson
        
        
        
        Published on 2010-03-24T02:17:05Z
        Indexed on 
            2010/03/24
            2:23 UTC
        
        
        Read the original article
        Hit count: 531
        
I have a problem that is driving me crazy, I want to write a number of texts on the screen using Texture2D however I only seem to be able to write the first one. If I individually write one of the labels it works but not if I write all of them, only the first label is displayed. Let me show some code:
-(void)drawText:(NSString*)theString AtX:(float)X Y:(float)Y withFont:(UIFont*)aFont 
{   
    // set color
    glColor4f(1, 0, 0, 1.0);
    // Enable modes needed for drawing
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    Texture2D* textTexture = [[Texture2D alloc] 
       initWithString:theString 
       dimensions:viewSize // 320x480
       alignment:UITextAlignmentLeft 
       font:aFont]; 
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    [textTexture drawInRect:CGRectMake(X,Y,1,1)];       
    glDisableClientState(GL_TEXTURE_COORD_ARRAY); 
    [textTexture release];
}
When I call this drawText once it seems to display the text properly, but if I call it a second time nothing seems to be displayed. Somebody has an idea what it could be?
The states like GL_BLEND and GL_TEXTURE_2D have been enabled in the view setup function.
In the Texture2D the dimensions are 512x512 as I pass the whole screen to function. If I don't pass that the text gets enlarged and fuzzy. I am a bit uncertain about that parameter.
TIA for any help.
© Stack Overflow or respective owner