weixin_47261246 2020-12-20 19:07 采纳率: 12.5%
浏览 25
已结题

用OpenGL画一个字母β

请大佬能不能教我下如何用openGL画一个字母β,就和图中的输出一样,最好能有c++的代码,如果可以的话,请加上注释

谢谢

  • 写回答

2条回答 默认 最新

  • 歇歇 2020-12-20 19:44
    关注

    #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.

    }

    评论

报告相同问题?

悬赏问题

  • ¥15 CSS通配符清除内外边距为什么可以覆盖默认样式?
  • ¥15 SPSS分类模型实训题步骤
  • ¥15 求解决扩散模型代码问题
  • ¥15 工创大赛太阳能电动车项目零基础要学什么
  • ¥20 limma多组间分析最终p值只有一个
  • ¥15 nopCommerce开发问题
  • ¥15 torch.multiprocessing.spawn.ProcessExitedException: process 1 terminated with signal SIGKILL
  • ¥15 QuartusⅡ15.0编译项目后,output_files中的.jdi、.sld、.sof不更新怎么解决
  • ¥15 pycharm输出和导师的一样,但是标红
  • ¥15 想问问富文本拿到的html怎么转成docx的