fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / CSMPlugin / SimpleTest / OSGSimpleCSMPlugin.cpp
blob9d721cc3e9b356eebbba2b723baec0785e59f1a3
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2008 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #include "OSGSimpleCSMPlugin.h"
41 #include "OSGComplexSceneManager.h"
42 #include "OSGOSGSceneFileType.h"
44 #include "OSGBaseInitFunctions.h"
45 #include "OSGGLU.h"
47 OSG_BEGIN_NAMESPACE
49 void dumpGLError(GLenum glError, const GLubyte *glErrorString)
51 fprintf(stderr, "Custom error dump\n");
52 fprintf(stderr, "-----------------\n");
54 switch(glError)
56 case GL_STACK_OVERFLOW:
57 case GL_STACK_UNDERFLOW:
59 GLint iMatMode;
60 GLint iMoViMatInfo[2];
61 GLint iProjMatInfo[2];
62 GLint iTexMatInfo [2];
64 glGetIntegerv(GL_MATRIX_MODE, &iMatMode);
66 glGetIntegerv(GL_MODELVIEW_STACK_DEPTH, &(iMoViMatInfo[0]));
67 glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &(iMoViMatInfo[1]));
69 glGetIntegerv(GL_PROJECTION_STACK_DEPTH, &(iProjMatInfo[0]));
70 glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &(iProjMatInfo[1]));
72 glGetIntegerv(GL_TEXTURE_STACK_DEPTH, &(iTexMatInfo[0]));
73 glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &(iTexMatInfo[1]));
75 fprintf(stderr, " MatrixMode 0x%04x\n", iMatMode);
77 fprintf(stderr, " ModelViewStack %d %d\n",
78 iMoViMatInfo[0],
79 iMoViMatInfo[1]);
81 fprintf(stderr, " ProjectionStack %d %d\n",
82 iProjMatInfo[0],
83 iProjMatInfo[1]);
88 SimpleCSMPlugin::SimpleCSMPlugin(void)
93 SimpleCSMPlugin::~SimpleCSMPlugin(void)
97 void SimpleCSMPlugin::run(int argc, char **argv)
99 #ifdef WIN32
100 OSG::preloadSharedObject("OSGImageFileIO");
101 #endif
103 OSG::ChangeList::setReadWriteDefault(true);
105 OSG::osgInit(argc,argv);
107 OSG::GLErrorCallback = dumpGLError;
109 // Assume dir is given
110 if(argc == 2)
112 // fprintf(stderr, "start from dir\n");
114 std::string szParamFilename = argv[1];
116 if(szParamFilename[szParamFilename.length() - 1] == '/')
118 szParamFilename += "params.csm";
120 else
122 szParamFilename += "/params.csm";
125 fprintf(stderr, "Trying to start from : %s\n", szParamFilename.c_str());
127 OSG::ComplexSceneManager::startFrom(szParamFilename);
129 else
131 OSG::OSGSceneFileType::the().readContainer(
132 "Source/Contrib/ComplexSceneManager/data/system-native.osg");
134 fprintf(stderr, "Got %p\n",
135 static_cast<void *>(OSG::ComplexSceneManager::the()));
137 const char *argvTmp[] =
139 "testCSM",
140 "Source/Contrib/ComplexSceneManager/data/system-native.osg",
141 "--data",
142 "TestData/tie.wrl",
143 "--global",
144 "Source/Contrib/ComplexSceneManager/data/simple_mouse.osg"
147 int argcTmp = 6;
149 OSG::ComplexSceneManager::the()->startFrom(
150 argcTmp,
151 const_cast<char **>(argvTmp));
153 OSG::ComplexSceneManager::the()->run();
157 OSG_END_NAMESPACE
159 extern "C"
161 OSG_DLL_EXPORT
162 OSG::SimpleCSMPluginInterface *createInterface(void)
164 return new OSG::SimpleCSMPlugin();