Ubuntu13.04使用Mesa

來源:互聯網
上載者:User

Ubuntu13.04使用Mesa 首先安裝:[cpp] sudo apt-get install libgl1-mesa-dev  sudo apt-get install libglu1-mesa-dev  sudo apt-get install freeglut3-dev   現在不用NetBeans了,用CMake建立工程。根目錄下的CMakeLists.txt內容:[cpp] cmake_minimum_required(VERSION 2.8)  project (vender)  add_subdirectory(src bin)   src目錄下的CMakeLists.txt檔案內容如下:[cpp] cmake_minimum_required(VERSION 2.8)  set(CMAKE_BUILD_TYPE Debug)  set(PROJECT_INCLUDE_DIR ../include)    include_directories(${PROJECT_INCLUDE_DIR})  AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src CPP_LIST1)    add_executable(vender ${CPP_LIST1})  target_link_libraries(vender GL GLU glut)  add_definitions(-Wall)   然後看一下src/main.cc檔案內容,和3年前代碼一樣。[cpp] #include <GL/glut.h>    void init();  void display();    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;  }    void init() {    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);  }    void display() {    glClear(GL_COLOR_BUFFER_BIT);      glColor3f(1.0, 0, 0);    glutWireTeapot(3);      glFlush();  }  運行結果: 我這次不想繪製什麼圖形,只是想知道我的顯卡類型。因此代碼刪減如下:[cpp] #include <GL/glut.h>    #include <iostream>    using namespace std;    int main(int argc, char* argv[]) {    glutInit(&argc, argv);    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);    glutInitWindowPosition(0, 0);    glutInitWindowSize(300, 300);              glutCreateWindow("OpenGL 3D View");      GLubyte const* vender = glGetString(GL_VENDOR);    cout << "GL_VENDOR: " << vender << endl;      GLubyte const* renderer = glGetString(GL_RENDERER);    cout << "GL_RENDERER: " << renderer << endl;      GLubyte const* version = glGetString(GL_VERSION);    cout << "GL_VERSION: " << version << endl;      return 0;  }   運行結果:[cpp] dean@dean-GA-MA790XT-UD4P:~/work/opengl/vendor/build/bin$ ./vender   GL_VENDOR: X.Org  GL_RENDERER: Gallium 0.4 on AMD JUNIPER  GL_VERSION: 3.0 Mesa 9.1.4   

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.