Creating a new Visual C++ 6.0 project

    The Microsoft C++ compiler, like most integrated development environments, combines source files into a project.  Also it combines projects into a "workspace".   The projects are a collection of source code and other resources, such as icons, menus, and other widgets.
    When writing programs, you will in many cases find it convenient to use an existing workspace/project to create a new application.    Often, of course, you don't want to do this (for instance, if you don't want to overwrite your existing project) and then you will want to create a new project. 

    This page describes briefly the steps needed to make a new C/C++ project that uses the aux or glut OpenGL library routines.  The same steps are used, in fact, for any program which has a main() program as its entry point.  We will describe the simplest possible way to do this.   For more information consult the online documentation provided with the Microsoft C++ compiler.

Step 1: Have the Visual C++ compiler running and as the active window.   If you have a workspace currently open, close it from the the File menu. 
    Then under the File menu, choose New....   A dialog box opens: choose the Projects tab.  Select Win32 Console Application as the project type.  Choose a project name (something informative, but not too long), and a directory for a location (the C++ compiler will automatically create a folder whose name is the same as the project).  Keep Create new workspace and Win32 selected.  Press OK.
   
In the next box, select either Empty Application, Simple Application or Hello-World Application.  (Empty Application is almost always best.)

Step 2:  You may start creating new .c, .cpp, and .h files in the usual way (use New from the File menu).  Once a source file is created, you must add it to the project.   You do this by selecting the Project menu, then Add to Project, then Files....
   Alternately, instead of creating a new file via the File menu and later adding it to the project, you may create a new file that is already in the project by using the Project menu, then Add to Project, then New....
    [There are various other, shortcut methods of adding a file to a project:  you may try to compile it and it will prompt you to put it in the project.   Or you may try right-clicking on the source file window.]

Step 2': Instead of creating a completely new source file, you may wish modify an existing source file for your new project.  (For instance, another OpenGL program, that you want to modify).  To do this, first create a copy of the source file and put it in your new project directory.   Then select the the Project menu, then Add to Project, then Files... to add it to the project.  Don't forget to use the same procedure for header files.
    If you skip the step of making a new copy of the file before adding it to your project, then you will have the same source file in two different projects.   If you modify the file for one project, it will also change the other project and in most cases, this is not what you want!

    Use the method of Step 2' to add additional source files to your workspace as needed.    The C++ compiler has a "Workspace" window on the left side of the screen.  Switch to the FileView mode in this window to have convenient access to the different files in your project.

Step 3: Compile your program using the Build menu or the shortcut key F7.  Run your program, with from the Build menu, or with the shortcut key F5.

Using I/O (stdin/stdout):  If you run your program it will open a text window (in addition to any OpenGL window).  The standard C I/O routines, such as printf, may be used to read and write from the window, via stdin and stdout.  If you want to do this, don't forget to include the necessary C header files.

Potential problems:

1. If you set your project up the wrong way, you may get compile-time errors about the use of precompiled headers.  If this happen, use the Project menu, go to Settings..., then choose the C/C++ tab, select Category Precompiled Headers and turn off precompiled headers.

2. If you are using the newer Visual C++ Studio.NET, similar procedures apply.  Make sure you choose a Win32 Console Application, and at the end, find the option that lets you start with an empty project.

3. If you are using old versions of the GLUT header file, you need to tell the compiler (or to be precise, the linker) to include the OpenGL libraries.    If you do not do this, then you will get lots of error messages about unresolved external references.  This is done by selecting the Project menu, then Settings..., and then in the dialog box, Link.  This shows a dialog box with a editable field Object/Library modules.  Add to the end of the contents of this field, the following three OpenGL library names:

opengl32.lib glu32.lib glut32.lib

If you would rather not do this, you can also use the #pragma command to tell the compiler which libraries to use: the newer versions of glut32.h use the pragma commands, and this is why you may be able to skip this step.  (If you are using the OpenGL aux libraries, then you need to add glaux.lib to the list of library names instead of glut32.lib.)