#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 "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 "tga.h"#include "lightmap.h"#include "winfuncs.h"#include "tll.h"#include "console.h"#include "log.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 = 20 |
| 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 |
| VERTEX * | vertex = new VERTEX[numVertices] |
| int | numPolygons = 58 |
| POLYGON * | polygon = new POLYGON[numPolygons] |
| POLYGON * | bsppolygon = new POLYGON[numPolygons] |
| TEXTURE * | texture = new TEXTURE[4] |
| CAMERA * | camera = new CAMERA[numCameras + 1] |
| CAMERA | LastCam |
| LIGHT * | light = 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 | showportals = 1 |
| int | numlistleaves = 0 |
| int | numlistpartitions = 0 |
| int | numcurrentportals = 0 |
| int | numleaves = 0 |
| int | currentleaf = 0 |
| int | numpartitions = 0 |
| bool | BuiltBSP = false |
| BSP_node * | root = new BSP_node |
| LinkedList< PORTAL > | PortalList |
| int | numportals = 0 |
| PORTAL * | portal |
| int | numStaticLights = 9 |
| StaticLight * | staticlight = new StaticLight[numStaticLights] |
| int | numLightmaps = 0 |
| Lightmap * | lightmap = new Lightmap[numPolygons] |
| int | visible = 0 |
| int | numSplines = 0 |
| int | cameraMode = 2 |
| int | currentSpline = 0 |
| int | lookAtPath = 0 |
| char | SplineFileName [MAX_PATH] |
| SPLINE * | spline |
| LinkedList< SPLINE > | SplineList |
| LinkedList< ListNode > | LeafList |
| LinkedList< ListNode > | PartitionList |
| ListNode * | listnode |
|
|
Definition at line 233 of file main.cpp. References LIGHT::Apply(), CheckForCollision(), currentCamera, currentleaf, DrawMyText(), DrawSplines(), DrawWorld(), CollisionPacket::eRadius, FindCurrentLeaf(), numLights, OBJECT::Position, CollisionPacket::sourcePoint, CollisionPacket::velocity, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by WinMain(), and WndProc().
00234 {
00235 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00236
00237 LastCam = camera[currentCamera];
00238 camera[currentCamera].Update();
00239
00240 CollisionPacket cp;
00241 cp.eRadius.x = 1.0;
00242 cp.eRadius.y = 1.0;
00243 cp.eRadius.z = 1.0;
00244 cp.sourcePoint.x = LastCam.Position.x;
00245 cp.sourcePoint.y = LastCam.Position.y;
00246 cp.sourcePoint.z = LastCam.Position.z;
00247 cp.velocity.x = camera[currentCamera].Position.x - LastCam.Position.x;
00248 cp.velocity.y = camera[currentCamera].Position.y - LastCam.Position.y;
00249 cp.velocity.z = camera[currentCamera].Position.z - LastCam.Position.z;
00250
00251 CheckForCollision(polygon, &camera[currentCamera].Position, &cp);
00252
00253 camera[currentCamera].Apply();
00254
00255 for(int loop = 0; loop <= numLights; loop++)
00256 light[loop].Apply();
00257
00258 currentleaf = FindCurrentLeaf(camera[currentCamera].Position, root);
00259
00260 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
00261 DrawWorld(root);
00262 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00263
00264 /*
00265 glPushMatrix();
00266 glDisable(GL_TEXTURE_2D);
00267 glDisable(GL_LIGHTING);
00268
00269 // Draw bounding box of data set
00270 glColor3f(1.0, 0.0, 0.0);
00271 glBegin(GL_LINES);
00272 glVertex3f(Min_X, Min_Y, Min_Z);
00273 glVertex3f(Min_X, Max_Y, Min_Z);
00274
00275 glVertex3f(Min_X, Min_Y, Min_Z);
00276 glVertex3f(Max_X, Min_Y, Min_Z);
00277
00278 glVertex3f(Min_X, Max_Y, Min_Z);
00279 glVertex3f(Max_X, Max_Y, Min_Z);
00280
00281 glVertex3f(Max_X, Max_Y, Min_Z);
00282 glVertex3f(Max_X, Min_Y, Min_Z);
00283
00284 glVertex3f(Min_X, Min_Y, Min_Z);
00285 glVertex3f(Min_X, Min_Y, Max_Z);
00286
00287 glVertex3f(Max_X, Min_Y, Min_Z);
00288 glVertex3f(Max_X, Min_Y, Max_Z);
00289
00290 glVertex3f(Min_X, Max_Y, Min_Z);
00291 glVertex3f(Min_X, Max_Y, Max_Z);
00292
00293 glVertex3f(Max_X, Max_Y, Min_Z);
00294 glVertex3f(Max_X, Max_Y, Max_Z);
00295
00296 glVertex3f(Min_X, Min_Y, Max_Z);
00297 glVertex3f(Min_X, Max_Y, Max_Z);
00298
00299 glVertex3f(Min_X, Min_Y, Max_Z);
00300 glVertex3f(Max_X, Min_Y, Max_Z);
00301
00302 glVertex3f(Min_X, Max_Y, Max_Z);
00303 glVertex3f(Max_X, Max_Y, Max_Z);
00304
00305 glVertex3f(Max_X, Max_Y, Max_Z);
00306 glVertex3f(Max_X, Min_Y, Max_Z);
00307 glEnd();
00308
00309 glEnable(GL_TEXTURE_2D);
00310 glEnable(GL_LIGHTING);
00311 glPopMatrix();
00312 //*/
00313
00314 DrawSplines(SplineList); // Required to calculate the camera path
00315 DrawMyText();
00316 }
|
|
||||||||||||
|
Definition at line 148 of file main.cpp. References AddPortalsToLeaves(), ApplicationStartTime, BuildBSP(), BuiltBSP, cameraMode, CreateBSPLightmaps(), FindTruePortals(), glFontCreate(), 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, numPolygons, BSP_node::numpolys, SetGLCamera(), SetGLLighting(), SetGLMaterial(), SetGLProperties(), SetGLTexture(), SetGLWorld(), SetSplines(), SetStaticLights(), POLYGON::Vertex, BSP_node::visible, VERTEX::x, VERTEX::y, and VERTEX::z. Referenced by WinMain().
00149 {
00150 CLog::addLine("--- Program Start ---");
00151
00152 int ReturnValue;
00153 ApplicationStartTime = (float)GetTickCount();
00154
00155 SetGLProperties();
00156 SetGLMaterial();
00157 SetGLLighting(light);
00158 SetGLCamera(camera);
00159 cameraMode = 2;
00160 SetSplines(SplineList);
00161
00162 if (!SetGLTexture(texture))
00163 ReturnValue = 0;
00164 else
00165 ReturnValue = 1;
00166
00167 // Create the font texture
00168 glFontCreate(&myFont, "roman.glf", 600);
00169
00170 SetGLWorld(polygon, texture, vertex);
00171
00172 // Find the bounding box of the data set
00173 Min_X = polygon[0].Vertex[0].x;
00174 Min_Y = polygon[0].Vertex[0].y;
00175 Min_Z = polygon[0].Vertex[0].z;
00176 Max_X = polygon[0].Vertex[0].x;
00177 Max_Y = polygon[0].Vertex[0].y;
00178 Max_Z = polygon[0].Vertex[0].z;
00179 for (int loop = 0; loop < numPolygons; loop++)
00180 {
00181 for (int i = 0; i < 3; i++)
00182 {
00183 if (polygon[loop].Vertex[i].x < Min_X )
00184 Min_X = polygon[loop].Vertex[i].x;
00185 if (polygon[loop].Vertex[i].y < Min_Y )
00186 Min_Y = polygon[loop].Vertex[i].y;
00187 if (polygon[loop].Vertex[i].z < Min_Z )
00188 Min_Z = polygon[loop].Vertex[i].z;
00189 if (polygon[loop].Vertex[i].x > Max_X )
00190 Max_X = polygon[loop].Vertex[i].x;
00191 if (polygon[loop].Vertex[i].y > Max_Y )
00192 Max_Y = polygon[loop].Vertex[i].y;
00193 if (polygon[loop].Vertex[i].z > Max_Z )
00194 Max_Z = polygon[loop].Vertex[i].z;
00195 }
00196 }
00197
00198 // BSP initialization
00199 for (int i = 0; i < numPolygons; i++)
00200 bsppolygon[i] = polygon[i];
00201
00202 root->nodeid = 0;
00203 root->leaf = 0;
00204 root->visible = 0;
00205 root->numpolys = numPolygons;
00206 root->nodepolylist = bsppolygon;
00207 root->nodelightmaplist = lightmap;
00208
00209 BuildBSP(root);
00210 BuiltBSP = true;
00211
00212 MakeNodeLists(root); // Create lists of the partition and leaf nodes
00213 MakePortalList(); // Create the large portals and add them to a portal list
00214
00215 AddPortalsToLeaves(root); // Add the portals to the bsp tree
00216 FindTruePortals(root); // Remove the excess portals
00217
00218 // initialize static lights
00219 SetStaticLights(staticlight);
00220
00221 // Create the lightmaps
00222 CreateBSPLightmaps(root);
00223 LoadBSPLightmaps(root);
00224
00225 return ReturnValue;
00226 }
|
|
||||||||||||
|
Definition at line 228 of file main.cpp. References SetGLView(). Referenced by WndProc().
00229 {
00230 SetGLView(Width, Height);
00231 }
|
|
||||||||||||||||||||
|
Definition at line 489 of file main.cpp. References AppDirectory, average, cameraMode, Console, currentCamera, currentLight, DialogInUse, DrawGLScene(), FALSE, g_hInst, GetTimePassed(), hDC, hRC, hWnd, InitGL(), key, lastmultiplier, lasttime, multiplier, numCameras, numLights, released_key, screen, showportals, step, TRUE, and WndProc().
00493 {
00494 MSG msg;
00495 g_hInst = hInstance;
00496 GetWindowRect(GetDesktopWindow(), &screen);
00497
00498 WNDCLASSEX wc;
00499 wc.cbSize = sizeof(WNDCLASSEX);
00500 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_SAVEBITS;
00501 wc.lpfnWndProc = (WNDPROC) WndProc;
00502 wc.cbClsExtra = 0;
00503 wc.cbWndExtra = 0;
00504 wc.hInstance = hInstance;
00505 wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
00506 wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
00507 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
00508 wc.hbrBackground = NULL;
00509 wc.lpszMenuName = NULL;
00510 wc.lpszClassName = "OpenGL WinClass";
00511
00512
00513 if(!RegisterClassEx(&wc))
00514 {
00515 MessageBox(NULL,"Failed To Register The Window Class.","Error",MB_OK|MB_ICONERROR);
00516 return FALSE;
00517 }
00518
00519 hWnd = CreateWindowEx(
00520 WS_EX_LEFT,
00521 "OpenGL WinClass",
00522 "OpenGL & Win32 Tutorial No.13",
00523 WS_MAXIMIZE |
00524 WS_CLIPCHILDREN |
00525 WS_CLIPSIBLINGS |
00526 WS_POPUPWINDOW |
00527 WS_VISIBLE,
00528 0, 0,
00529 screen.right, screen.bottom,
00530 NULL,
00531 NULL,
00532 hInstance,
00533 NULL);
00534
00535 if(!hWnd)
00536 {
00537 MessageBox(NULL,"Window Creation Error.","Error",MB_OK|MB_ICONERROR);
00538 return FALSE;
00539 }
00540
00541 DEVMODE dmScreenSettings;
00542 memset(&dmScreenSettings, 0, sizeof(DEVMODE));
00543 dmScreenSettings.dmSize = sizeof(DEVMODE);
00544 dmScreenSettings.dmPelsWidth = screen.right;
00545 dmScreenSettings.dmPelsHeight = screen.bottom;
00546 dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
00547 ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
00548
00549 ShowWindow(hWnd, SW_HIDE);
00550
00551 GetCurrentDirectory(MAX_PATH, AppDirectory);
00552
00553 Console.Open();
00554
00555 if(DialogBox(hInstance, "STARTDLG", hWnd, (DLGPROC)StartProc) == IDOK)
00556 {
00557 if (!InitGL(screen.right, screen.bottom))
00558 {
00559 Console.Close();
00560 SendMessage(hWnd,WM_CLOSE,0,0);
00561 }
00562 else
00563 {
00564 ShowWindow(hWnd, SW_SHOW);
00565 UpdateWindow(hWnd);
00566 SetFocus(hWnd);
00567 wglMakeCurrent(hDC,hRC);
00568 SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00569 ShowCursor(0);
00570 }
00571 }
00572 else
00573 {
00574 delete[] lightmap;
00575 delete[] staticlight;
00576 delete[] texture;
00577 delete[] vertex;
00578 delete[] camera;
00579 delete[] light;
00580 delete[] polygon;
00581 delete[] bsppolygon;
00582 delete root;
00583 PostQuitMessage(0);
00584 }
00585
00586 while (1)
00587 {
00588 while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
00589 {
00590 if (GetMessage(&msg, NULL, 0, 0))
00591 {
00592 TranslateMessage(&msg);
00593 DispatchMessage(&msg);
00594 }
00595 else
00596 {
00597 return TRUE;
00598 }
00599 }
00600
00601 if(!DialogInUse)
00602 {
00603 SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00604 DrawGLScene();
00605 glFlush();
00606 SwapBuffers(hDC);
00607 }
00608
00609 multiplier = GetTimePassed(lasttime, average, lastmultiplier);
00610 camera[currentCamera].Multiplier = multiplier;
00611 light[currentLight].Multiplier = multiplier;
00612
00613 if (key['C'] && released_key['C'] == 0)
00614 {
00615 if (currentCamera < numCameras)
00616 currentCamera++;
00617 else
00618 currentCamera = 0;
00619 released_key['C'] = 1;
00620 }
00621
00622 if (!key['C'])
00623 released_key['C'] = 0;
00624
00625 if (key['L'] && released_key['L'] == 0)
00626 {
00627 if (currentLight < numLights)
00628 currentLight++;
00629 else
00630 currentLight = 0;
00631 released_key['L'] = 1;
00632 }
00633
00634 if (!key['L'])
00635 released_key['L'] = 0;
00636 /*
00637 if (key['I'] && released_key['I'] == 0)
00638 {
00639 DialogInUse = 1;
00640 lightColor[0] = light[currentLight].Ambient[0];
00641 lightColor[1] = light[currentLight].Ambient[1];
00642 lightColor[2] = light[currentLight].Ambient[2];
00643 ShowCursor(1);
00644 GetLightColor();
00645 key['I'] = 0;
00646 ShowCursor(0);
00647 SetCursorPos(screen.right * 0.5, screen.bottom * 0.5);
00648 light[currentLight].Ambient[0] = lightColor[0];
00649 light[currentLight].Ambient[1] = lightColor[1];
00650 light[currentLight].Ambient[2] = lightColor[2];
00651 light[currentLight].Update();
00652 DialogInUse = 0;
00653 }
00654
00655 if (!key['I'])
00656 released_key['I'] = 0;
00657
00658 if (key['O'] && released_key['O'] == 0)
00659 {
00660 DialogInUse = 2;
00661 lightColor[0] = light[currentLight].Diffuse[0];
00662 lightColor[1] = light[currentLight].Diffuse[1];
00663 lightColor[2] = light[currentLight].Diffuse[2];
00664 ShowCursor(1);
00665 GetLightColor();
00666 key['O'] = 0;
00667 ShowCursor(0);
00668 SetCursorPos(screen.right * 0.5, screen.bottom * 0.5);
00669 light[currentLight].Diffuse[0] = lightColor[0];
00670 light[currentLight].Diffuse[1] = lightColor[1];
00671 light[currentLight].Diffuse[2] = lightColor[2];
00672 light[currentLight].Update();
00673 DialogInUse = 0;
00674 }
00675
00676 if (!key['O'])
00677 released_key['O'] = 0;
00678
00679 if (key['P'] && released_key['P'] == 0)
00680 {
00681 DialogInUse = 3;
00682 lightColor[0] = light[currentLight].Specular[0];
00683 lightColor[1] = light[currentLight].Specular[1];
00684 lightColor[2] = light[currentLight].Specular[2];
00685 ShowCursor(1);
00686 GetLightColor();
00687 key['P'] = 0;
00688 ShowCursor(0);
00689 SetCursorPos(screen.right * 0.5, screen.bottom * 0.5);
00690 light[currentLight].Specular[0] = lightColor[0];
00691 light[currentLight].Specular[1] = lightColor[1];
00692 light[currentLight].Specular[2] = lightColor[2];
00693 light[currentLight].Update();
00694 DialogInUse = 0;
00695 }
00696
00697 if (!key['P'])
00698 released_key['P'] = 0;
00699 */
00700 if (key['P'] && released_key['P'] == 0)
00701 {
00702 if (showportals)
00703 showportals = 0;
00704 else
00705 showportals = 1;
00706 released_key['P'] = 1;
00707 }
00708
00709 if (!key['P'])
00710 released_key['P'] = 0;
00711 /*
00712 if (key['H'] && released_key['H'] == 0)
00713 {
00714 if (visible)
00715 visible = 0;
00716 else
00717 visible = 1;
00718 released_key['H'] = 1;
00719 }
00720
00721 if (!key['H'])
00722 released_key['H'] = 0;
00723
00724 if (key['S'] && released_key['S'] == 0)
00725 {
00726 if (currentSpline < numSplines - 1)
00727 currentSpline++;
00728 else
00729 currentSpline = 0;
00730 released_key['S'] = 1;
00731 }
00732
00733 if (!key['S'])
00734 released_key['S'] = 0;
00735
00736 if (key['T'] && released_key['T'] == 0)
00737 {
00738 if (lookAtPath < numSplines - 1)
00739 lookAtPath++;
00740 else
00741 lookAtPath = 0;
00742 released_key['T'] = 1;
00743 }
00744
00745 if (!key['T'])
00746 released_key['T'] = 0;
00747 //*/
00748 if (key['M'] && released_key['M'] == 0)
00749 {
00750 /*
00751 if (cameraMode < 2)
00752 cameraMode++;
00753 else
00754 cameraMode = 0;
00755 */
00756 if (cameraMode == 2)
00757 cameraMode = 0;
00758 else
00759 cameraMode = 2;
00760 released_key['M'] = 1;
00761 }
00762
00763 if (!key['M'])
00764 released_key['M'] = 0;
00765
00766 if (key[49])
00767 {
00768 step = 10.0;
00769 }
00770
00771 if (key[50])
00772 {
00773 step = 20.0;
00774 }
00775
00776 if (key[51])
00777 {
00778 step = 30.0;
00779 }
00780
00781 if (key[52])
00782 {
00783 step = 40.0;
00784 }
00785
00786 if (key[53])
00787 {
00788 step = 50.0;
00789 }
00790
00791 if (key[54])
00792 {
00793 step = 60.0;
00794 }
00795
00796 if (key[55])
00797 {
00798 step = 70.0;
00799 }
00800
00801 if (key[56])
00802 {
00803 step = 80.0;
00804 }
00805
00806 if (key[57])
00807 {
00808 step = 90.0;
00809 }
00810
00811 if (key[VK_NUMPAD6])
00812 {
00813 light[currentLight].Movement_x += step;
00814 }
00815
00816 if (key[VK_NUMPAD4])
00817 {
00818 light[currentLight].Movement_x -= step;
00819 }
00820
00821 if (key[VK_NUMPAD2])
00822 {
00823 light[currentLight].Movement_z += step;
00824 }
00825
00826 if (key[VK_NUMPAD8])
00827 {
00828 light[currentLight].Movement_z -= step;
00829 }
00830
00831 if (key[VK_NUMPAD7])
00832 {
00833 light[currentLight].Movement_y += step;
00834 }
00835
00836 if (key[VK_NUMPAD9])
00837 {
00838 light[currentLight].Movement_y -= step;
00839 }
00840
00841 if (key[VK_NUMPAD5] && released_key[VK_NUMPAD5] == 0)
00842 {
00843 if (light[currentLight].Positional == FALSE)
00844 light[currentLight].Positional = TRUE;
00845 else
00846 light[currentLight].Positional = FALSE;
00847 released_key[VK_NUMPAD5] = 1;
00848 }
00849
00850 if (!key[VK_NUMPAD5])
00851 released_key[VK_NUMPAD5] = 0;
00852
00853 if (key[VK_RIGHT])
00854 {
00855 camera[currentCamera].Movement_x += step;
00856 }
00857
00858 if (key[VK_LEFT])
00859 {
00860 camera[currentCamera].Movement_x -= step;
00861 }
00862
00863 if (key[VK_DOWN])
00864 {
00865 camera[currentCamera].Movement_z += step;
00866 }
00867
00868 if (key[VK_UP])
00869 {
00870 camera[currentCamera].Movement_z -= step;
00871 }
00872
00873 if (key[VK_PRIOR])
00874 {
00875 camera[currentCamera].Movement_y += step;
00876 }
00877
00878 if (key[VK_NEXT])
00879 {
00880 camera[currentCamera].Movement_y -= step;
00881 }
00882
00883 if (key[VK_SPACE])
00884 {
00885 camera[currentCamera].Reset();
00886 }
00887
00888 if (key[VK_ESCAPE] || key['Q'])
00889 SendMessage(hWnd,WM_CLOSE,0,0);
00890 }
00891 }
|
|
||||||||||||||||||||
|
Definition at line 318 of file main.cpp. References cameraMode, Console, currentCamera, DeleteBSP(), DeleteSpline(), DrawGLScene(), FALSE, LinkedList< T >::Get(), glFontDestroy(), hDC, hRC, hWnd, key, numportals, numSplines, ps, ReSizeGLScene(), screen, TRUE, and PORTAL::Vertex. Referenced by WinMain().
00322 {
00323 GLuint PixelFormat;
00324 static PIXELFORMATDESCRIPTOR pfd=
00325 {
00326 sizeof(PIXELFORMATDESCRIPTOR),
00327 1,
00328 PFD_DRAW_TO_WINDOW |
00329 PFD_SUPPORT_OPENGL |
00330 PFD_DOUBLEBUFFER,
00331 PFD_TYPE_RGBA,
00332 16,
00333 0, 0, 0, 0, 0, 0,
00334 0,
00335 0,
00336 0,
00337 0, 0, 0, 0,
00338 16,
00339 0,
00340 0,
00341 PFD_MAIN_PLANE,
00342 0,
00343 0, 0, 0
00344 };
00345
00346
00347 switch (message)
00348 {
00349 case WM_CREATE:
00350 hDC = GetDC(hWnd);
00351
00352 PixelFormat = ChoosePixelFormat(hDC, &pfd);
00353
00354 if (!PixelFormat)
00355 {
00356 MessageBox(NULL,"Can't find a suitable PixelFormat.","Error",MB_OK|MB_ICONERROR);
00357 PostQuitMessage(0);
00358 break;
00359 }
00360
00361 if(!SetPixelFormat(hDC,PixelFormat,&pfd))
00362 {
00363 MessageBox(NULL,"Can't set the PixelFormat.","Error",MB_OK|MB_ICONERROR);
00364 PostQuitMessage(0);
00365 break;
00366 }
00367
00368 hRC = wglCreateContext(hDC);
00369 if(!hRC)
00370 {
00371 MessageBox(NULL,"Can't create a GL Rendering Context.","Error",MB_OK|MB_ICONERROR);
00372 PostQuitMessage(0);
00373 break;
00374 }
00375
00376 if(!wglMakeCurrent(hDC, hRC))
00377 {
00378 MessageBox(NULL,"Can't activate the GL Rendering Context.","Error",MB_OK|MB_ICONERROR);
00379 PostQuitMessage(0);
00380 break;
00381 }
00382 break;
00383
00384 case WM_SYSCOMMAND:
00385 {
00386 switch (wParam)
00387 {
00388 case SC_SCREENSAVE:
00389 case SC_MONITORPOWER:
00390 return 0;
00391 }
00392 break;
00393 }
00394
00395 if (DialogInUse)
00396 {
00397 case WM_PAINT:
00398 BeginPaint(hWnd,&ps);
00399 DrawGLScene();
00400 glFlush();
00401 SwapBuffers(hDC);
00402 EndPaint(hWnd,&ps);
00403 break;
00404 }
00405
00406 case WM_CLOSE:
00407 delete[] lightmap;
00408 delete[] staticlight;
00409 delete[] texture;
00410 delete[] vertex;
00411 delete[] camera;
00412 delete[] light;
00413 delete[] polygon;
00414
00415 for (int i = numSplines - 1; i >= 0; i--)
00416 DeleteSpline(i, SplineList);
00417
00418 if (BuiltBSP)
00419 DeleteBSP(root);
00420 delete root;
00421
00422 for (int i = numportals; i > 0; i--)
00423 {
00424 portal = PortalList.Get(i);
00425 delete[] portal->Vertex;
00426 }
00427
00428 glFontDestroy(&myFont);
00429
00430 CLog::addLine("--- End of Program ---");
00431 Console.Close();
00432
00433 ChangeDisplaySettings(NULL, 0);
00434 wglMakeCurrent(hDC,NULL);
00435 wglDeleteContext(hRC);
00436 ReleaseDC(hWnd,hDC);
00437 DestroyWindow(hWnd);
00438 break;
00439
00440 case WM_DESTROY:
00441 PostQuitMessage(0);
00442 break;
00443
00444 case WM_KEYDOWN:
00445 key[wParam] = TRUE;
00446 break;
00447
00448 case WM_KEYUP:
00449 key[wParam] = FALSE;
00450 break;
00451
00452 case WM_SIZE:
00453 SetCursorPos((int)(screen.right * 0.5), (int)(screen.bottom * 0.5));
00454 ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
00455 break;
00456
00457 case WM_MOUSEMOVE:
00458 if (cameraMode == 0)
00459 {
00460 camera[currentCamera].Delta_x = float(HIWORD(lParam) - screen.bottom * 0.5) * 10;
00461 camera[currentCamera].Delta_y = float(LOWORD(lParam) - screen.right * 0.5) * 10;
00462 }
00463 break;
00464
00465 case WM_LBUTTONDOWN:
00466 camera[currentCamera].Delta_z = -120.0;
00467 break;
00468
00469 case WM_RBUTTONDOWN:
00470 camera[currentCamera].Delta_z = 120.0;
00471 break;
00472
00473 case WM_LBUTTONUP:
00474 if (wParam != MK_RBUTTON)
00475 camera[currentCamera].Delta_z = 0.0;
00476 break;
00477
00478 case WM_RBUTTONUP:
00479 if (wParam != MK_LBUTTON)
00480 camera[currentCamera].Delta_z = 0.0;
00481 break;
00482
00483 default:
00484 return (DefWindowProc(hWnd, message, wParam, lParam));
00485 }
00486 return (0);
00487 }
|
|
|
|
|
|
Definition at line 45 of file main.cpp. Referenced by bsplinepoint(), and InitGL(). |
|
|
Definition at line 64 of file main.cpp. Referenced by GetTimePassed(), and WinMain(). |
|
|
|
|
|
Definition at line 117 of file main.cpp. Referenced by InitGL(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 57 of file main.cpp. Referenced by DrawFire(), DrawGLScene(), WinMain(), and WndProc(). |
|
|
Definition at line 115 of file main.cpp. Referenced by DrawGLScene(), and DrawMyText(). |
|
|
|
|
|
Definition at line 137 of file main.cpp. Referenced by LoadSplines(). |
|
|
Definition at line 98 of file main.cpp. Referenced by ColorDialogHook(), and WinMain(). |
|
|
|
|
|
Definition at line 66 of file main.cpp. Referenced by DrawMyText(), and GetTimePassed(). |
|
|
|
|
|
Definition at line 41 of file main.cpp. Referenced by WinMain(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 40 of file main.cpp. Referenced by GetLightColor(), WinMain(), and WndProc(). |
|
|
Definition at line 97 of file main.cpp. Referenced by StartProc(). |
|
|
|
|
|
|
|
|
Definition at line 65 of file main.cpp. Referenced by GetTimePassed(), and WinMain(). |
|
|
Definition at line 62 of file main.cpp. Referenced by GetTimePassed(), and WinMain(). |
|
|
|
|
|
|
|
|
Definition at line 94 of file main.cpp. Referenced by GetLightColor(). |
|
|
Definition at line 131 of file main.cpp. Referenced by CreateLightmaps(). |
|
|
|
|
|
Definition at line 138 of file main.cpp. Referenced by LoadSplines(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 105 of file main.cpp. Referenced by CreateLargePortal(), and InitGL(). |
|
|
Definition at line 63 of file main.cpp. Referenced by GetTimePassed(), and WinMain(). |
|
|
|
|
|
Definition at line 58 of file main.cpp. Referenced by SetGLCamera(), and WinMain(). |
|
|
Definition at line 111 of file main.cpp. Referenced by DrawMyText(). |
|
|
Definition at line 114 of file main.cpp. Referenced by BuildBSP(). |
|
|
Definition at line 130 of file main.cpp. Referenced by CreateLightmaps(). |
|
|
Definition at line 71 of file main.cpp. Referenced by DrawGLScene(), SetGLLighting(), and WinMain(). |
|
|
Definition at line 109 of file main.cpp. Referenced by MakeNodeLists(). |
|
|
Definition at line 110 of file main.cpp. Referenced by MakeNodeLists(). |
|
|
Definition at line 116 of file main.cpp. Referenced by MakePortalList(). |
|
|
Definition at line 81 of file main.cpp. Referenced by InitGL(), and SetGLWorld(). |
|
|
Definition at line 122 of file main.cpp. Referenced by AddPortalsToLeaves(), MakePortalList(), and WndProc(). |
|
|
Definition at line 135 of file main.cpp. Referenced by LoadSplines(), SetSplines(), and WndProc(). |
|
|
Definition at line 126 of file main.cpp. Referenced by CreateLightmaps(). |
|
|
Definition at line 77 of file main.cpp. Referenced by POLYGON::POLYGON(), and VERTEX::VERTEX(). |
|
|
|
|
|
Definition at line 48 of file main.cpp. Referenced by OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::MoveX(), and OBJECT::MoveY(). |
|
|
Definition at line 82 of file main.cpp. Referenced by CheckForCollision(), ClipPortalToBackLeaf(), ClipPortalToFrontLeaf(), InvertPortals(), and SetGLWorld(). |
|
|
|
|
|
|
|
|
Definition at line 43 of file main.cpp. Referenced by WndProc(). |
|
|
Definition at line 49 of file main.cpp. Referenced by OBJECT::Rotate(). |
|
|
Definition at line 54 of file main.cpp. Referenced by WinMain(). |
|
|
|
|
|
|
|
|
Definition at line 108 of file main.cpp. Referenced by WinMain(). |
|
|
|
|
|
Definition at line 139 of file main.cpp. Referenced by StartProc(). |
|
|
Definition at line 141 of file main.cpp. Referenced by AddSpline(), DeleteSpline(), DrawSplines(), LoadSplines(), and SetSplines(). |
|
|
|
|
|
Definition at line 59 of file main.cpp. Referenced by WinMain(). |
|
|
Definition at line 99 of file main.cpp. Referenced by StartProc(). |
|
|
Definition at line 86 of file main.cpp. Referenced by DrawBillboards(), DrawFire(), DrawHalo(), SetGLTexture(), and SetGLWorld(). |
|
|
Definition at line 78 of file main.cpp. Referenced by SetGLVertices(), and SetGLWorld(). |
|
|
|
1.2.15