Lost in Computer

Source: Internet
Author: User

It was difficult to compile an OpenGL program. Then, when running the program, a prompt box Indicating "the loss of glu32.dll in the computer" pops up, so I went to c: \ windows \ system32 to check it, this file does not exist,

Then I downloaded one and put it in.

Here we will provide you with a bit of fig ~ I am using it, no problem ~~

Leave the source code of my first OpenGL ~~ Xi ~~

# Include <windows. h> # define glu_disable_atexit_hack # include <Gl/GL. h> # include <Gl/Glaux. h> # include <Gl/Glu. h> # include <Gl/glut. h> # pragma comment (Lib, "opengl32.lib") # pragma comment (Lib, "glu32.lib") # pragma comment (Lib, "Glaux. lib ") # pragma comment (Lib," glu32.lib ") # pragma comment (Lib," gdiplus. lib ") int mousex, Mousey; bool mousebuttondown = false; // whether to press float rotx = 16, roty = 0; // initialize the rotation angle, only the rotation around the Y axis is used here // Void idle () {glupostredisplay (); // tag the current window and re-draw it.} void resize (glsizei iwidth, glsizei iheight) {glviewport (0, 0, iwidth, iheight); glmatrixmode (gl_projection); glloadidentity (); gluperspective (65.0, (glfloat) iwidth/(glfloat) iheight, 0.1, 120.0); glmatrixmode (gl_modelview ); glloadidentity () ;}// Add a plotting function. You can draw a triangle to rotate around the Y axis according to the mouse operation. Void drawscene () {glclear (gl_color_buffer_bit | gl_depth_buffer_bit); // clear the screen and depth cache glloadidentity (); // reset the current model observation matrix gltranslatef (0.0f, 0.0f, -6.0f); // move 1.5 units to the left and 6.0 glrotatef (roty, 0.0f, 1.0f, 0.0f) into the screen; // rotate the pyramid glbegin (gl_triangles) around the Y axis ); // start to draw glcolor3f (1.0f, 0.0f, 0.0f) on each surface of the pyramid; // glvertex3f (0.0f, 1.0f, 0.0f) in red; // top vertex of the triangle (front side) glcolor3f (0.0f, 1.0f, 0.0f); // green glvertex3f (-1.0f,-1.0f, 1.0f); // triangle Glcolor3f (0.0f, 0.0f, 1.0f); // blue glvertex3f (1.0f,-1.0f, 1.0f); // right bottom vertex of the triangle (front side) glcolor3f (1.0f, 0.0f, 0.0f); // red glvertex3f (0.0f, 1.0f, 0.0f); // top vertex of a triangle (right side) glcolor3f (0.0f, 0.0f, 1.0f ); // blue glvertex3f (1.0f,-1.0f, 1.0f); // glcolor3f (0.0f, 1.0f, 0.0f) of the lower left vertex (right side) of the triangle; // green glvertex3f (1.0f, -1.0f,-1.0f); // glcolor3f (1.0f, 0.0f, 0.0f); // glvertex3f (0.0f, 1.0f, 0.0f) in red );/ /Glcolor3f (0.0f, 1.0f, 0.0f) on the top vertex (back side) of the triangle; // green glvertex3f (1.0f,-1.0f,-1.0f ); // glcolor3f (0.0f, 0.0f, 1.0f) of the lower left vertex (rear side) of the triangle; // blue glvertex3f (-1.0f,-1.0f,-1.0f ); // glcolor3f (1.0f, 0.0f, 0.0f) in the lower right vertex (rear side) of the triangle; // glvertex3f (0.0f, 1.0f, 0.0f) in red ); // glcolor3f (0.0f, 0.0f, 1.0f) of the top vertex (left side) of the triangle; // blue glvertex3f (-1.0f,-1.0f,-1.0f ); // glcolor3f (0.0f, 1.0f, 0.0f) of the lower left vertex (left side) of the triangle; // green glvertex3f (-1.0f,-1.0f, 1.0 F); // glend () of the lower right vertex (left side) of the triangle; // The pyramid is drawn to end the map (); // swap buffer} // Add the menu definition function and the menu response function. The menu here is the right-click pop-up popup menu, in which buildpopupmenu creates the menu and its corresponding ID number, and defines the menu ID number, which is placed at the top of the main file. Enum menucommands {menu_test = 0, menu_exit}; void selectfrommenu (INT idcommand) {Switch (idcommand) {Case menu_test: // write the response code MessageBox (null, "test ", "", 0); break; Case menu_exit: exit (0); break;} glupostredisplay (); // What is the use ???????} Int annotate (void) {int menu; menu = fig (selectfrommenu); fig ("test \ TT", menu_test); fig ("Exit \ tesc", menu_exit ); return menu;} // Add the mouse response function. The mouse response function mainly includes the mouse clicking response and moving response. The mousebutton Mouse clicking response, and the mousemotion is the mouse moving response. Void mousebutton (INT button, int state, int X, int y) {If (Button = fig) {If (State = fig) {mousex = x; Mousey = y; mousebuttondown = true;} else {mousebuttondown = false ;}} void mousemotion (int x, int y) {int deltx, delty; // calculate mouse movement since click delty = x-mousex; deltx = Y-Mousey; // store new mouse position mousex = x; Mousey = y; If (mousebuttondown) {// rotate rotx + = deltx; roty + = delty; fig () ;}// void keyboard response function (unsigned char key, int X, int y) {Switch (key) {Case 'T': selectfrommenu (menu_test); break; Case 27: // ESC selectfrommenu (menu_exit); break ;}} int main (INT argc, char ** argv) {glsizei iwidth = 640.0; // defines the window size glsizei iheight = 480.0; gluinit (& argc, argv); // glut initialization // specifies the function glucreatewindow () the created window mode, such as single cache or dual cache, is RGB or rgba mode. // You can also specify a depth cache associated with the window, template cache maid mode (glu_rgb | glu_depth | glu_double); // window display mode, which is RGB color mode, depth buffering, dual-buffer fig size (iwidth, iheight ); // window size (100,100); // window location ("OpenGL getting started on the console"); // create a window // process the window and input events buildpopupmenu (); // create a right-click pop-up menu, such as the gluattachmenu (glu_right_button) and the glumousefunc (mousebutton). // press the mouse to display the response function, fig func (mousemotion ); // The Response Function glutidlefunc (keyboard) when the mouse moves; // The Response Function glutidlefunc (idle) when the keyboard is pressed; // The Handler function when the program is idle () // initialize the drawing environment, including enabling the deep cache, setting the background color, and setting the glclearcolor (0.0f, 0.0f, 0.0f, 0) such as the viewport size; // set the background color to gl_depth_test ); // enable the deep test gldepthfunc (gl_lequal); // when the depth is small or equal, It also renders the glureshapefunc (resize); // The response function of the window when the window size changes ); // set the plotting function to drawscene () glumainloop (); // The program runs the loop return 0 ;}

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.