Establish the OpenGL Runtime Environment (running instance) in ubuntu8.04)

Source: Internet
Author: User
Create a basic compiling environment

The first thing that is indispensable is the internal handler and the basic correspondence handler. if the system does not have security issues, follow these steps:

sudo apt-get install build-essential


Installing OpenGL library

Next, we will introduce the library we will use. First, install OpenGL library.

sudo apt-get install libgl1-mesa-dev


Installing OpenGL utilities

OpenGL utilities is a tool Group built on the OpenGL library. It provides many convenient functions to make OpenGL larger and easier to use.
Next, we will install OpenGL utilities

sudo apt-get install libglu1-mesa-dev


Installing OpenGL utility Toolkit

OpenGL utility toolkit is a toolkit built on OpenGL utilities. Besides the limitations of OpenGL utilities, It also adds support for the spatial window interface by OpenGL.

sudo apt-get install libglut-dev


Set the maximum number and maximum number

Before that, we need a typical example. example. C is as follows:

#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();
}

With the programming examples, and the basic programming environment, after writing a function related to OpenGL, all we need to do is to inform our browser that we have an android OpenGL function. During programming, We need to compile these functions.

gcc example.c -o example.out -lGL -lGLU -lglut

Because we have installed OpenGL utility toolkit, which is based on OpenGL utilities and OpenGL
Library, so we can simply compile the OpenGL utility Toolkit
You can access our website. The following example shows the same effect:

gcc example.c -o example.out -lglut

Below is a simple description of the GCC metric data used in the next section.

-L <library> tell GCC to terminate the specified library
-O <File> specifies the output name of the delimiter In the delimiter row.


Rows

Next, let's take a look at our results. If we see the right button, it means it is successful!

Sliced: teapot.png freesamael tea set with OpenGL
./example.out

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.