Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

main.cpp File Reference

#include <windows.h>
#include "shared.h"
#include "general.h"
#include "listnode.h"
#include "locmath.h"
#include "vector.h"
#include "vertex.h"
#include "quat.h"
#include "matrix.h"
#include "texture.h"
#include "polygon.h"
#include "tll.h"
#include "plane.h"
#include "object.h"
#include "camera.h"
#include "light.h"
#include "collision.h"
#include "glfont.h"
#include "bspline.h"
#include "bsp.h"
#include "portal.h"
#include "pvs.h"
#include "tga.h"
#include "lightmap.h"
#include "winfuncs.h"
#include "console.h"
#include "log.h"
#include "bass.h"
#include "sound.h"
#include "bullet.h"
#include "decal.h"
#include "particle.h"
#include "mmgr.h"
#include "resource.rh"

Go to the source code of this file.

Functions

int InitGL (int Width, int Height)
void ReSizeGLScene (int Width, int Height)
void DrawGLScene (void)
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int)

Variables

ConsoleWindow Console
HGLRC hRC
HDC hDC
HWND hWnd
HINSTANCE g_hInst
RECT screen
PAINTSTRUCT ps
char AppDirectory [MAX_PATH]
float ApplicationStartTime
float pi = 3.141592
float radian = pi / 180
float epsilon = 0.05
bool key [256]
bool released_key [256]
int currentCamera = 0
int numCameras = 4
float step = 30.0
float lasttime
float multiplier
const int average = 10
float lastmultiplier [average]
int fps
int GL_LIGHT [8] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}
int currentLight = 0
int numLights = 0
PLANE frustum [6]
int numVertices = 37
VERTEXvertex = new VERTEX[numVertices]
int numPolygons = 58
POLYGONpolygon = new POLYGON[numPolygons]
POLYGONbsppolygon = new POLYGON[numPolygons]
TEXTUREtexture = new TEXTURE[10]
CAMERAcamera = new CAMERA[numCameras + 1]
CAMERA LastCam
int maxDecals = 100
DECAL muzzleflashdecal
DECAL impactflashdecal
LIGHTlight = new LIGHT[numLights + 1]
float lightColor [3] = {1.0, 1.0, 1.0}
HWND hWndStartDlg
int DialogInUse = 0
char szText [BUFFER_SIZE]
GLFONT myFont
float Min_X
float Min_Y
float Min_Z
float Max_X
float Max_Y
float Max_Z
int bulletspeed = 0
int bullettype = 1
int numleavesvisible = 0
int showportals = 0
int numlistleaves = 0
int numlistpartitions = 0
int numcurrentportals = 0
float test = 0.0
int device
BOOL lowqual
int numSamples = 0
int numChannels = 0
LinkedList< SOUND_SAMPLESampleList
LinkedList< SOUND_CHANNELChannelList
float shotlast
int numBullets = 50
BULLETbullet = new BULLET[numBullets]
int numBulletsActive = 0
int numleaves = 0
int currentleaf = 0
int numpartitions = 0
bool BuiltBSP = false
BSP_noderoot = new BSP_node
LinkedList< PORTALPortalList
int numportals = 0
PORTALportal
int numStaticLights = 9
StaticLightstaticlight = new StaticLight[numStaticLights]
int numLightmaps = 0
Lightmaplightmap = new Lightmap[numPolygons]
int visible = 0
int numSplines = 0
int cameraMode = 2
int currentSpline = 0
int lookAtPath = 0
char SplineFileName [MAX_PATH]
SPLINEspline
LinkedList< SPLINESplineList
LinkedList< ListNodeLeafList
LinkedList< ListNodePartitionList
ListNodelistnode
ParticleManager PManager


Function Documentation

void DrawGLScene void   
 

Definition at line 284 of file main.cpp.

References LIGHT::Apply(), CalculatePVS(), channel_gunshot, CheckForCollision(), CountVisibleLeaves(), currentCamera, currentleaf, DrawDecals(), DrawMyText(), DrawSplines(), DrawWorld(), CollisionPacket::eRadius, ExtractFrustum(), FindCurrentLeaf(), numleavesvisible, numLights, OBJECT::Position, CollisionPacket::sourcePoint, ParticleManager::Update(), UpdateBullets(), UpdateChannel(), UpdateListener(), CollisionPacket::velocity, VECTOR::x, VECTOR::y, and VECTOR::z.

Referenced by WinMain(), and WndProc().

