Monday, January 4, 2010

OpenGL on Windows & Common Instructions

Download glut for Windows here here.

Common instructions for setting up opengl with Visual Studio
Many different sites have posts about this. However, I'm going to give you hints. In Pro versions SDKs are installed by default. If you are using Visual Studio Express you need to install Windows Platform SDK.

Now extract the glut archive you just downloaded from this page. Copy glut.h and paste where GL.h and GLU.h resides.


[Click image to enlarge]

The directory is PlatformSDKInstallDIR\Windows\VERSION\Include\gl
Copy dll file to System 32 folder
Copy lib file to to PlatformSDKInstallDIR\Windows\VERSION\Lib

For Visual Studio 2008 Pro files go like this.
      glut.h -> C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl
      glut32.dll-> C:\Windows\System32
      glut32.lib -> C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib

Testing OpenGL Code
  • Create new win32 -> win32 project.
  • Click Solution Explorer. Right click Source Files. Click Add - > New Item. Specify a name. Select .cpp as template.
  • Download this code file. Extract and copy the contents of the cpp file and paste on the empty cpp file of the IDE
  • Select Project properties additional dependency: opengl32.lib glut32.lib glu32.lib


    [Click image to enlarge]

  • To build press Alt + Shft + B. If build is successful press Ctrl + F5 to run the program.


    [Click image to enlarge]
If your opengl code does not have a WinMAIN function, instead you have a main function then the type of project to be created should be General -> Empty Project to avoid linker errors. Output of the program will start with a console. In both cases you need to remember about selecting additional dependency: opengl32.lib glut32.lib glu32.lib in project properties.

Example of such code here.

Related Links:

1 comment:

  1. Previously compiled Windows Seven version of glut has been removed when a few people reported disruption.

    ReplyDelete