VC ++ OpenGL Development Environment Configuration

Source: Internet
Author: User

1. Download the glut Toolkit

 Http://www.opengl.org/resources/libraries/glut/

2. Go to the VC installation directory.
Vc \ include \ GL, copy the. h file in the Toolkit.

Copy the. Lib file to\ Vc \ Lib

Copy the. dll file to the System32 folder in the system directory.

3. Create a C ++ project and test the project as follows:CodeThe environment is configured successfully.

# Include
<Gl/glut. h>
# Include <Gl/Gl. h>
# Include <Gl/Glaux. h>
# Pragma comment (Lib, "opengl32.lib ")
# Pragma comment (Lib, "glu32.lib ")
# Pragma comment (Lib, "Glaux. lib ")
# Include <windows. h>

Void myinit (void );
Void callback myreshape (glsizei W, glsizei H );
Void callback display (void );

Void myinit (void)
{
Glclearcolor (0.0, 0.0, 0.0, 0.0 );
Glclear (gl_color_buffer_bit );
}

Void callback myreshape (glsizei W, glsizei H)
{
Glviewport (0, 0, W, H );
Glmatrixmode (gl_projection );
Glloadidentity ();

If (W <= H)
Glortho (-1.5, 1.5,-1.5 * (glfloat) h/(glfloat) W,
1.5 * (glfloat) h/(glfloat) W,-10.0, 10.0 );
Else
Glortho (-1.5 * (glfloat) h/(glfloat) W,
1.5 * (glfloat) h/(glfloat) W,-1.5, 1.5,-10.0, 10.0 );
Glmatrixmode (gl_modelview );
Glloadidentity ();
}

Void callback display (void)
{
Glcolor3f (1.0, 1.0, 0.0 );
Auxwiresphere (1.0 );
Glflush ();
}

Void main (void)
{
// Set the display mode: single cache | rgba color mode
Auxinitdisplaymode (aux_single | aux_rgba );
// Initialize the window position
Auxinitposition (400,200,500,500 );
// Set the window title
Auxinitwindowa ("OpenGLProgram");
Myinit ();
Auxreshapefunc (myreshape );
Auxmainloop (Display );
}

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.