00285 {
00286     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00287 
00288     LastCam = camera[currentCamera];
00289     camera[currentCamera].Update();
00290 
00291     CollisionPacket cp;
00292     cp.eRadius.x = 1.0;
00293     cp.eRadius.y = 1.0;
00294     cp.eRadius.z = 1.0;
00295     cp.sourcePoint.x = LastCam.Position.x;
00296     cp.sourcePoint.y = LastCam.Position.y;
00297     cp.sourcePoint.z = LastCam.Position.z;
00298     cp.velocity.x = camera[currentCamera].Position.x - LastCam.Position.x;
00299     cp.velocity.y = camera[currentCamera].Position.y - LastCam.Position.y;
00300     cp.velocity.z = camera[currentCamera].Position.z - LastCam.Position.z;
00301 
00302     CheckForCollision(polygon, &camera[currentCamera].Position, &cp);
00303 
00304     camera[currentCamera].Apply();
00305 
00306     for(int loop = 0; loop <= numLights; loop++)
00307         light[loop].Apply();
00308 
00309     currentleaf = FindCurrentLeaf(camera[currentCamera].Position, root);
00310 
00311     ExtractFrustum();
00312     CalculatePVS(currentleaf);
00313     numleavesvisible = CountVisibleLeaves();
00314 
00315     UpdateListener();
00316 
00317     UpdateChannel(channel_gunshot, &camera[currentCamera].Position, NULL, NULL);
00318 
00319     UpdateBullets();         // Added this function to general.cpp
00320 
00321     PManager.Update();       // Update particles
00322 
00323     DrawWorld(root);             // Particles are rendered along with the world in bsp.cpp
00324 
00325     DrawDecals();            // Added this function to decal.cpp
00326 
00327     DrawSplines(SplineList);           // Required to calculate the camera path
00328 
00329     DrawMyText();              // Draw text last
00330 }

int InitGL int    Width,
int    Height
 

Definition at line 180 of file main.cpp.

References AddPortalsToLeaves(), ApplicationStartTime, BuildBSP(), BuiltBSP, cameraMode, CreateBouncy(), CreateBSPLightmaps(), CreateRomanCandle(), CreateSounds(), FindTruePortals(), glFontCreate(), InitializeBASS(), InitializeBullets(), BSP_node::leaf, LoadBSPLightmaps(), MakeNodeLists(), MakePortalList(), Max_X, Max_Y, Max_Z, Min_X, Min_Y, Min_Z, BSP_node::nodeid, BSP_node::nodelightmaplist, BSP_node::nodepolylist, BSP_node::numdecals, numPolygons, BSP_node::numpolys, VECTOR::Set(), SetGLCamera(), SetGLLighting(), SetGLMaterial(), SetGLProperties(), SetGLTexture(), SetGLWorld(), SetSplines(), SetStaticLights(), DECAL::Size, POLYGON::Vertex, BSP_node::visible, VERTEX::x, VERTEX::y, and VERTEX::z.

Referenced by WinMain().

00181 {
00182     int ReturnValue;
00183 
00184     srand((unsigned)time(NULL));
00185     
00186     InitializeBASS();
00187     CreateSounds();
00188 
00189     ApplicationStartTime = (float)GetTickCount();
00190     cameraMode = 0;
00191 
00192     SetGLProperties();
00193     SetGLMaterial();
00194     SetGLLighting(light);
00195     SetGLCamera(camera);
00196     SetSplines(SplineList);
00197 
00198     if (!SetGLTexture(texture))
00199         ReturnValue = 0;
00200     else
00201         ReturnValue = 1;
00202 
00203     // Create the font texture
00204     glFontCreate(&myFont, "roman.glf", 600);
00205 
00206     SetGLWorld(polygon, texture, vertex);
00207 
00208     // Find the bounding box of the data set
00209     Min_X = polygon[0].Vertex[0].x;
00210     Min_Y = polygon[0].Vertex[0].y;
00211     Min_Z = polygon[0].Vertex[0].z;
00212     Max_X = polygon[0].Vertex[0].x;
00213     Max_Y = polygon[0].Vertex[0].y;
00214     Max_Z = polygon[0].Vertex[0].z;
00215     for (int loop = 0; loop < numPolygons; loop++)
00216     {
00217         for (int i = 0; i < 3; i++)
00218         {
00219             if (polygon[loop].Vertex[i].x < Min_X )
00220                 Min_X = polygon[loop].Vertex[i].x;
00221             if (polygon[loop].Vertex[i].y < Min_Y )
00222                 Min_Y = polygon[loop].Vertex[i].y;
00223             if (polygon[loop].Vertex[i].z < Min_Z )
00224                 Min_Z = polygon[loop].Vertex[i].z;
00225             if (polygon[loop].Vertex[i].x > Max_X )
00226                 Max_X = polygon[loop].Vertex[i].x;
00227             if (polygon[loop].Vertex[i].y > Max_Y )
00228                 Max_Y = polygon[loop].Vertex[i].y;
00229             if (polygon[loop].Vertex[i].z > Max_Z )
00230                 Max_Z = polygon[loop].Vertex[i].z;
00231         }
00232     }
00233 
00234     // BSP initialization
00235     for (int i = 0; i < numPolygons; i++)
00236         bsppolygon[i] = polygon[i];
00237 
00238     root->nodeid = 0;
00239     root->leaf = 0;
00240     root->visible = 0;
00241     root->numpolys = numPolygons;
00242     root->nodepolylist = bsppolygon;
00243     root->nodelightmaplist = lightmap;
00244     root->numdecals = 0;
00245     BuildBSP(root);
00246     BuiltBSP = true;
00247 
00248     // Portal Creation
00249     MakeNodeLists(root);
00250     MakePortalList();
00251     AddPortalsToLeaves(root);
00252     FindTruePortals(root);
00253 
00254     // Initialize static lights
00255     SetStaticLights(staticlight);
00256 
00257     // Create the lightmaps
00258     CreateBSPLightmaps(root);
00259     LoadBSPLightmaps(root);
00260 
00261     // Model Initialization
00262     InitializeBullets();
00263 
00264     // Decal Initialization
00265     muzzleflashdecal.Size = 3;            // Set the decal sizes
00266     impactflashdecal.Size = 3;
00267 
00268     // Particle Initialization
00269     VECTOR tempvect(0.0, -10.0, -30);
00270     CreateRomanCandle(tempvect);
00271     tempvect.Set(-10.0, -10.0, -30);
00272     CreateBouncy(tempvect);
00273     tempvect.Set(10.0, -10.0, -30);
00274     CreateBouncy(tempvect);
00275 
00276     return ReturnValue;
00277 }

