Using OpenGL in the Dev C + + Environment

Source: Internet
Author: User

Introduced

Dev-c++ actually contains the basic features of developing OpenGL programs that can be easily selected: Create a new-multimedia-opengl and build an OpenGL program.

This program contains the basic OpenGL program structure, including the build window, message-driven mechanism, and basic OpenGL program. You can see a constantly rotating color triangle by clicking Run directly.

The library libglu32.a has been connected in link Parameters, Project Option, in the project, libopengl32.a

-lopengl32

can also be seen in the Makefile.win of the engineering root directory

LIBS     

So if you want to build your own OpenGL project, you must add the following parameters to the link for building the Win32 project.

-lglu32-lopengl32

It is now simple to implement according to the routines in the OpenGL Programming Guide: Render a white rectangle in a black background

#include <windows.h>//#include <gl/gl.h>//glut.h already included//#include <GL/glu.h>#include <GL/glut.h>//Draw ProgramsvoidDisplay () {glclear (gl_color_buffer_bit);//Set the screen to blackGLCOLOR3F (.,1.0,1.0);//Set current color status to whiteGlbegin (Gl_polygon);//Draw polygonsglvertex3f (0.25,0.25,0.0); glvertex3f (0.75,0.25,0.0); glvertex3f (0.75,0.75,0.0); glvertex3f (0.25,0.75,0.0);     Glend (); Glflush ();//Send buffer}//Initialize drawingvoidInit () {Glclearcolor (0.0,0.0,0.0,0.0);//Clear color settingsGlmatrixmode (gl_projection);//Set projection modeGlloadidentity (); Glortho (0.0,1.0,0.0,1.0,-1.0,1.0); Set projection space}intMainintargcChar* * argv) {glutinit (&AMP;ARGC, argv);//Initialize GLUTGlutinitdisplaymode (Glut_single | GLUT_RGB);//Set display mode to single buffering, RGB modeGlutinitwindowsize ( -, -);//Set window sizeGlutinitwindowposition ( -, -);//Set window locationGlutcreatewindow ("Hello");//Set window titleInit ();    Glutdisplayfunc (display); Glutmainloop ();return 0;}
Configuration

With the above perceptual knowledge, you can then further understand the principle of configuring OpenGL in DEV C + +

    • Windows configuration:

      Make sure that you have the following files under your Windows/system32 file:

      Glu32.dll, Glut32.dll, Glut.dll, Opengl32.dll

    • Configuration of the DEV C + + library:

      Ensure that the following files are in the Lib file in the dev C + + installation directory:

      libglu32.a, libglut32.a, LIBGLUT.A, LIBOPENGL.A

      Second, make sure that the Inlude\gl file is also like the head file:

      Gl.h, Glu.h, Glut.h,

    • property settings for the DEV C + + File project:

      Right-click the project, pop-up menu, click Project Properties, and then pop up the table to select the parameter item, enter in the connector on the right:

      -lglut32-lglu32-lopengl32-lwinmm-lgdi32

Using OpenGL in the Dev C + + Environment

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.