1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #include "OSGSimpleCSMPlugin.h"
41 #include "OSGComplexSceneManager.h"
42 #include "OSGOSGSceneFileType.h"
44 #include "OSGBaseInitFunctions.h"
49 void dumpGLError(GLenum glError
, const GLubyte
*glErrorString
)
51 fprintf(stderr
, "Custom error dump\n");
52 fprintf(stderr
, "-----------------\n");
56 case GL_STACK_OVERFLOW
:
57 case GL_STACK_UNDERFLOW
:
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",
81 fprintf(stderr
, " ProjectionStack %d %d\n",
88 SimpleCSMPlugin::SimpleCSMPlugin(void)
93 SimpleCSMPlugin::~SimpleCSMPlugin(void)
97 void SimpleCSMPlugin::run(int argc
, char **argv
)
100 OSG::preloadSharedObject("OSGImageFileIO");
103 OSG::ChangeList::setReadWriteDefault(true);
105 OSG::osgInit(argc
,argv
);
107 OSG::GLErrorCallback
= dumpGLError
;
109 // Assume dir is given
112 // fprintf(stderr, "start from dir\n");
114 std::string szParamFilename
= argv
[1];
116 if(szParamFilename
[szParamFilename
.length() - 1] == '/')
118 szParamFilename
+= "params.csm";
122 szParamFilename
+= "/params.csm";
125 fprintf(stderr
, "Trying to start from : %s\n", szParamFilename
.c_str());
127 OSG::ComplexSceneManager::startFrom(szParamFilename
);
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
[] =
140 "Source/Contrib/ComplexSceneManager/data/system-native.osg",
144 "Source/Contrib/ComplexSceneManager/data/simple_mouse.osg"
149 OSG::ComplexSceneManager::the()->startFrom(
151 const_cast<char **>(argvTmp
));
153 OSG::ComplexSceneManager::the()->run();
162 OSG::SimpleCSMPluginInterface
*createInterface(void)
164 return new OSG::SimpleCSMPlugin();