void ReSizeGLScene int    Width,
int    Height
 

Definition at line 279 of file main.cpp.

References SetGLView().

Referenced by WndProc().

00280 {
00281     SetGLView(Width, Height);
00282 }

int WINAPI WinMain HINSTANCE    hInstance,
HINSTANCE   ,
LPSTR   ,
int   
 

Definition at line 533 of file main.cpp.

References DECAL::active, BULLET::active, AppDirectory, ApplicationStartTime, average, bulletspeed, bullettype, cameraMode, channel_gunshot, Console, currentCamera, currentLight, DialogInUse, DrawGLScene(), FALSE, BULLET::flag, g_hInst, GetTimePassed(), hDC, hRC, hWnd, InitGL(), key, lastmultiplier, lasttime, OBJECT::Multiplier, multiplier, numBullets, numBulletsActive, numCameras, numLights, OBJECT::Orientation, BULLET::OriginalPosition, PlayChannel(), OBJECT::Position, BULLET::PreviousPosition, released_key, screen, shotlast, showportals, step, TRUE, BULLET::VelocityVector, and WndProc().

00537 {
00538     MSG        msg;
00539     g_hInst = hInstance;
00540     GetWindowRect(GetDesktopWindow(), &screen);
00541 
00542     WNDCLASSEX    wc;
00543     wc.cbSize = sizeof(WNDCLASSEX);
00544     wc.style            = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_SAVEBITS;
00545     wc.lpfnWndProc        = (WNDPROC) WndProc;
00546     wc.cbClsExtra        = 0;
00547     wc.cbWndExtra        = 0;
00548     wc.hInstance        = hInstance;
00549     wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
00550     wc.hIconSm          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
00551     wc.hCursor            = LoadCursor(NULL, IDC_ARROW);
00552     wc.hbrBackground    = NULL;
00553     wc.lpszMenuName        = NULL;
00554     wc.lpszClassName    = "OpenGL WinClass";
00555 
00556 
00557     if(!RegisterClassEx(&wc))
00558     {
00559         MessageBox(NULL,"Failed To Register The Window Class.","Error",MB_OK|MB_ICONERROR);
00560         return FALSE;
00561     }
00562 
00563     hWnd = CreateWindowEx(
00564     WS_EX_LEFT,
00565     "OpenGL WinClass",
00566     "OpenGL & Win32 Tutorial No.16",
00567     WS_MAXIMIZE |
00568     WS_CLIPCHILDREN |
00569     WS_CLIPSIBLINGS |
00570     WS_POPUPWINDOW |
00571     WS_VISIBLE,
00572     0, 0,
00573     screen.right, screen.bottom,
00574     NULL,
00575     NULL,
00576     hInstance,
00577     NULL);
00578 
00579     if(!hWnd)
00580     {
00581         MessageBox(NULL,"Window Creation Error.","Error",MB_OK|MB_ICONERROR);
00582         return FALSE;
00583     }
00584 
00585     DEVMODE dmScreenSettings;
00586     memset(&dmScreenSettings, 0, sizeof(DEVMODE));
00587     dmScreenSettings.dmSize        = sizeof(DEVMODE);
00588     dmScreenSettings.dmPelsWidth    = screen.right;
00589     dmScreenSettings.dmPelsHeight    = screen.bottom;
00590     dmScreenSettings.dmFields    = DM_PELSWIDTH | DM_PELSHEIGHT;
00591     ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
00592 
00593     ShowWindow(hWnd, SW_HIDE);
00594 
00595     GetCurrentDirectory(MAX_PATH, AppDirectory);
00596 
00597     DialogBox(hInstance, "DEVICE", hWnd, (DLGPROC)devicedialogproc);
00598 
00599         Console.Open();
00600 
00601     if(DialogBox(hInstance, "STARTDLG", hWnd, (DLGPROC)StartProc) == IDOK)
00602     {
00603         if (!InitGL(screen.right, screen.bottom))
00604         {
00605             SendMessage(hWnd, WM_CLOSE, 0, 0);
00606         }
00607         else
00608         {
00609             ShowWindow(hWnd, SW_SHOW);
00610             UpdateWindow(hWnd);
00611             SetFocus(hWnd);
00612             wglMakeCurrent(hDC,hRC);
00613             SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00614             ShowCursor(0);
00615         }
00616     }
00617     else
00618     {
00619         delete[] lightmap;
00620         delete[] staticlight;
00621         delete[] texture;
00622         delete[] vertex;
00623         delete[] camera;
00624         delete[] light;
00625         delete[] polygon;
00626         delete[] bsppolygon;
00627         delete root;
00628         delete[] bullet;
00629         PostQuitMessage(0);            
00630     }
00631 
00632     while (1)
00633     {
00634         while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
00635         {
00636             if (GetMessage(&msg, NULL, 0, 0))
00637             {
00638                 TranslateMessage(&msg);
00639                 DispatchMessage(&msg);
00640             }
00641             else
00642             {
00643                 return TRUE;
00644             }
00645         }
00646 
00647         if(!DialogInUse)
00648         {
00649             SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00650             DrawGLScene();
00651             glFlush();
00652             SwapBuffers(hDC);
00653         }
00654 
00655         multiplier = GetTimePassed(lasttime, average, lastmultiplier);
00656         camera[currentCamera].Multiplier = multiplier;
00657         light[currentLight].Multiplier = multiplier;
00658         for (int loop = 0; loop < numBullets; loop++)
00659             bullet[loop].Multiplier = multiplier;
00660 
00661         if (key['C'] && released_key['C'] == 0)
00662         {
00663             if (currentCamera < numCameras)
00664                 currentCamera++;
00665             else
00666                 currentCamera = 0;
00667             released_key['C'] = 1;
00668         }
00669 
00670         if (!key['C'])
00671             released_key['C'] = 0;
00672 
00673         if (key['L'] && released_key['L'] == 0)
00674         {
00675             if (currentLight < numLights)
00676                 currentLight++;
00677             else
00678                 currentLight = 0;
00679             released_key['L'] = 1;
00680         }
00681 
00682         if (!key['L'])
00683             released_key['L'] = 0;
00684 
00685         if (key['P'] && released_key['P'] == 0)
00686         {
00687             if (showportals)
00688                 showportals = 0;
00689             else
00690                 showportals = 1;
00691             released_key['P'] = 1;
00692         }
00693 
00694         if (!key['P'])
00695             released_key['P'] = 0;
00696 
00697         if (key['M'] && released_key['M'] == 0)
00698         {
00699             if (cameraMode == 2)
00700                 cameraMode = 0;
00701             else
00702                 cameraMode = 2;
00703             released_key['M'] = 1;
00704         }
00705 
00706         if (!key['M'])
00707             released_key['M'] = 0;
00708 
00709         if (key['F'])
00710         {
00711             // Loop through all bullets
00712             for (int loop = 0; loop < numBullets; loop++)
00713             {
00714                 // Get current time
00715                 float shotthis = (float)GetTickCount();
00716                 // If last time in NULL then this is the first time fired
00717                 if (shotlast == 0)
00718                     shotlast = ApplicationStartTime;
00719                 // Get the interval between shots
00720                 float shotoffset = shotthis - shotlast;
00721                 // If minimum interval has passed and bullet is inactive
00722                 if (shotoffset > 100 && bullet[loop].active != true)
00723                 {
00724                     // This time becomes last time fired
00725                     shotlast = shotthis;
00726                     // Set a flag to indicate that this is the first time fired
00727                     bullet[loop].flag = true;
00728                     // Set the bullet to active
00729                     bullet[loop].active = true;
00730                     // Set the bullets direction vector
00731                     bullet[loop].VelocityVector = camera[currentCamera].GetZUnit();
00732                     // Set the bullets orientation
00733                     bullet[loop].Orientation = camera[currentCamera].Orientation;
00734                     // Set the bullets position
00735                     bullet[loop].OriginalPosition = camera[currentCamera].Position;
00736                     bullet[loop].PreviousPosition = camera[currentCamera].Position;
00737                     bullet[loop].Position = camera[currentCamera].Position;
00738                     // Increase the number of bullets active counter
00739                     numBulletsActive++;
00740                     // Make the muzzle-flash decal active
00741                     muzzleflashdecal.active = true;
00742                     // Play the gunshot sound
00743                     PlayChannel(channel_gunshot);
00744 
00745                     break;
00746                 }
00747             }
00748         }
00749 
00750         if (key['T'] && released_key['T'] == 0)
00751         {
00752             if (bullettype)
00753                 bullettype = 0;
00754             else
00755                 bullettype = 1;
00756             released_key['T'] = 1;
00757         }
00758 
00759         if (!key['T'])
00760             released_key['T'] = 0;
00761 
00762         if (key['S'] && released_key['S'] == 0)
00763         {
00764             if (bulletspeed)
00765                 bulletspeed = 0;
00766             else
00767                 bulletspeed = 1;
00768             released_key['S'] = 1;
00769         }
00770 
00771         if (!key['S'])
00772             released_key['S'] = 0;
00773 
00774         if (key[49])
00775         {
00776             step = 10.0;
00777         }
00778 
00779         if (key[50])
00780         {
00781             step = 20.0;
00782         }
00783 
00784         if (key[51])
00785         {
00786             step = 30.0;
00787         }
00788 
00789         if (key[52])
00790         {
00791             step = 40.0;
00792         }
00793 
00794         if (key[53])
00795         {
00796             step = 50.0;
00797         }
00798 
00799         if (key[54])
00800         {
00801             step = 60.0;
00802         }
00803 
00804         if (key[55])
00805         {
00806             step = 70.0;
00807         }
00808 
00809         if (key[56])
00810         {
00811             step = 80.0;
00812         }
00813 
00814         if (key[57])
00815         {
00816             step = 90.0;
00817         }
00818 
00819         if (key[VK_NUMPAD6])
00820         {
00821             light[currentLight].Movement_x += step;
00822         }
00823 
00824         if (key[VK_NUMPAD4])
00825         {
00826             light[currentLight].Movement_x -= step;
00827         }
00828 
00829         if (key[VK_NUMPAD2])
00830         {
00831             light[currentLight].Movement_z += step;
00832         }
00833 
00834         if (key[VK_NUMPAD8])
00835         {
00836             light[currentLight].Movement_z -= step;
00837         }
00838 
00839         if (key[VK_NUMPAD7])
00840         {
00841             light[currentLight].Movement_y += step;
00842         }
00843 
00844         if (key[VK_NUMPAD9])
00845         {
00846             light[currentLight].Movement_y -= step;
00847         }
00848 
00849         if (key[VK_NUMPAD5] && released_key[VK_NUMPAD5] == 0)
00850         {
00851             if (light[currentLight].Positional == FALSE)
00852                 light[currentLight].Positional = TRUE;
00853             else
00854                 light[currentLight].Positional = FALSE;
00855             released_key[VK_NUMPAD5] = 1;
00856         }
00857 
00858         if (!key[VK_NUMPAD5])
00859             released_key[VK_NUMPAD5] = 0;
00860 
00861         if (key[VK_RIGHT])
00862         {
00863             camera[currentCamera].Movement_x += step;
00864         }
00865 
00866         if (key[VK_LEFT])
00867         {
00868             camera[currentCamera].Movement_x -= step;
00869         }
00870 
00871         if (key[VK_DOWN])
00872         {
00873             camera[currentCamera].Movement_z += step;
00874         }
00875 
00876         if (key[VK_UP])
00877         {
00878             camera[currentCamera].Movement_z -= step;
00879         }
00880 
00881         if (key[VK_PRIOR])
00882         {
00883             camera[currentCamera].Movement_y += step;
00884         }
00885 
00886         if (key[VK_NEXT])
00887         {
00888             camera[currentCamera].Movement_y -= step;
00889         }
00890 
00891         if (key[VK_SPACE])
00892         {
00893             camera[currentCamera].Reset();
00894         }
00895 
00896         if (key[VK_ESCAPE] || key['Q'])
00897             SendMessage(hWnd,WM_CLOSE,0,0);
00898     }
00899 }

