Ubuntu Settings OpenGL Environment

Source: Internet
Author: User

Here is a good link, in order to prevent link invalidation, copy the content as follows.

Link http://blog.csdn.net/zhangliang_571/article/details/25241911

Content:

OpenGL is a library of drawing functions developed by SGI, a set of C-language functions for the development of 2D and 3D graphics applications. OpenGL lets programmers do not have to take into account the various display card underlying operation is the same problem, the hardware is communicated by the OpenGL core, so as long as the display card support OpenGL, then the program does not need to re-transplant, and the program developers do not need to re-learn a set of library to migrate the program.


Installation


The first essential is the compiler and the basic function library, if the system is not installed, according to the following way to install:

    1. $ sudo apt-get install build-essential


Installing the OpenGL Library

    1. $ sudo apt-get install Libgl1-mesa-dev


Installing OpenGL Utilities

    1. $ sudo apt-get install Libglu1-mesa-dev

OpenGL Utilities is a group of tools built on the OpenGL Library, providing many handy functions that make OpenGL more powerful and easier to use.

Installing OpenGL Utility Toolkit

    1. $ sudo apt-get install Libglut-dev

OpenGL Utility Toolkit is a toolkit built on OpenGL Utilities, adding OpenGL support for Windows interfaces in addition to the lack of OpenGL Utilities.
Note: At this point, the following scenario may occur, the shell tip:

    1. Reading Package Lists ... Done
    2. Building Dependency Tree
    3. Reading state information ... Done
    4. E:unable to locate package Libglut-dev

Change the above $ sudo apt-get install Libglut-dev command to $ sudo apt-get install Freeglut3-dev.

Test


Example TEST.C Source code:

  1. #include <gl/glut. h>

  2. void init(void)
  3. {
  4. Glclearcolor(0. 0, 0. 0, 0. 0, 0. 0);
  5. Glmatrixmode(gl_projection);
  6. Glortho(-5, 5,-5, 5, 5,);
  7. Glmatrixmode(Gl_modelview);
  8. Glulookat(0, 0,ten, 0, 0, 0, 0, 1, 0);

  9. return;
  10. }

  11. void display(void)
  12. {
  13. Glclear(gl_color_buffer_bit);
  14. glcolor3f(1. 0, 0, 0);
  15. Glutwireteapot(3);
  16. Glflush();

  17. return;
  18. }

  19. int main(int argc, char*argv[])
  20. {
  21. Glutinit(&argc, argv);
  22. Glutinitdisplaymode(Glut_rgb | Glut_single);
  23. Glutinitwindowposition(0, 0);
  24. Glutinitwindowsize(a);
  25. Glutcreatewindow("OpenGL 3D View");
  26. Init();
  27. Glutdisplayfunc(display);
  28. Glutmainloop();

  29. return 0;
  30. }

When compiling the program, execute the following command:

    1. $ gcc-o Test Test.c-lgl-lglu-lglut

Perform:

    1. $./test

Ubuntu Settings OpenGL Environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.