Configure the OpenGL environment for Ubuntu and opengl for ubuntu

Source: Internet
Author: User

Configure the OpenGL environment for Ubuntu and opengl for ubuntu

Create a basic compilation environment

1 sudo apt-get install build-essential

 

Install OpenGL Library

1 sudo apt-get install libgl1-mesa-dev

 

Install OpenGL Utilities

1 sudo apt-get install libglu1-mesa-dev

 

Install OpenGL Utility Toolkit

1 sudo apt-get install freeglut3-dev

 

Test result: a. c

 1 #include <GL/glut.h> 2  3 void init() 4 { 5     glClearColor(0.0, 0.0, 0.0, 0.0); 6     glMatrixMode(GL_PROJECTION); 7     glOrtho(-5, 5, -5, 5, 5, 15); 8     glMatrixMode(GL_MODELVIEW); 9     gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);10 }11 12 void display()13 {14     glClear(GL_COLOR_BUFFER_BIT);15     glColor3f(1.0, 0, 0);16     glutWireTeapot(3);17     glFlush();18 }19 20 int main(int argc, char *argv[])21 {22     glutInit(&argc, argv);23     glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);24     glutInitWindowPosition(0, 0);25     glutInitWindowSize(300, 300);26     glutCreateWindow("OpenGL 3D View");27     init(); glutDisplayFunc(display);28     glutMainLoop();29     return 0;30 }

 

Compile

1 gcc a.c -o a -lGL -lGLU -lglut

 

Effect


(200 points added) how to install openGL on ubuntu ??

None of the above methods work. You should go to the Ubuntu Forum for advice.

How to install opengl in ubuntu

Sudo apt-get install opengl

Or the Software Center -- search opengl

Or cutting-edge -- search opengl

Related Article

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.