Problem using glutStrokeString instead of glutBitmapString

I am writing my first OpenGL program (in C using freeglut). I have the following code in my display function that works great and prints gray colored text:

glColor3f(0.5f, 0.5f, 0.5f); glRasterPos2f(0, 0); glutBitmapString(GLUT_BITMAP_HELVETICA_12, (unsigned char*)"some text"); 

Now I would like to try glutStrokeString instead of glutBitmapString. In my (humble) understanding, the API should work:

 glScalef(0.003,0.003,1); glutStrokeString(GLUT_STROKE_ROMAN, (unsigned char*)"some text"); 

Running my program using these two lines instead of calling glutBitmapString shows the text once before it disappears. Moreover, from now on, all of my texts displayed with glutBitmapString do not work either. What am I missing here?

+4
source share
1 answer

I finally decided. The problem was that for some reason, glutIdleFunc was set to my display function, and I forgot to reset my matrix (so I called glScalef again and again). Now it works great.

0
source

Source: https://habr.com/ru/post/1336309/


All Articles