LRESULT CALLBACK WndProc HWND    hWnd,
UINT    message,
WPARAM    wParam,
LPARAM    lParam
 

Definition at line 332 of file main.cpp.

References cameraMode, Console, currentCamera, DeleteBSP(), DeleteBullets(), DeleteSpline(), DrawGLScene(), FALSE, LinkedList< T >::Get(), glFontDestroy(), hDC, hRC, hWnd, key, numportals, numSplines, ps, ReSizeGLScene(), screen, TRUE, and PORTAL::Vertex.

Referenced by WinMain().

00336 {
00337     GLuint    PixelFormat;
00338     int generic_format;
00339     int generic_accelerated;
00340     PIXELFORMATDESCRIPTOR pfd_new;
00341   
00342     static PIXELFORMATDESCRIPTOR pfd=
00343     {
00344            sizeof(PIXELFORMATDESCRIPTOR),
00345         1,
00346         PFD_DRAW_TO_WINDOW |
00347         PFD_SUPPORT_OPENGL |
00348         PFD_DOUBLEBUFFER,
00349         PFD_TYPE_RGBA,
00350         16,
00351         0, 0, 0, 0, 0, 0,
00352         0,
00353         0,
00354         0,
00355         0, 0, 0, 0,
00356         16,
00357         0,
00358         0,
00359         PFD_MAIN_PLANE,
00360         0,
00361         0, 0, 0
00362     };
00363 
00364 
00365     switch (message)
00366     {
00367         case WM_CREATE:
00368             hDC = GetDC(hWnd);
00369 
00370             PixelFormat = ChoosePixelFormat(hDC, &pfd);
00371 /*
00372             DescribePixelFormat(hDC, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd_new);
00373              
00374             generic_format = pfd_new.dwFlags & PFD_GENERIC_FORMAT;
00375             generic_accelerated = pfd_new.dwFlags & PFD_GENERIC_ACCELERATED;
00376 
00377             if (generic_format && ! generic_accelerated)
00378             {
00379                 // software
00380                    MessageBox(NULL, "Software Rendering.", "Info", MB_OK | MB_ICONINFORMATION);
00381             }
00382             else if (generic_format && generic_accelerated)
00383             {
00384                 // hardware - MCD
00385                    MessageBox(NULL, "Hardware Rendering - MCD.", "Info", MB_OK | MB_ICONINFORMATION);
00386             }
00387             else if (! generic_format && ! generic_accelerated)
00388             {
00389                 // hardware - ICD
00390                    MessageBox(NULL, "Hardware Rendering - ICD.", "Info", MB_OK | MB_ICONINFORMATION);
00391             }
00392 //*/
00393              if (!PixelFormat)
00394             {
00395                    MessageBox(NULL,"Can't find a suitable PixelFormat.","Error",MB_OK|MB_ICONERROR);
00396                 PostQuitMessage(0);
00397                 break;
00398             }
00399 
00400             if(!SetPixelFormat(hDC,PixelFormat,&pfd))
00401             {
00402                 MessageBox(NULL,"Can't set the PixelFormat.","Error",MB_OK|MB_ICONERROR);
00403                 PostQuitMessage(0);
00404                 break;
00405             }
00406 
00407             hRC = wglCreateContext(hDC);
00408             if(!hRC)
00409             {
00410                 MessageBox(NULL,"Can't create a GL Rendering Context.","Error",MB_OK|MB_ICONERROR);
00411                 PostQuitMessage(0);
00412                 break;
00413             }
00414 
00415             if(!wglMakeCurrent(hDC, hRC))
00416             {
00417                 MessageBox(NULL,"Can't activate the GL Rendering Context.","Error",MB_OK|MB_ICONERROR);
00418                 PostQuitMessage(0);
00419                 break;
00420             }
00421             break;
00422 
00423         case WM_SYSCOMMAND:
00424         {
00425             switch (wParam)
00426             {
00427                 case SC_SCREENSAVE:
00428                 case SC_MONITORPOWER:
00429                     return 0;
00430             }
00431             break;
00432         }
00433 
00434         if (DialogInUse)
00435         {
00436             case WM_PAINT:
00437                 BeginPaint(hWnd,&ps);
00438                 DrawGLScene();
00439                 glFlush();
00440                 SwapBuffers(hDC);
00441                 EndPaint(hWnd,&ps);
00442             break;
00443         }
00444 
00445         case WM_CLOSE:
00446             delete[] lightmap;
00447             delete[] staticlight;
00448             delete[] texture;
00449             delete[] vertex;
00450             delete[] camera;
00451             delete[] light;
00452             delete[] polygon;
00453 
00454             for (int i = numSplines - 1; i >= 0; i--)
00455                 DeleteSpline(i, SplineList);
00456 
00457             if (BuiltBSP)
00458                 DeleteBSP(root);
00459             delete root;
00460 
00461             for (int i = numportals; i > 0; i--)
00462             {
00463                 portal = PortalList.Get(i);
00464                 delete[] portal->Vertex;
00465             }
00466             
00467             glFontDestroy(&myFont);
00468             
00469             BASS_Stop();             // Stop all samples playing
00470             BASS_Free();             // Free the BASS resources
00471 
00472             DeleteBullets();
00473             
00474             CLog::addLine("--- End of Program ---");
00475             Console.Close();
00476 
00477             ChangeDisplaySettings(NULL, 0);
00478             wglMakeCurrent(hDC,NULL);
00479             wglDeleteContext(hRC);
00480             ReleaseDC(hWnd,hDC);
00481             DestroyWindow(hWnd);
00482         break;
00483 
00484         case WM_DESTROY:
00485             PostQuitMessage(0);
00486         break;
00487 
00488         case WM_KEYDOWN:
00489             key[wParam] = TRUE;
00490         break;
00491 
00492         case WM_KEYUP:
00493             key[wParam] = FALSE;
00494         break;
00495 
00496         case WM_SIZE:
00497             SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00498             ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
00499         break;
00500 
00501         case WM_MOUSEMOVE:
00502             if (cameraMode == 0)
00503             {
00504                 camera[currentCamera].Delta_x = float(HIWORD(lParam) - screen.bottom * 0.5) * 10;
00505                 camera[currentCamera].Delta_y = float(LOWORD(lParam) - screen.right * 0.5) * 10;
00506             }
00507         break;
00508 
00509         case WM_LBUTTONDOWN:
00510             camera[currentCamera].Delta_z = -120.0;
00511         break;
00512 
00513         case WM_RBUTTONDOWN:
00514             camera[currentCamera].Delta_z = 120.0;
00515         break;
00516 
00517         case WM_LBUTTONUP:
00518             if (wParam != MK_RBUTTON)
00519                 camera[currentCamera].Delta_z = 0.0;
00520         break;
00521 
00522         case WM_RBUTTONUP:
00523             if (wParam != MK_LBUTTON)
00524                 camera[currentCamera].Delta_z = 0.0;
00525         break;
00526 
00527         default:
00528             return (DefWindowProc(hWnd, message, wParam, lParam));
00529     }
00530     return (0);
00531 }


