Make text stand still

Member
Posts: 21
Joined: 2004.11
Post: #1
I've use this code to write text in OpenGLView
PHP Code:
glDisable(GL_DEPTH_TEST);
glPushMatrix();

glLoadIdentity(); //

glOrtho010010, -1.01.0);
glMatrixModeGL_MODELVIEW );
glPushMatrix();

glLoadIdentity();//

glColor4f(0,1,10.7);
glPrintfont0.00.0"Score");
glPopMatrix();
glMatrixModeGL_PROJECTION );
glPopMatrix(); 

glEnable(GL_DEPTH_TEST); 


but the problems is that the text doesnt show up

if i delete both glLoadIdentity();, it shows up.

The problem then is that the text move around the camera.

What should I do?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #2
What's glPrint?

Do you need to glTranslate before you print?

What are the two arguments you pass as 0.0 to glPrint?
Quote this message in a reply
Member
Posts: 21
Joined: 2004.11
Post: #3
I use two files for glPrint, NSGLFont.h and NSGLFont.m
this is an exerpt from NSGLFont.m
PHP Code:
void glPrintNSGLFont *ffloat xfloat y, const char *fmt, ... )
{
    
char    text[256];
    
va_list    ap;
    
NSString    *s;
    
GLboolean tex2dlight;


    if( 
fmt == NULL ) return;
    
// format the string into (char *) text
    
va_startapfmt );
        
vsprintftextfmtap );
    
va_end(ap);

    if( [
f textured] ) { = [NSString stringWithCStringtext]; [f writeString]; }
    else
    {
        
// I always get a SIGSEGV 11 when glRasterPos* is called with textures off and lighting on
        // so here I turn them off.
        
glGetBooleanvGL_TEXTURE_2D, &tex2d );     glDisable(GL_TEXTURE_2D);
        
glGetBooleanvGL_LIGHTING, &light );    glDisable(GL_LIGHTING);

        
// RasterPos to the correct location
        
glRasterPos2f(xy);

        
// create an NSString
        
= [NSString stringWithCStringtext];

        
// write the string
        
[f writeString];
 
        
// enable as required
        
if( tex2d glEnable(GL_TEXTURE_2D);
        if( 
light glEnable(GL_LIGHTING);
    }

Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
Have you tried putting a sensible value in for the x and y arguments in glPrint?
Quote this message in a reply
Post Reply