Using the WinBGI Graphics Package

Fall 2006, Biola University

   

Introduction

You can use the WinBGI Graphics package to do simple non-object oriented non-event driven graphics in Visual Studio .NET C++

General Instructions

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 2005...
        Microsoft Visual Studio .NET 2005
    )
  • 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 a folder (usually best to avoid network drives like DigitalLocker.  Instead, put it on D: (Temp), then copy when you're done and want to save it).
  • 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... or Save Link 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 DigitalLocker.

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()
 

Some Simple Graphics Projects

A lot of these examples come in ZIP files.  Just download and unzip the files, and open the project in Visual Studio.

Some example graphics commands.

Drawing patterns: Download the lines.zip project.

Bouncing Lines Screen Saver project - learn simple animation.  Start with: bouncing_lines.zip.  Another animation project:  planets.zip.

Learning how to do animation: Start with bounce.zip.  Solution: BouncingBall.zip - See source: bouncing_ball.htm

More Resources

Games! You can use this graphics package to make simple games.  Here are some related resources:

Some example games: blank_game.zip, simple_game.zip, grid_game.zip

Final Games Fall 2005 - Final projects from Fall 2005.

Final Games - Final projects from Fall 2004.

See how to Add an Icon, and Change to Release Mode.

Tutorial on MS Visual Studio .NET (Handout with step-by-step instructions)

See all 64 colors that you can use in a graphics project.

How to Use the Mouse in a graphics Project.

A Picture Gallery of some past projects. (Initials, etc.)

(Last Updated 12-Oct-2006, Matthew Weathers)