PDA

View Full Version : how to show text on SGI-IRIX(6.5) machine using glutBitmapCharacter



saurabh_shrivastava
05-10-2003, 11:32 PM
Myself Saurabh Shrivastava have posted the problem regarding the glutBitmapCharacter() on IRIX(6.5)..according to suggestion i tried to change the code with void * but its still not working..
kindly let me know the answer why its giving prob..I still feel that may be i've not set the exact environment (glColor or any Disable/Enable option for light or anything but i'm not sure) though i don't know which to set for ..
again i'm enclosing the code here..


fn declaration

void text_string(int x,int y,void *font,char *text);

************************************************** **
calling fn


void *font="GLUT_BITMAP_8_BY_13";
char *buff="SAURABH";
float cent_x,cent_y;

text_string((int)cent_x,(int)cent_y,font,buff);

************************************************** ***


fn definition
************************************************** ***
void text_string(int x,int y,void *font,char *text)

{

glRasterPos2f((float)x+2,(float)y+2);
if (text == NULL)
exit(1);
while (*text != '\0')
{
glutBitmapCharacter(font, (int)*text);
text++;
}
}


any help in the matter wil be appreciated .

thanks in advance
saurabh



[This message has been edited by saurabh_shrivastava (edited 05-11-2003).]

shinpaughp
05-10-2003, 11:42 PM
Are you sure the values that you pass to glRasterPos are valid coords. For glRasterPos, they must be within the window, even 1 pixel outside and GL will not render anything based on that raster position. And, if they are valid, what font are you passing?

Also, I noticed that the font you pass into your function is defined as char* whereas all of the constants are defined as void* as follow:

#define GLUT_BITMAP_9_BY_15 ((void*)2)
#define GLUT_BITMAP_8_BY_13 ((void*)3)
#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
#if (GLUT_API_VERSION >= 3)
#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
#define GLUT_BITMAP_HELVETICA_18 ((void*)8)

so if you are passing an actual string as the font, it will not work. So, you should change char* to void* and pass the parameter (such as) GLUT_BITMAP_TIMES_ROMAN_10 to your text_string function.

[This message has been edited by shinpaughp (edited 05-11-2003).]