Variable Documentation

char AppDirectory[MAX_PATH]
 

Definition at line 50 of file main.cpp.

Referenced by StartProc(), and WinMain().

float ApplicationStartTime
 

Definition at line 51 of file main.cpp.

Referenced by bsplinepoint(), InitGL(), and WinMain().

const int average = 10
 

Definition at line 70 of file main.cpp.

Referenced by GetTimePassed(), and WinMain().

POLYGON* bsppolygon = new POLYGON[numPolygons]
 

Definition at line 89 of file main.cpp.

bool BuiltBSP = false
 

Definition at line 146 of file main.cpp.

Referenced by InitGL().

BULLET* bullet = new BULLET[numBullets]
 

Definition at line 139 of file main.cpp.

int bulletspeed = 0
 

Definition at line 119 of file main.cpp.

Referenced by WinMain().

int bullettype = 1
 

Definition at line 120 of file main.cpp.

Referenced by WinMain().

CAMERA* camera = new CAMERA[numCameras + 1]
 

Definition at line 95 of file main.cpp.

int cameraMode = 2
 

Definition at line 165 of file main.cpp.

Referenced by InitGL(), WinMain(), and WndProc().

LinkedList<SOUND_CHANNEL> ChannelList
 

Definition at line 134 of file main.cpp.

