[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #include "OgreWin32ConfigDialog.h"
|
---|
| 26 | #include "OgreWin32ErrorDialog.h"
|
---|
| 27 |
|
---|
| 28 | #ifndef OGRE_NO_DX_INPUT
|
---|
| 29 | #ifdef DX7INPUTONLY
|
---|
| 30 | #include "OgreWin32Input.h"
|
---|
| 31 | #else
|
---|
| 32 | #include "OgreWin32Input8.h"
|
---|
| 33 | #endif
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | #include "OgreWin32Timer.h"
|
---|
| 37 | #include "OgreRoot.h"
|
---|
| 38 | #include "OgreLogManager.h"
|
---|
| 39 | #include "OgreRenderWindow.h"
|
---|
| 40 |
|
---|
| 41 | namespace Ogre {
|
---|
| 42 |
|
---|
| 43 | #ifdef DEBUG
|
---|
| 44 | int g_iCreatedConfigDiag = 0;
|
---|
| 45 | int g_iCreatedErrorDiag = 0;
|
---|
| 46 | int g_iCreatedRenderWindow = 0;
|
---|
| 47 | int g_iCreatedInputReader = 0;
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 | /// Retrieves an instance of a config dialog for this platform
|
---|
| 51 | extern "C" void createPlatformConfigDialog(ConfigDialog** ppDlg)
|
---|
| 52 | {
|
---|
| 53 | // Must get HINSTANCE
|
---|
| 54 | HINSTANCE hInst = GetModuleHandle(OGRE_PLATFORM_LIB);
|
---|
| 55 | *ppDlg = new Win32ConfigDialog(hInst);
|
---|
| 56 |
|
---|
| 57 | #ifdef DEBUG
|
---|
| 58 | g_iCreatedConfigDiag++;
|
---|
| 59 | #endif
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /// Retrieves an instance of an error dialog for this platform
|
---|
| 63 | extern "C" void createPlatformErrorDialog(ErrorDialog** ppDlg)
|
---|
| 64 | {
|
---|
| 65 | HINSTANCE hInst = GetModuleHandle(OGRE_PLATFORM_LIB);
|
---|
| 66 | *ppDlg = new Win32ErrorDialog(hInst);
|
---|
| 67 |
|
---|
| 68 | #ifdef DEBUG
|
---|
| 69 | g_iCreatedErrorDiag++;
|
---|
| 70 | #endif
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | /// Creates a Timer using default implementation
|
---|
| 74 | extern "C" void createTimer(Timer** ppTimer)
|
---|
| 75 | {
|
---|
| 76 | *ppTimer = new Win32Timer();
|
---|
| 77 | (*ppTimer)->reset();
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | extern "C" void destroyTimer(Timer* ppTimer)
|
---|
| 81 | {
|
---|
| 82 | delete ppTimer;
|
---|
| 83 | }
|
---|
| 84 | /// Retrieves an instance of an input reader for this platform
|
---|
| 85 | extern "C" void createPlatformInputReader(InputReader** ppReader)
|
---|
| 86 | {
|
---|
| 87 | #ifndef OGRE_NO_DX_INPUT
|
---|
| 88 | #ifdef DX7INPUTONLY
|
---|
| 89 | *ppReader = new Win32Input();
|
---|
| 90 | #else
|
---|
| 91 | *ppReader = new Win32Input8();
|
---|
| 92 | #endif
|
---|
| 93 | #endif
|
---|
| 94 |
|
---|
| 95 | #ifdef DEBUG
|
---|
| 96 | g_iCreatedInputReader++;
|
---|
| 97 | #endif
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | /// Destroys
|
---|
| 101 | extern "C" void destroyPlatformConfigDialog(ConfigDialog* dlg)
|
---|
| 102 | {
|
---|
| 103 | delete dlg;
|
---|
| 104 |
|
---|
| 105 | #ifdef DEBUG
|
---|
| 106 | g_iCreatedConfigDiag--;
|
---|
| 107 | #endif
|
---|
| 108 | }
|
---|
| 109 | /// Destroys
|
---|
| 110 | extern "C" void destroyPlatformErrorDialog(ErrorDialog* dlg)
|
---|
| 111 | {
|
---|
| 112 | delete dlg;
|
---|
| 113 |
|
---|
| 114 | #ifdef DEBUG
|
---|
| 115 | g_iCreatedErrorDiag--;
|
---|
| 116 | #endif
|
---|
| 117 | }
|
---|
| 118 | /// Destroys
|
---|
| 119 | extern "C" void destroyPlatformRenderWindow(RenderWindow* wnd)
|
---|
| 120 | {
|
---|
| 121 | delete wnd;
|
---|
| 122 |
|
---|
| 123 | #ifdef DEBUG
|
---|
| 124 | g_iCreatedRenderWindow--;
|
---|
| 125 | #endif
|
---|
| 126 | }
|
---|
| 127 | /// Destroys
|
---|
| 128 | extern "C" void destroyPlatformInputReader(InputReader* reader)
|
---|
| 129 | {
|
---|
| 130 | delete reader;
|
---|
| 131 |
|
---|
| 132 | #ifdef DEBUG
|
---|
| 133 | g_iCreatedInputReader--;
|
---|
| 134 | #endif
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | extern "C" void messagePump(RenderWindow* rw)
|
---|
| 138 | {
|
---|
| 139 | //A simple Win32 event pump
|
---|
| 140 | MSG msg;
|
---|
| 141 | while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
|
---|
| 142 | {
|
---|
| 143 | TranslateMessage( &msg );
|
---|
| 144 | DispatchMessage( &msg );
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | #ifdef DEBUG
|
---|
| 149 | BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module
|
---|
| 150 | DWORD fdwReason, // reason for calling function
|
---|
| 151 | LPVOID lpvReserved // reserved
|
---|
| 152 | )
|
---|
| 153 | {
|
---|
| 154 | if( fdwReason == DLL_THREAD_DETACH ) {
|
---|
| 155 | if( g_iCreatedConfigDiag )
|
---|
| 156 | LogManager::logMessage( "Memory Leak: Not all platform configuration dialogs were destroyed!!!", LML_CRITICAL );
|
---|
| 157 | if( g_iCreatedErrorDiag )
|
---|
| 158 | LogManager::logMessage( "Memory Leak: Not all platform error dialogs were destroyed!!!", LML_CRITICAL );
|
---|
| 159 | if( g_iCreatedRenderWindow )
|
---|
| 160 | LogManager::logMessage( "Memory Leak: Not all platform render windows were destroyed!!!", LML_CRITICAL );
|
---|
| 161 | if( g_iCreatedInputReader )
|
---|
| 162 | LogManager::logMessage( "Memory Leak: Not all platform input readers were destroyed!!!", LML_CRITICAL );
|
---|
| 163 | }
|
---|
| 164 | }
|
---|
| 165 | #endif
|
---|
| 166 | }
|
---|