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