Ubuntu14.04 OpenGL Animation test Program

Source: Internet
Author: User

1 Installing the FREEGLUT3 OpenGL Auxiliary class Library

sudo apt-get install Freeglut3-dev


2 Compiling commands

GCC Test.cpp-lglut-lgl-lglu

As can be seen from the above command, three classes of libraries are used


3 Animation test Program

Third party libraries: sudo apt-get install freeglut3-dev//which uses the Glut.h file//compile command: GCC test.cpp-lglut-lgl-lglu#include <gl/   glut.h> #include <stdlib.h>static glfloat spin = 0.0;void display (void) {glclear (gl_color_buffer_bit);   Glpushmatrix ();   GLROTATEF (Spin, 0.0, 0.0, 1.0);   GLCOLOR3F (1.0, 1.0, 1.0);   GLRECTF (-25.0,-25.0, 25.0, 25.0);   Glpopmatrix (); Glutswapbuffers ();}   void Spindisplay (void) {spin = spin + 2.0;   if (Spin > 360.0) spin = spin-360.0; Glutpostredisplay ();}   void init (void) {Glclearcolor (0.0, 0.0, 0.0, 0.0); Glshademodel (Gl_flat);}   void reshape (int w, int h) {glviewport (0, 0, (Glsizei) W, (Glsizei) h);   Glmatrixmode (gl_projection);   Glloadidentity ();   Glortho (-50.0, 50.0,-50.0, 50.0,-1.0, 1.0);   Glmatrixmode (Gl_modelview); Glloadidentity ();} void Mouse (int button, int state, int x, int. y) {switch (button) {case Glut_left_button:if (state = = GLU         T_down) Glutidlefunc (Spindisplay);      BreakCase Glut_middle_button:case glut_right_button:if (state = = Glut_down) glutidlefunc (NULL);      Break   Default:break; }/* * Request double buffer display mode.   * Register Mouse Input callback functions */int main (int argc, char** argv) {glutinit (&AMP;ARGC, argv); Glutinitdisplaymode (glut_double |   GLUT_RGB);    Glutinitwindowsize (250, 250);   Glutinitwindowposition (100, 100);   Glutcreatewindow (Argv[0]);   Init ();    Glutdisplayfunc (display);    Glutreshapefunc (reshape);   Glutidlefunc (Spindisplay);   Glutmousefunc (mouse);   Glutmainloop ();   return 0; /* ANSI C requires main to return int. */}
Save as Test.cpp file and compile with command (2) to get a.out

4 run

./a.out

The result is a rotated rectangle animation.

Ubuntu14.04 OpenGL Animation test Program

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.