Thursday, 12 September 2013

Execute opengl programs in Microsoft visual studio 10

  • Windows Using MS Visual C++
Installing GLUT
    1. Most of the following files (i.e. OpenGL and GLU) will already be present Microsoft Visual Studio 2010. The following GLUT files will need to be verified into the specified directories.
    2. To install:
Installation/verification:
OpenGL comes with the OS and Visual Studio 2010/2008 installations, to verify:
·         runtime libraries:
C:\Windows\System32\{opengl,glu}32.dll
on 64-bit Windows:
C:\Windows\SysWOW64\{opengl,glu}32.dll
·         header files:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\GL\{GL,GLU}.h
["Program Files (x86)" for 64-bit Windows; VS2008: v6.0A]
·         linker library:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\OpenGL32.Lib
["Program Files (x86)" for 64-bit Windows; VS2008: v6.0A]
Install GLUT by downloading the glut zip file (v. 3.7.6) from the web and copying its files to the correct folders as follows:
ü  Runtime Library:
C:\Windows\system\glut32.dll
ü  Header File:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\GL\glut.h
ü  Linker Library:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\glut32.lib
ü  Alternatively ,Copy the OpenGL/GLU dll , the header and linker library files under "C:\Program Files\Microsoft Visual Studio 10.0\VC\"
ü  Later in your OpenGL source files, include the following line:
#include <GL/glut.h>
1.      Create a new project:
ü  Choose File | New from the File Menu, Select the Projects tab

ü  Choose Win32 Console Application, Fill in your Project name
ü  On the "Welcome to the Win32 Application Wizard" page, click  Next

ü  On the "Application Setting" dialog box, under "Additional options" tick "Empty project", then click "Finish"

Add Source files:

ü  Right click on "sampleapp" on the second line of the "Solution Explorer" pane on the left to "Add→New Item (If need to add new file) / Existing Item (to open existing file)"
select your file and click "Add".
ü  Open Notepad and type the program. Then store it as filename.c


2.      Add libraries:
ü  Right click on "sample" again and select "Properties" to tell the linker which libraries need to be added

ü  On the "Property Pages", under "Configuration:" tell VS to add the additional libraries to "All Configurations”

ü  Select "Configuration Properties→Linker→Input" on the left pane, and enter:
opengl32.lib; glu32.lib; glut32.lib;
Then click "Apply"

ü  Optional:
To prevent your program from opening a console window, while still on the "Property Pages", select "Configuration Properties→Linker→Command Line" on the left pane, and enter:
/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup
Then click "Apply"

ü  Close the "Property Pages" pane by clicking "Ok",
3.      Build and Execute

Click on the play button on the second menu bar (   ) to build and run the program. If you print out messages to the console, run the program using Ctl-F5 instead,to keep the command window from exiting after the program exits.

No comments:

Post a Comment