source: OGRE/trunk/ogrenew/PlatformManagers/Win32/src/OgreWin32PlatformDll.cpp @ 657

Revision 657, 4.5 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://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
41namespace 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#ifdef DEBUG
138    BOOL WINAPI DllMain( HINSTANCE hinstDLL,  // handle to DLL module
139                         DWORD fdwReason,     // reason for calling function
140                         LPVOID lpvReserved   // reserved
141                       )
142    {
143        if( fdwReason == DLL_THREAD_DETACH ) {
144            if( g_iCreatedConfigDiag )
145                LogManager::logMessage( "Memory Leak: Not all platform configuration dialogs were destroyed!!!", LML_CRITICAL );
146            if( g_iCreatedErrorDiag )
147                LogManager::logMessage( "Memory Leak: Not all platform error dialogs were destroyed!!!", LML_CRITICAL );
148            if( g_iCreatedRenderWindow )
149                LogManager::logMessage( "Memory Leak: Not all platform render windows were destroyed!!!", LML_CRITICAL );
150            if( g_iCreatedInputReader )
151                LogManager::logMessage( "Memory Leak: Not all platform input readers were destroyed!!!", LML_CRITICAL );
152        }
153    }
154#endif
155}
Note: See TracBrowser for help on using the repository browser.