请大佬能不能教我下如何用openGL画一个字母β,就和图中的输出一样,最好能有c++的代码,如果可以的话,请加上注释
谢谢
请大佬能不能教我下如何用openGL画一个字母β,就和图中的输出一样,最好能有c++的代码,如果可以的话,请加上注释
谢谢
#include<windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
void init (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0); // 设置显示颜色为白色.
glMatrixMode (GL_PROJECTION); // 设置投影参数
gluOrtho2D (0.0, 200.0, 0.0, 150.0);
}
void CharMap(void)
{
glClear (GL_COLOR_BUFFER_BIT); // 清空显示屏幕
// glColor3f (0.0, 0.0, 0.0); // 设置颜色为红色
glColor3f(0.0,0.0,0.0);
char text = 'β';
glRasterPos2i(20,40);
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,text )//输出字符
glScalef(0.1,0.1,0.0);
glRotatef(300,20.0,20.0,0.0);
glRasterPos2i(20,40);
glutStrokeCharacter(GLUT_STROKE_ROMAN,text );//显示
}
glFlush();
}
int main (int argc, char** argv)
{
glutInit (&argc, argv); // Initialize GLUT.
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set display mode.
glutInitWindowPosition (50, 100); // Set top-left display-window position.
glutInitWindowSize (1000, 600); // Set display-window width and height.
glutCreateWindow ("An Example OpenGL Program"); // Create display window.
init ( ); // Execute initialization procedure.
glutDisplayFunc (CharMap); // Send graphics to display window.
glutMainLoop ( );
return 0; // Display everything and wait.
}