Something More for Research

Explorer of Research #HEMBAD

Getting OpenGL Set Up on Windows

Posted by Hemprasad Y. Badgujar on October 1, 2012


START 1

Getting OpenGL Set Up on Windows

 What exactly is OpenGL? It’s a way to draw stuff in 3D. It can also be used for 2D drawing, but this site doesn’t focus on that. There are better tools for straight 2D drawing, such as SDL and Allegro.

The graphics card is where the 3D computation happens. The purpose of OpenGL is to communicate with the graphics card about your 3D scene.

So why not talk to the graphics card directly? Each graphics card is a little different. In a sense, they all speak different “languages”. To talk to them all, you can either learn all of their languages, or find a “translator” that knows all of their languages and talk to the translator, so that you only have to know one language. OpenGL serves as a “translator” for graphics cards.

This lesson will explain how to get OpenGL and GLUT set up on Windows. We’ll use the Visual C++ Express 2005 IDE to edit, compile, and run our programs. Visual C++ Express is a free IDE. To use it, you will have to register, which is free, within 30 days. You can use another IDE if you prefer, but getting it set up will be a little different.

Downloading and Installing

First, download and install the necessary software using the following instructions:

  1. Download Visual C++ Express and the Microsoft Platform SDK from the Microsoft website. Note that when you download the SDK, it may say something about Windows Server. Don’t worry about that; it’ll install just fine on any modern version of Windows.
  2. Install Visual C++ and the SDK.
  3. Download the OpenGL installer from here and the GLUT binary from here.
  4. Run the OpenGL installer.
  5. Extract GLUT to the directory of your choice. You can do this by creating a new directory, locating and opening the ZIP file using Windows Explorer, and copying the files to the new directory using copy-paste. Alternatively, you can use a free program like WinZip to extract GLUT.
  6. In the directory to which you extracted GLUT, make two folders, one called “include” and one called “lib”. In the “include” folder, create another folder called “GL”, and move glut.h to that folder. Move all of the other files that you extracted for GLUT into the “lib” folder.
  7. Run Visual C++ Express. Go to Tools -> Options, then Projects and Solutions -> VC++ Directories. Note where it says “Show directories for”. You’ll want to change the directories for include files by adding “x\include”, “y\include”, and “z\Include” and to change the directories for library files by adding “x\lib”, “y\lib”, and “z\Lib”, where “x” is the folder where you installed OpenGL, “y” is the folder where you extracted GLUT, and “z” is the folder where you installed the Microsoft Platform SDK.
  8. Change your PATH environment variable as follows: go to the control panel, and go to System. Go to the “Advanced” tab and click on “Environment Variables”. Find the “PATH” (or “Path”) variable. Change it by adding “;x\lib;y\lib;z\Lib” (without the quotes) to the end of it, where again, “x“, “y“, and “z” are the folders where you installed OpenGL, GLUT, and the Microsoft Platform SDK. Make sure there are no spaces before or after the semicolons.
  9. Reboot your computer, so that Windows will recognise the changes to the PATH environment variable.

Compiling and Running the Test Program

To make sure that everything was set up correctly, we’re going to see if we can get a test program to work.

  1. Download this test program and extract it somewhere on your computer.
  2. Run Visual Studio C++. Go to File -> New -> Project From Existing Code.
  3. Click next to indicate that you are making a Visual C++ project.
  4. Set the project file location to the folder to which you extracted the test program. Enter in a name for your project (such as “cube”) and click next.
  5. Change the project type from “Windows application project” to “Console application project”, and click next.
  6. Click next, then click finish to finish creating the project.
  7. Go to Project -> Properties. Click on Configuration Properties. Click the “Configuration Manager” button in the upper-right corner. Change the “Active solution configuration” from “Debug” to “Release”. Click close, then click OK.
  8. In Project -> Properties, go to Configuration Properties -> General. Where it shows the output directory as “Release”, backspace the word “Release”, and click OK. This makes Visual C++ put the executable in the same directory as the source code, so when our program needs to open a file, it looks for it in that directory. In this case, the program will have to load in an image file called “vtr.bmp”.
  9. Go to Build -> Build project_name to build your project.
  10. There should be two warnings about ignoring /INCREMENTAL. You don’t have to, but if you want, you can fix them as follows. In Project -> Properties, go to Configuration Properties -> Linker, and change “Enable Incremental Linking” from “Yes (/Incremental)” to “No (/Incremental:No)”.
  11. Run the program by going to Debug -> Start Without Debugging. If all goes well, the test program should run.

Note that you’ll have to set up a project every time you want to work on a program from my site, so you’ll have to repeat steps 1 – 11 above.

I’d like to point out a couple of things about the program. First of all, notice that the project has a file called “Makefile”. It’s not used on Windows; it’s only needed for Linux, Mac OS X, and other UNIX-based operating systems. But Visual C++ will automatically ignore the file, so you don’t have to worry about removing it from the project.

Secondly, take a look at main.cpp. Notice that the include directives for OpenGL appear after the #include directives for the normal C++ include files. If we had them in the opposite order, because of the Windows download that I recommended for GLUT, you’d get a compiler error. So make sure that the include files for the standard C++ stuff appear before the include files for OpenGL.

Whew! We’ve finished setting up OpenGL. Now we’re ready to learn how to program in 3D.

 

 

Advertisements

One Response to “Getting OpenGL Set Up on Windows”

  1. zzzz said

    copied from here ……. please at least try to give credit to the original publishers

    http://www.videotutorialsrock.com/opengl_tutorial/what_is_opengl/text.php

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Extracts from a Personal Diary

dedicated to the life of a silent girl who eventually learnt to open up

Num3ri v 2.0

I miei numeri - seconda versione

ThuyDX

Just another WordPress.com site

Algunos Intereses de Abraham Zamudio Chauca

Matematica, Linux , Programacion Serial , Programacion Paralela (CPU - GPU) , Cluster de Computadores , Software Cientifico

josephdung

thoughts...

Tech_Raj

A great WordPress.com site

Travel tips

Travel tips

Experience the real life.....!!!

Shurwaat achi honi chahiye ...

Ronzii's Blog

Just your average geek's blog

Karan Jitendra Thakkar

Everything I think. Everything I do. Right here.

VentureBeat

News About Tech, Money and Innovation

Chetan Solanki

Helpful to u, if u need it.....

ScreenCrush

Explorer of Research #HEMBAD

managedCUDA

Explorer of Research #HEMBAD

siddheshsathe

A great WordPress.com site

Ari's

This is My Space so Dont Mess With IT !!

%d bloggers like this: