source: osgVisual/src/core/osgVisual.cpp @ 87

Last change on this file since 87 was 87, checked in by Torben Dannhauer, 14 years ago

Introductes VS 2008 Memory Leak Debugging.
Todo: Compile on Linux and compare with Valgrind, VS 2008 seems to be awkward in leak debugging

File size: 2.6 KB
Line 
1/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer
2 *
3 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17const unsigned int MAX_NUM_EVENTS = 10;
18
19#ifdef _DEBUG
20        #ifdef WIN32
21                // Declare this in header.
22                #define _CRTDBG_MAP_ALLOC
23                #include <stdlib.h>
24                #include <crtdbg.h>
25        #endif
26#endif
27
28//#include <windows.h>
29
30#include <osg/ArgumentParser>
31#include <osg/Referenced>
32#include <osgDB/Registry>
33
34#include <visual_core.h>
35
36
37
38
39int main(int argc, char** argv)
40{
41       
42#ifdef _DEBUG
43        #ifdef WIN32
44                #include <leakDetection.h>      // ugly but must be included inside the class
45
46                int tmp_flag;
47
48                HANDLE log_file = CreateFile("mem_log.txt", GENERIC_WRITE,FILE_SHARE_WRITE,
49                        NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
50
51                _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
52                        _CRTDBG_MODE_DEBUG);
53                _CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
54                _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_FILE | _CRTDBG_MODE_WNDW |
55                        _CRTDBG_MODE_DEBUG);
56
57                // output to the file if not under VS
58                _CrtSetReportFile(_CRT_ASSERT, log_file);
59                _CrtSetReportFile(_CRT_WARN, log_file);
60                _CrtSetReportFile(_CRT_ERROR, log_file);
61
62                tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
63                tmp_flag |= _CRTDBG_ALLOC_MEM_DF;
64                tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
65                tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
66
67                _CrtSetDbgFlag(tmp_flag);
68        #endif
69#endif
70
71    // Use an ArgumentParser object to manage the program arguments.
72        osg::ArgumentParser arguments(&argc,argv);
73
74    // Instantiate osgVisual main class
75        osg::ref_ptr<osgVisual::visual_core> core = new osgVisual::visual_core(arguments);
76
77    // Visual initialisieren
78    core->initialize();
79
80        // Shut osgVisual down
81        core->shutdown();
82
83        // Set Pointer to null to destroy the objects before this function ends - otherwise memory leaks wil be detected.
84        core = NULL;
85
86        return 0;
87}
Note: See TracBrowser for help on using the repository browser.