美文网首页
ubuntu18.04 install opengl

ubuntu18.04 install opengl

作者: 荆白雪_1984 | 来源:发表于2019-12-19 18:30 被阅读0次

    原文链接:https://www.linuxidc.com/Linux/2017-03/141555.htm

    #安装编译器与基本的函数库
    $  sudo apt-get install build-essential
    
    image.png
    #安装OpenGL Library
    $ sudo apt-get install libgl1-mesa-dev
    
    image.png

    (1)

    $ ping www.baidu.com
    
    image.png

    (2)

    $ sudo apt-get update
    $ sudo apt-get upgrade
    

    (3)
    名字打错了,,,

    # 安装OpenGL Utilities
    $ sudo apt-get install libglu1-mesa-dev
    
    image.png
    # 安装OpenGL Utility Toolkit
    $ sudo apt-get install libglut-dev
    
    image.png

    (1)替代上面命令

    $  sudo apt-get install freeglut3-dev
    
    image.png
    $ touch test.c
    

    include <GL/glut.h>

    void init(void)
    {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glOrtho(-5, 5, -5, 5, 5, 15);
    glMatrixMode(GL_MODELVIEW);
    gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
    return;
    }

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 0, 0);
    glutWireTeapot(3);
    glFlush();
    return;
    }

    int main(int argc, char *argv[])
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(300, 300);
    glutCreateWindow("OpenGL 3D View");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
    }

    $ gcc -o test test.c -lGL -lGLU -lglut
    
    image.png

    从虚拟机中拷贝GL文件下的gl.h文件。

    
    $ ./test
    
    image.png
    $ glxinfo | grep "OpenGL version"
    OpenGL version string: 3.1 Mesa 20.0.0-devel (git-afdc012 2019-12-18 bionic-oibaf-ppa)
    
    image.png

    相关文章

      网友评论

          本文标题:ubuntu18.04 install opengl

          本文链接:https://www.haomeiwen.com/subject/wxzpnctx.html