Eclipse + mingw + OpenGL Configuration

Source: Internet
Author: User

Yesterday I tried to use eclipse + mingw to run OpenGL. After a long time, I finally finished it this morning. The steps are as follows:

 

1: Download eclipse for C ++ ide on www.eclipse.org.

2: Download mingw. I searched it on SourceForge.

3: Install mingw step by step. After installation, add the environment variable in path. For example, C:/mingw/bin.

4: Next glut library on the Internet. Then, use mingw-utils to compile the glu32.lib file into the libglu32.a file. The specific method is to use the remip in mingw-utils on the CMD command line.

5: Put the libglu32.a file generated by remip.exe in the mingw/lib directory.

6: Put the glut. h In the glut library under the mingw/include/GL file. Because mingw comes with some GL libraries.

7. Place the glut library's glu32.dll in the C:/Windows/system32 directory.

I found a test on the Internet.Code:

 

# Include <stdlib. h> <br/> # include <Gl/GL. h> <br/> # include <Gl/glut. h> <br/> void display (void) <br/> {<br/> glclear (gl_color_buffer_bit);/* clear all pixels */<br/> glcolor3f (1.0, 1.0, 1.0); <br/> glbegin (gl_polygon);/* draw white polygon with corners at (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) */<br/> glvertex3f (0.25, 0.25, 0.0); <br/> glvertex3f (0.75, 0.25, 0.0); <br/> glvertex3f (0.75, 0.75, 0.0); <br/> glvertex3f (0.25, 0.75, 0.0); <br/> glend (); <br/> glflush (); /* Start processing buffered OpenGL routines */<br/>}< br/> void Init (void) <br/>{< br/> glclearcolor (0.0, 0.0, 0.0, 0.0);/* select clearing color */<br/> glmatrixmode (gl_projection); <br/> glloadidentity (); <br/> glortho (0.0, 1.0, 0.0, 1.0,-1.0, 1.0);/* initialize viewing values */<br/>}< br/> int main (INT argc, char ** argv) <br/>{< br/> gluinit (& argc, argv); <br/> gluinitdisplaymode (glu_single | glu_rgb ); /* declare initial display mode (single buffer and rgba ). */<br/> fig (250,250);/* declare initial window size. */<br/> fig (100,100);/* declare initial window position. */<br/> fig ("hello");/* open window with "hello" in its title bar. */<br/> Init ();/* Call initialization routines. */<br/> maid (Display);/* Register callback function to display graphics. */<br/> fig ();/* Enter main loop and process events. */<br/> return 0;/* ansi c requires main to return Int. */<br/>}< br/>

 

In this eclipse project, you also need to set a static Link Library. Otherwise, it will always show that the static library cannot be found, or the undefinded reference error occurs during compilation.

The procedure is as follows: propreties-> C/C ++ build-> setting-> mingw C ++ linker-> libraries adds opengl32, glu32, and glu32 to libraries (-l ).

It seems that this order cannot be disrupted.

After completing these steps, you can run OpenGL.

 

Related Article

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.