Saturday, June 15, 2013

Setting up OpenGL with Visual Studio

1. place dependencies to system folders

copy header files into C:\Program Files(x86)\Windows Kits\8.0\Include\um\gl
copy lib files into C:\Program Files(x86)\Windows Kits\8.0\Lib\win8\um\ 
copy dll files into C:\windows\SysWOW64\
By placing dependencies into system folders, one doesn't have to specify directories from Visual Studio side. However, if you wanna run your project at any place without messing up the system folders, try the procedure below.

2. place dependencies to arbitrary folders 
Assuming header, library, and binary files(.dll) were placed in an arbitrary folder, i.e.

header and lib were placed in 'C:\Project_Folder\Dependencies\gl\'

binaries were placed in 'C:\Project_Folder\Dependencies\gl\bin\'
Here is how to set up these directories with visual studio
   (1) header and library  
       header: Propoertie Pages\VC++ Directories\Include Directories\   
       library : Propoertie PagesVC++ Directories\Library Directories\
   (2) linker


      Linkers can be specified through 
      Property Pages\Linker\Input\Additional Dependencies\ 


      or  added in the code as
            #pragma  comment (lib , "glew32.lib" )
            #pragma  comment (lib , "freeglutd.lib" )
            #pragma  comment (lib , "glu.lib" )
            #pragma  comment (lib , "glut.lib" )
            #pragma  comment (lib , "glut32.lib" )

   (3) binary
In order to have your application run smoothly, the OpenGL binary files have to be placed in the same folder with your application(.exe). You may copy OpenGL binary files into each of the output folder of your project, or you could switch the project output dir to where the OpenGL binaries located. The output dir can be specified atPropoertie Pages\Common Properties\General\Output DirectoryNote: end the directory with a trailing slash, or VS will throw a warning.
The whole procedure can be done through  project properties page for each single project. This can also be completed at View\Property Manager to avoid repeating the same setup for different projects. Once directories were added through property manager, the properties will be applied to all projects automatically.

No comments:

Post a Comment