Linux (Ubuntu 14.04) setting up OpenGL

Source: Internet
Author: User

1. Install the C + + compilation package.

2. Install OpenGL and Freeglut Library

sudo apt-get install Mesa-common-dev

sudo apt-get install Freeglut3-dev

3. Testing:run This code, comes from OpenGL Red Book, by Save it as a CPP file. Then open the terminal and navigate to the directory containing this CPP file.

g++ TEXT.CPP-LGLUT-LGL
Then you'll get an a.out. Run it by

./a.out4. Done

1#include"gl/freeglut.h"2#include"gl/gl.h"3 4 /*display Function-code from:5      http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html6 This is the actual usage of the OpenGL library.7 The following code is the same for any platform*/8 voidrenderfunction ()9 {TenGlclearcolor (0.0,0.0,0.0,0.0); One glclear (gl_color_buffer_bit); AGLCOLOR3F (1.0,1.0,1.0); -Glortho (-1.0,1.0, -1.0,1.0, -1.0,1.0); - Glbegin (Gl_polygon); theGLVERTEX2F (-0.5, -0.5); -GLVERTEX2F (-0.5,0.5); -GLVERTEX2F (0.5,0.5); -GLVERTEX2F (0.5, -0.5); + glend (); - Glflush (); + } A  at /*Main Method-main Entry point of application - The Freeglut Library does the window creation work for us, - regardless of the platform.*/ - intMainintargcChar**argv) - { -Glutinit (&argc, argv); in Glutinitdisplaymode (glut_single); -Glutinitwindowsize ( -, -); toGlutinitwindowposition ( -, -); +Glutcreatewindow ("Opengl-first Window Demo"); - Glutdisplayfunc (renderfunction); the Glutmainloop ();  *     return 0; $}

Note:fell free to context me.

Linux (Ubuntu 14.04) setting up OpenGL

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.