Solutions for configuring OpenGL in VS2010 and for problems encountered with 64-bit systems

Source: Internet
Author: User
Tags visual studio 2010

First, the following will be a brief introduction to the configuration of OpenGL in VS2010.

Preparation before learning OpenGL first step, choose a compilation environment now the main compiler environment of Windows system has visual Studio,broland C + + builder,dev-c++, and so on, they all support OpenGL.

I chose Visual Studio 2010 and vc6++ as an environment for learning OpenGL. The second step, install the Glut Toolkit glut is not necessary for OpenGL, but it will give us a certain convenience of learning, recommended installation. Glut in the Windows environment: (approximately 150k in size) http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip cannot download from the above address, please use the following connection :
Http://upload.programfan.com/upfile/200607311626279.zip installation of GLUT in Windows environment: 1, will download the compressed package, will get 5 files, respectively, is glut.h, Glut.lib,glut32.lib,glut.dll,glut32.dll 2, put the glut.h into C:\Program Files\Microsoft Sdks\windows\v7.0a\include\gl inside, VS2010 will automatically search for this path.

3. Copy the Glut.lib and Glut32.lib to F:\vs2010\VC\lib, as determined by the specific installation path of the VS2010.

4. Copy the Glut.dll and Glut32.dll to C:\WINDOWS\system32.

So far, the environment has been configured.

Below to develop a simple C + + program, the VC in the Environment VS2010

1. New Project->win32 Console application.

2. Enter the project name: SIMPLEGL, other default.

3. Enter the source code:

1#include <gl/glut.h>2#include <stdio.h>3#include <time.h>4 5 //the Sun, the Earth and the moon6 //let's say every month is 30 days .7 //12 months a year, a total of 360 days8 Static intDay = $;//changes in day: from 0 to 3599 Ten Doublecallfrequency () One { A     Static intcount; -     Static DoubleSave; -     Staticclock_t last,current; the     DoubleTimegap; -  -++count; -     if(count<= -) +         returnSave; -Count =0; +Last =Current ; ACurrent =clock (); atTimegap = (current-last)/(Double) Clk_tck;  -Save =50.0/Timegap; -     returnSave; - } -  - voidMydisplay (void) in { -     DoubleFPS =callfrequency (); toprintf"FPS =%f\n", FPS); +  - glenable (gl_depth_test); theGlclear (gl_color_buffer_bit|gl_depth_buffer_bit); *  $ Glmatrixmode (gl_projection);Panax Notoginseng glloadidentity (); -Gluperspective ( the,1,1,400000000); the Glmatrixmode (gl_modelview); + glloadidentity (); AGlulookat (0,-200000000,200000000,0,0,0,0,0,1); the  +  -     //Draw the Red "sun" $GLCOLOR3F (1.0f,0.0f,0.0f); $Glutsolidsphere (69600000, -, -); -     //Draw the Blue "Earth" -GLCOLOR3F (0.0f,0.0f,1.0f); theGlrotatef (day/360.0*360.0,0.0f,0.0f,-1.0f); -Gltranslatef (150000000,0.0f,0.0f);WuyiGlutsolidsphere (15945000, -, -); the     //draw a yellow "moon" -GLCOLOR3F (1.0f,1.0f,0.0f); WuGlrotatef (day/30.0*360.0-day/360.0*360.0,0.0f,0.0f,-1.0f); -Gltranslatef (38000000,0.0f,0.0f); AboutGlutsolidsphere (4345000, -, -); $  - Glflush (); - glutswapbuffers (); - } A  + voidMyidle (void) the { -++Day ; $     if(day>= the) theDay =0; the Mydisplay (); the } the  - intMainintargcChar*argv[]) in { theGlutinit (&argc,argv); theGlutinitdisplaymode (glut_rgb|glut_double); AboutGlutinitwindowposition ( -, -); theGlutinitwindowsize ( -, -); theGlutcreatewindow ("the Sun, the Earth and the moon"); theGlutdisplayfunc (&mydisplay); +Glutidlefunc (&myidle); - Glutmainloop (); the Bayi     return 0; the}
View Code

4. Select the project properties, select the C/c++-> preprocessor, and at the right of the "preprocessor definition", delete the "_console"

5. In the project properties, switch to the "linker" system, the subsystem selection of the right window: Window (/subsystem:windows)

6. In the project properties, switch to the "linker" command line, and in "Other options" Enter:/entry:maincrtstartup (You can remove the DOS window that appears when the program is running)

Compile and run, you can see the "Sun, Earth and Moon Dynamic operation Diagram"!

second, the program cannot start this application because the computer is missing Glut32.dll

Windows7 64-bit +vs2010

Tip: The program cannot start this application because the computer is missing glut32.dll ...

Resolute View System32 folder, found this file, then don't understand, why still can't find it, unreasonable ah.

Womb did not find, in order to see the effect of the code run as soon as possible, the DLL copied to the generated EXE sibling directory, ah, can be.

but not reconciled, then looked at the Windows directory, found in the System32 sibling directory also has a directory: SysWOW64, it seems to be a 64-bit unique folder, Decisively check the ins and outs of this folder, here quoted the explanation of Baidu Encyclopedia:

Convert library

And in this directory found Glut.dll, this is not a close relative of Glut32.dll, so put this DLL into the directory, and the EXE in the same class directory of the DLL removed, sure enough to run successfully.

Third, manually uninstall Visual Studio

Next I'm going to say two more questions about uninstalling VS2010, because I've had a minor problem in development, uninstalled it and re-installed it, but uninstalling is a bit trickier than other software. When uninstalling to pay attention to install VS2010 time, I recommend using 360 software housekeeper Uninstall, according to the time to manually uninstall. The items that were manually uninstalled are as follows:

1. Delete all instances of the Visual Studio products.

2. uninstall any support products in the following order. When you use a non-English installation, you must also remove the language packs for some of the products that are listed. There is no need to restart until you delete the last package on the list.

A. Microsoft Visual Studio ADO Entity Framework Tool

B. Microsoft SQL Server R2 Transact-SQL language service

C. Microsoft SQL Server R2 Data-tier application project

D. Microsoft SQL Server R2 Data- Tier application framework

E. Microsoft Sync Framework SDK version 1.0 SP1

F. Microsoft Sync Framework Services version 1.0 SP1

G. Microsoft Sync Framework Runtime version 1.0 SP1

H. Microsoft Silverlight 3 SDK

I. Microsoft ASP 2

J. Microsoft asp 2-visual Studio Tools

K. Microsoft. NET Framework 4 multi-targeting Pack

L. Microsoft TFS object Model

M. Microsoft Visual F # 2.0 runtime

N. Microsoft Visual Studio x64 Prerequisites

Solutions for configuring OpenGL in VS2010 and for problems encountered with 64-bit systems

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.