Using the WinBGI Graphics Package
These are general instructions for
creating a blank graphics project. Use this to start most of the projects.
Create a new project with the name given in class for that assignment. This
part is just like the tutorial you already saw. Here's a detailed
summary:
- Start the compiler (Start... Programs... Computer Science Programs...
Microsoft Visual Studio .NET 2003...
Microsoft Visual Studio .NET 2003)
- Click the menu item File | New |
Project... or press CTRL+SHIFT+N or click the New Project
button.
- On the "New Project" window, do four things:
- In the left pane expand the selection named
Visual C++ Projects and then select Win32.
- In the right pane, select Win32 Console Project.
- In the Name: text box type a name, for example
initials.
- In the Location: text box, click on the button to
browse to your 105_Projects folder.
- Click the OK button to continue.
- Click Application Settings on the left side of the window and then
place a check in the box marked Empty project.
- Click Finish.
Adding Existing Source Code
- Next, minimize the compiler and copy some files into the folder the
compiler just created for you. You can copy them from any other place, or from this web page. These are the files you need:
- Note: To copy these from this web page, right-click on the links
above, and then do File... Save Target As... and save those files in
the correct directory.
- Rename blank_graphics.cpp to whatever project name you're
working on. (For example: initials.cpp)
- Go back into the compiler and add those 3 files into your project. To do
this: Under Project menu, choose Add Existing Item... (or
Shift-Alt-A) then select all three files.
Since you'll be using these three files
repeatedly, I suggest saving them somewhere easy to find in your My Documents
(Called "Save Files Here" in the computer lab).
Minimal Graphics program:
Here's what the blank_graphics2.cpp program looks like. This program,
along with the graphics2.h and winbgi2.cpp is sort of the bare
minimum just to bring up a blank, black graphics window:
//
// Project
Name:
//
// Author:
// Date
:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "graphics2.h"
#define ESC 0x1b
void
main()
{
srand(time(NULL));
// Seed the random number
generator
int
GraphDriver=0,GraphMode=0;
initgraph(
&GraphDriver, &GraphMode, "", 640, 480 ); // Start
Window
char
tempstring[80];
getch(); //Wait for a key. (When main function ends, the window will
close)
} //end of
main()
(Last Updated 6-Sep-2004, Matthew
Weathers)