使用 glutStrokeString 而不是 glutBitmapString 时出现问题
我正在编写我的第一个 OpenGL 程序(使用 freeglut 用 C 语言)。我的显示函数中有以下代码,该代码运行良好并打印出灰色文本:
glColor3f(0.5f, 0.5f, 0.5f);
glRasterPos2f(0, 0);
glutBitmapString(GLUT_BITMAP_HELVETICA_12, (unsigned char*)"some text");
现在我想尝试 glutStrokeString 而不是 glutBitmapString。根据我对 API 的(粗浅的)理解,以下内容应该有效:
glScalef(0.003,0.003,1);
glutStrokeString(GLUT_STROKE_ROMAN, (unsigned char*)"some text");
使用这两行而不是 glutBitmapString 调用运行我的程序,在文本消失之前显示一次文本。此外,从那时起,我用 glutBitmapString 显示的所有文本也不起作用。我在这里缺少什么?
I'm writing my first OpenGL-program (in C using freeglut). I have the following code in my display function, that works nicely and prints out a grey colored text:
glColor3f(0.5f, 0.5f, 0.5f);
glRasterPos2f(0, 0);
glutBitmapString(GLUT_BITMAP_HELVETICA_12, (unsigned char*)"some text");
Now I'd like to try glutStrokeString instead of glutBitmapString. In my (humble) understanding of the API, the following should work:
glScalef(0.003,0.003,1);
glutStrokeString(GLUT_STROKE_ROMAN, (unsigned char*)"some text");
Running my program with this two lines instead of the glutBitmapString-call shows the text once before it disappears. Moreover from that point on all my texts displayed with glutBitmapString don't work either. What am I missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于解决了。问题是,由于某种原因 glutIdleFunc 被设置为我的显示函数,而我忘记重置我的矩阵(所以我一次又一次地调用 glScalef)。现在效果很好。
I've finally solved it. 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). It works fine now.