ConsoleWindow Console
 

Definition at line 41 of file main.cpp.

Referenced by WinMain(), and WndProc().

int currentCamera = 0
 

Definition at line 63 of file main.cpp.

Referenced by DrawGLScene(), UpdateListener(), WinMain(), and WndProc().

int currentleaf = 0
 

Definition at line 144 of file main.cpp.

Referenced by DrawGLScene().

int currentLight = 0
 

Definition at line 76 of file main.cpp.

Referenced by DrawHalo(), and WinMain().

int currentSpline = 0
 

Definition at line 166 of file main.cpp.

Referenced by LoadSplines().

int device
 

Definition at line 129 of file main.cpp.

Referenced by devicedialogproc(), and InitializeBASS().

int DialogInUse = 0
 

Definition at line 109 of file main.cpp.

Referenced by ColorDialogHook(), and WinMain().

float epsilon = 0.05
 

Definition at line 56 of file main.cpp.

int fps
 

Definition at line 72 of file main.cpp.

Referenced by DrawMyText(), and GetTimePassed().

PLANE frustum[6]
 

Definition at line 80 of file main.cpp.

HINSTANCE g_hInst
 

Definition at line 47 of file main.cpp.

Referenced by WinMain().

int GL_LIGHT[8] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7}
 

Definition at line 75 of file main.cpp.

