Make text stand still
I've use this code to write text in OpenGLView
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?
PHP Code:
glDisable(GL_DEPTH_TEST);
glPushMatrix();
glLoadIdentity(); //
glOrtho( 0, 10, 0, 10, -1.0, 1.0);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();//
glColor4f(0,1,1, 0.7);
glPrint( font, 0.0, 0.0, "Score");
glPopMatrix();
glMatrixMode( GL_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?
What's glPrint?
Do you need to glTranslate before you print?
What are the two arguments you pass as 0.0 to glPrint?
Do you need to glTranslate before you print?
What are the two arguments you pass as 0.0 to glPrint?
I use two files for glPrint, NSGLFont.h and NSGLFont.m
this is an exerpt from NSGLFont.m
this is an exerpt from NSGLFont.m
PHP Code:
void glPrint( NSGLFont *f, float x, float y, const char *fmt, ... )
{
char text[256];
va_list ap;
NSString *s;
GLboolean tex2d, light;
if( fmt == NULL ) return;
// format the string into (char *) text
va_start( ap, fmt );
vsprintf( text, fmt, ap );
va_end(ap);
if( [f textured] ) { s = [NSString stringWithCString: text]; [f writeString: s ]; }
else
{
// I always get a SIGSEGV 11 when glRasterPos* is called with textures off and lighting on
// so here I turn them off.
glGetBooleanv( GL_TEXTURE_2D, &tex2d ); glDisable(GL_TEXTURE_2D);
glGetBooleanv( GL_LIGHTING, &light ); glDisable(GL_LIGHTING);
// RasterPos to the correct location
glRasterPos2f(x, y);
// create an NSString
s = [NSString stringWithCString: text];
// write the string
[f writeString: s ];
// enable as required
if( tex2d ) glEnable(GL_TEXTURE_2D);
if( light ) glEnable(GL_LIGHTING);
}
}
Have you tried putting a sensible value in for the x and y arguments in glPrint?

