Linux OpenGL Practice Article-1

Source: Internet
Author: User

The environment used in this practice is CentOS 7.

Reference: http://www.xuebuyuan.com/1472808.html

OpenGL Development Environment Setup:

1.OPENGL Library Installation

OpenGL Library using the Mesa library, install the command:

Yum Intall mesa*

Mesa Library is an open-source three-dimensional computer graphics library that implements the OpenGL application interface in the form of open source. Specific description: https://www.mesa3d.org/intro.html.

2.glut Installation

Download Freeglut, for: https://github.com/dcnieho/FreeGLUT/releases. Glut is OpenGL's utility library, OpenGL is just a three-dimensional graphics interface, and no window, processing mouse and other devices input and output aspects of content, glut provide relevant aspects of the content. Freeglut is a release version of Glut (and one is the original version of GLUT).

Because I use CMake installation, according to the Readme.cmake steps and precautions to install.

Command:

CMake.

Make

Make install

3. Simple examples

New File Main.cpp

#include <GL/glut.h>#include<stdlib.h>voidinit ();voiddisplay ();intMainintargcChar*argv[]) {Glutinit (&argc, argv); Glutinitdisplaymode (Glut_rgb|glut_single); Glutinitwindowposition (0,0); Glutinitwindowsize ( -, -); Glutcreatewindow ("OpenGL 3D View");        Init ();        Glutdisplayfunc (display);        Glutmainloop (); return 0;}voidinit () {Glclearcolor (0.0,0.0,0.0,0.0);        Glmatrixmode (gl_projection); Glortho (-5,5, -5,5,5, the);        Glmatrixmode (Gl_modelview); Glulookat (0,0,Ten,0,0,0,0,1,0);}voiddisplay () {glclear (gl_color_buffer_bit); glcolor3f (1.0,0,0); Glutwireteapot (3); Glflush ();}

Compile command:

GCC-LGLUT-LGLU-LGL main.cpp

Linux OpenGL Practice Article-1

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.