HDC hDC [static]
 

Definition at line 45 of file main.cpp.

Referenced by WinMain(), and WndProc().

HGLRC hRC [static]
 

Definition at line 44 of file main.cpp.

Referenced by WinMain(), and WndProc().

HWND hWnd
 

Definition at line 46 of file main.cpp.

Referenced by GetLightColor(), WinMain(), and WndProc().

HWND hWndStartDlg
 

Definition at line 108 of file main.cpp.

Referenced by StartProc().

DECAL impactflashdecal
 

Definition at line 101 of file main.cpp.

bool key[256]
 

Definition at line 59 of file main.cpp.

Referenced by WinMain(), and WndProc().

CAMERA LastCam
 

Definition at line 96 of file main.cpp.

float lastmultiplier[average]
 

Definition at line 71 of file main.cpp.

Referenced by GetTimePassed(), and WinMain().

float lasttime
 

Definition at line 68 of file main.cpp.

Referenced by GetTimePassed(), and WinMain().

LinkedList<ListNode> LeafList
 

Definition at line 173 of file main.cpp.

LIGHT* light = new LIGHT[numLights + 1]
 

Definition at line 104 of file main.cpp.

float lightColor[3] = {1.0, 1.0, 1.0}
 

Definition at line 105 of file main.cpp.

Referenced by GetLightColor().

Lightmap* lightmap = new Lightmap[numPolygons]
 

Definition at line 160 of file main.cpp.

Referenced by CreateLightmaps().

ListNode* listnode
 

Definition at line 175 of file main.cpp.

int lookAtPath = 0
 

Definition at line 167 of file main.cpp.

Referenced by LoadSplines().

BOOL lowqual
 

Definition at line 130 of file main.cpp.

Referenced by devicedialogproc(), and InitializeBASS().

float Max_X
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

float Max_Y
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

float Max_Z
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

int maxDecals = 100
 

Definition at line 99 of file main.cpp.

float Min_X
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

float Min_Y
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

float Min_Z
 

Definition at line 116 of file main.cpp.

Referenced by CreateLargePortal(), and InitGL().

float multiplier
 

