home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 2 / Engine / Engine.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  3.2 KB  |  91 lines

  1. //-----------------------------------------------------------------------------
  2. // The primary engine header file. This file links the entire engine together
  3. // and is the only header file that needs to be included in any project using
  4. // the engine.
  5. //
  6. // Programming a Multiplayer First Person Shooter in DirectX
  7. // Copyright (c) 2004 Vaughan Young
  8. //-----------------------------------------------------------------------------
  9. #ifndef ENGINE_H
  10. #define ENGINE_H
  11.  
  12. //-----------------------------------------------------------------------------
  13. // DirectInput Version Define
  14. //-----------------------------------------------------------------------------
  15. #define DIRECTINPUT_VERSION 0x0800
  16.  
  17. //-----------------------------------------------------------------------------
  18. // System Includes
  19. //-----------------------------------------------------------------------------
  20. #include <stdio.h>
  21. #include <tchar.h>
  22. #include <windowsx.h>
  23.  
  24. //-----------------------------------------------------------------------------
  25. // DirectX Includes
  26. //-----------------------------------------------------------------------------
  27. #include <d3dx9.h>
  28. #include <dinput.h>
  29. #include <dplay8.h>
  30. #include <dmusici.h>
  31.  
  32. //-----------------------------------------------------------------------------
  33. // Macros
  34. //-----------------------------------------------------------------------------
  35. #define SAFE_DELETE( p )       { if( p ) { delete ( p );     ( p ) = NULL; } }
  36. #define SAFE_DELETE_ARRAY( p ) { if( p ) { delete[] ( p );   ( p ) = NULL; } }
  37. #define SAFE_RELEASE( p )      { if( p ) { ( p )->Release(); ( p ) = NULL; } }
  38.  
  39. //-----------------------------------------------------------------------------
  40. // Engine Includes
  41. //-----------------------------------------------------------------------------
  42. #include "LinkedList.h"
  43. #include "ResourceManagement.h"
  44. #include "Geometry.h"
  45.  
  46. //-----------------------------------------------------------------------------
  47. // Engine Setup Structure
  48. //-----------------------------------------------------------------------------
  49. struct EngineSetup
  50. {
  51.     HINSTANCE instance; // Application instance handle.
  52.     char *name; // Name of the application.
  53.  
  54.     //-------------------------------------------------------------------------
  55.     // The engine setup structure constructor.
  56.     //-------------------------------------------------------------------------
  57.     EngineSetup()
  58.     {
  59.         instance = NULL;
  60.         name = "Application";
  61.     }
  62. };
  63.  
  64. //-----------------------------------------------------------------------------
  65. // Engine Class
  66. //-----------------------------------------------------------------------------
  67. class Engine
  68. {
  69. public:
  70.     Engine( EngineSetup *setup = NULL );
  71.     virtual ~Engine();
  72.  
  73.     void Run();
  74.  
  75.     HWND GetWindow();
  76.     void SetDeactiveFlag( bool deactive );
  77.  
  78. private:
  79.     bool m_loaded; // Indicates if the engine is loading.
  80.     HWND m_window; // Main window handle.
  81.     bool m_deactive; // Indicates if the application is active or not.
  82.  
  83.     EngineSetup *m_setup; // Copy of the engine setup structure.
  84. };
  85.  
  86. //-----------------------------------------------------------------------------
  87. // Externals
  88. //-----------------------------------------------------------------------------
  89. extern Engine *g_engine;
  90.  
  91. #endif