| Home | About | Links | Problems | My Graphics BaseCode | Contact |
There are several uses for this code:
Mostly, however, it was useful for me to write and organize the code. I use it in all my math, graphics, and research classes, even if it is for something as trivial as visualizing a 3D isosurface or drawing a binary tree, and it has made Caltech quite an easy school.
The code comes in several versions; right now they are all Visual Studio solution files. This simple version just demonstrates draws a rotating sphere (for more complex examples, go HERE.) You can get a zip of the full version of the BaseCode below, or click on the link for more versions and help loading and linking the project, as well as copies of the libraries themselves. For help navigating the code (not necessary to just see if the BaseCode works) go here.
BaseCode.zip
Other versions, plus compiling and linking information
There is quite a lot of code in quite a lot of files. However, only four files are actually compiled and linked. Two of these files are changed often between various graphics projects; the other two change only rarely. These files, and their functions, are:
Main.h is included by all source files and includes every header file in the correct order. In VC++, this would normally be made into a pre-compiled header (*.pch.) There are also various #includes here for enabling or disabling various features (such as DirectX or OpenGL) if you don't have certain libraries or header files. It also describes the libraries necessary to link the project.
MainControl includes everything that changes often between applications, such as what meshes to load, and also determines what is rendered each frame. Essentially all project-specific code, and no API specific code, goes here. Common tasks of the MainControl class involve initalizing meshes and the world/view/perspective matrices, then updating the camera and rendering the meshes on the scene each frame. The MainControl class here just draws a sphere on the screen each frame.
MainControl.h, Web Version
MainControl.cpp, Web Version
The God class glues the operating system, the graphics API, the application interface, and the application's main window together. It is essentially the first and the last code that is executed. It maintains copies of most of the other classes (AppInterface, WindowManager, GraphicsDevice) and invokes their code in the appropriate order. Various paramaters in God.cpp may be changed between projects to change the API that is used, whether to capture the screen each frame, the screen or window resolution to use, etc.
God.h, Web Version
God.cpp, Web Version
The interface between the application and the MainControl class. A very short class that is really only a go-between, and is entirely unnecessary if there is only one MainControl class. The reason for AppInterface will become apparent later, when multiple MainControls are used. In general, all this code does is create an instance of the MainControl class, and invoke its procedures when it is told to do so by the God class. Unless you change the number of MainControl classes or the interaction between them, you won't need to change this file.
AppInterface.h, Web Version
AppInterface.cpp, Web Version
This is not a class or structure with member function, but a single file that includes all the classes/structures that do not change from project to project. These include classes for meshes, pixels, vectors, matrices, linked lists, Z-Buffers, cameras, etc. Most of the source code is included in this file. The files it includes are categorized into a variety of folders, which are themselves in a folder called Engine. Since I use these files constantly I put the entire Engine folder in an include directory uniform to all my projects, but a copy could easily be carried around for each project. While I've considered linking them into a single library, I like being able to browse the source code itself on occasion.
Engine.h, Web Version
Engine.cpp, Web Version
These are all the various folders of code files included in Engine.h/Engine.cpp.
Core Functions
Math Structures
Graphics Structures
Textures
Mesh Structures
Edge-Based Mesh
Graphics Devices
Composite Objects
Windows Controllers
last updated: May 13th 2005 © 2005 by Matthew Fisher