Definition at line 69 of file main.cpp.

Referenced by GetTimePassed(), and WinMain().

DECAL muzzleflashdecal
 

Definition at line 100 of file main.cpp.

GLFONT myFont
 

Definition at line 113 of file main.cpp.

int numBullets = 50
 

Definition at line 138 of file main.cpp.

Referenced by WinMain().

int numBulletsActive = 0
 

Definition at line 140 of file main.cpp.

Referenced by WinMain().

int numCameras = 4
 

Definition at line 64 of file main.cpp.

Referenced by SetGLCamera(), and WinMain().

int numChannels = 0
 

Definition at line 132 of file main.cpp.

Referenced by CreateChannel().

int numcurrentportals = 0
 

Definition at line 125 of file main.cpp.

int numleaves = 0
 

Definition at line 143 of file main.cpp.

Referenced by CountVisibleLeaves().

int numleavesvisible = 0
 

Definition at line 121 of file main.cpp.

Referenced by DrawGLScene().

int numLightmaps = 0
 

Definition at line 159 of file main.cpp.

Referenced by CreateLightmaps().

int numLights = 0
 

Definition at line 77 of file main.cpp.

Referenced by DrawGLScene(), SetGLLighting(), and WinMain().

int numlistleaves = 0
 

Definition at line 123 of file main.cpp.

Referenced by MakeNodeLists().

int numlistpartitions = 0
 

Definition at line 124 of file main.cpp.

Referenced by MakeNodeLists().

int numpartitions = 0
 

Definition at line 145 of file main.cpp.

Referenced by MakePortalList().

int numPolygons = 58
 

Definition at line 87 of file main.cpp.

Referenced by InitGL(), and SetGLWorld().

int numportals = 0
 

Definition at line 151 of file main.cpp.

Referenced by AddPortalsToLeaves(), MakePortalList(), and WndProc().

int numSamples = 0
 

Definition at line 131 of file main.cpp.

Referenced by LoadSample().

int numSplines = 0
 

Definition at line 164 of file main.cpp.

Referenced by LoadSplines(), SetSplines(), and WndProc().

int numStaticLights = 9
 

Definition at line 155 of file main.cpp.

Referenced by CreateLightmaps().

int numVertices = 37
 

Definition at line 83 of file main.cpp.

Referenced by POLYGON::POLYGON(), and VERTEX::VERTEX().

LinkedList<ListNode> PartitionList
 

Definition at line 174 of file main.cpp.

float pi = 3.141592
 

Definition at line 54 of file main.cpp.

Referenced by OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::MoveX(), and OBJECT::MoveY().

ParticleManager PManager
 

Definition at line 178 of file main.cpp.

POLYGON* polygon = new POLYGON[numPolygons]
 

Definition at line 88 of file main.cpp.

Referenced by CheckForCollision(), ClipPortalToBackLeaf(), ClipPortalToFrontLeaf(), InvertPortals(), and SetGLWorld().

PORTAL* portal
 

Definition at line 152 of file main.cpp.

LinkedList<PORTAL> PortalList
 

Definition at line 150 of file main.cpp.

PAINTSTRUCT ps
 

Definition at line 49 of file main.cpp.

Referenced by WndProc().

float radian = pi / 180
 

Definition at line 55 of file main.cpp.

Referenced by OBJECT::Rotate().

bool released_key[256]
 

Definition at line 60 of file main.cpp.

Referenced by WinMain().

BSP_node* root = new BSP_node
 

Definition at line 147 of file main.cpp.

LinkedList<SOUND_SAMPLE> SampleList
 

Definition at line 133 of file main.cpp.

RECT screen
 

Definition at line 48 of file main.cpp.

Referenced by WinMain(), and WndProc().

float shotlast
 

Definition at line 137 of file main.cpp.

Referenced by WinMain().

int showportals = 0
 

Definition at line 122 of file main.cpp.

Referenced by WinMain().

SPLINE* spline
 

Definition at line 169 of file main.cpp.

char SplineFileName[MAX_PATH]
 

Definition at line 168 of file main.cpp.

Referenced by StartProc().

LinkedList<SPLINE> SplineList
 

Definition at line 170 of file main.cpp.

Referenced by AddSpline(), DeleteSpline(), DrawSplines(), LoadSplines(), and SetSplines().

StaticLight* staticlight = new StaticLight[numStaticLights]
 

Definition at line 156 of file main.cpp.

float step = 30.0
 

Definition at line 65 of file main.cpp.

Referenced by WinMain().

char szText[BUFFER_SIZE]
 

Definition at line 110 of file main.cpp.

Referenced by StartProc().

float test = 0.0
 

Definition at line 126 of file main.cpp.

TEXTURE* texture = new TEXTURE[10]
 

Definition at line 92 of file main.cpp.

VERTEX* vertex = new VERTEX[numVertices]
 

Definition at line 84 of file main.cpp.

int visible = 0
 

Definition at line 163 of file main.cpp.


Generated on Fri Dec 23 05:19:58 2005 for Particles by doxygen1.2.15