const int A = 500; / * chiều dài của một side của cửa sổ Monitor * / const float B = 500; / * length của một side của các clipping rectangle * / const float C = 200; / * chiều dài của cửa sổ của chương trình Draws * /
glMatrixMode (GL_PROJECTION); / * In World coordinates: * / glLoadIdentity (); / * position the "clipping rectangle" * / gluOrtho2D (-B / 2, B / 2, -B / 2, B / 2); / * at -B / 2, its right edge at + B / 2, its bottom * / glMatrixMode (GL_MODELVIEW); / * edge at -B / 2 and its top edge at + B / 2 * / }
void display (void) {
glClear (GL_COLOR_BUFFER_BIT); / * clear the window * /
glMatrixMode (GL_MODELVIEW); / * Các bản sau sau được sử dụng * / glLoadIdentity (); / * in terms of World coordinates * /
void main (int argc, char ** argv) { glutInit (& argc, argv); glutInitWindowSize (A, A); / * A x A pixel screen window * /
glutInitDisplayMode (GLUT_RGB | GLUT_SINGLE); glutCreateWindow ("My Rectangle"); / * window title * / glutDisplayFunc (display); / * tell OpenGL main loop what * / myinit (); / * set attributes * /
glutMainLoop (); / * pass control to main loop * / }
g. Now, click in the Dev-cpp editing window and then click Edit> Paste in its menu. The program will appear in the edit window.
Instructions for installing Dev-C ++ Picture 27
hour. Click File> Save . The file in your project directory will now contain the OpenGL program.
i. Let Dev-cpp know which library to link to. Click Project> Project Options .
Instructions for installing Dev-C ++ Picture 28
j. Now click "Parameters". Click the " Add Library or Object " button and navigate to the libraries that will be added. They are found in C: Dev-cpplib
./lib/libopengl32.a
./lib/libglu32.a
./lib/libglut32.a
Add them in that order. Note that the slash will appear in the Unix style "/" and not the "DOS type".
Instructions for installing Dev-C ++ Picture 29
When you have finished adding these 3 libraries, you will see:
Instructions for installing Dev-C ++ Picture 30
The exact template has the form "././ ." you see depends on the complexity of the directory structure in which your source file resides.
Click OK.
k. Click Execute> Compile and Run . The program will be compiled, linked and run:
Instructions for installing Dev-C ++ Picture 31
If everything doesn't work (very popular), click the " Compile Log " tab to find some confusing error messages. If you see an error like this, it means you made the wrong order when adding libraries to the project: