From 8d918d951f283d90762e8200bf3e460b0f1cc6b4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 10 Jan 2007 14:56:22 +0000 Subject: [PATCH] Ported osgconv and osgdem across to osgViewer --- VisualStudio/OpenSceneGraph.dsw | 4 +- VisualStudio/applications/osgconv/osgconv.dsp | 8 +-- VisualStudio/applications/osgdem/osgdem.dsp | 8 +-- applications/osgconv/GNUmakefile | 2 +- applications/osgconv/GNUmakefile.inst | 5 +- applications/osgconv/osgconv.cpp | 53 +++++++++++++----- applications/osgdem/GNUmakefile | 2 +- applications/osgdem/GNUmakefile.inst | 2 +- applications/osgdem/osgdem.cpp | 55 ++++++++++++++----- applications/osgversion/GNUmakefile.inst | 5 +- 10 files changed, 94 insertions(+), 50 deletions(-) diff --git a/VisualStudio/OpenSceneGraph.dsw b/VisualStudio/OpenSceneGraph.dsw index 4cca7b8b4..464e3268a 100644 --- a/VisualStudio/OpenSceneGraph.dsw +++ b/VisualStudio/OpenSceneGraph.dsw @@ -297,7 +297,7 @@ Package=<4> Project_Dep_Name Core osgUtil End Project Dependency Begin Project Dependency - Project_Dep_Name Core osgProducer + Project_Dep_Name Core osgViewer End Project Dependency }}} @@ -321,7 +321,7 @@ Package=<4> Project_Dep_Name Core osgGA End Project Dependency Begin Project Dependency - Project_Dep_Name Core osgProducer + Project_Dep_Name Core osgViewer End Project Dependency Begin Project Dependency Project_Dep_Name Core osgUtil diff --git a/VisualStudio/applications/osgconv/osgconv.dsp b/VisualStudio/applications/osgconv/osgconv.dsp index 3b4682252..207b4f744 100755 --- a/VisualStudio/applications/osgconv/osgconv.dsp +++ b/VisualStudio/applications/osgconv/osgconv.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 OpenThreadsWin32.lib opengl32.lib Producer.lib /nologo /subsystem:console /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgconv.exe" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# ADD LINK32 OpenThreadsWin32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgconv.exe" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" !ELSEIF "$(CFG)" == "Application osgconv - Win32 Debug" @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /Zm200 /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /Zm200 /c # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe @@ -76,7 +76,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 OpenThreadsWin32d.lib Producerd.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"$(OutDir)/osgconvd.exe" /pdbtype:sept /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# ADD LINK32 OpenThreadsWin32d.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"$(OutDir)/osgconvd.exe" /pdbtype:sept /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" # SUBTRACT LINK32 /incremental:no !ENDIF diff --git a/VisualStudio/applications/osgdem/osgdem.dsp b/VisualStudio/applications/osgdem/osgdem.dsp index 95523d01c..a33c4461a 100644 --- a/VisualStudio/applications/osgdem/osgdem.dsp +++ b/VisualStudio/applications/osgdem/osgdem.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 OpenThreadsWin32.lib gdal_i.lib producer.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgdem.exe" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# ADD LINK32 OpenThreadsWin32.lib gdal_i.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgdem.exe" /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" !ELSEIF "$(CFG)" == "Application osgdem - Win32 Debug" @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /Zm200 /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../3rdParty/include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /Zm200 /c # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe @@ -76,7 +76,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 OpenThreadsWin32d.lib gdal_iD.lib producerd.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"$(OutDir)/osgdemd.exe" /pdbtype:sept /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../Producer/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" +# ADD LINK32 OpenThreadsWin32d.lib gdal_iD.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"$(OutDir)/osgdemd.exe" /pdbtype:sept /libpath:"../../../lib/$(PlatformName)" /libpath:"../../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../../3rdParty/lib" # SUBTRACT LINK32 /incremental:no !ENDIF diff --git a/applications/osgconv/GNUmakefile b/applications/osgconv/GNUmakefile index e9adb2e62..3e4a3b195 100644 --- a/applications/osgconv/GNUmakefile +++ b/applications/osgconv/GNUmakefile @@ -8,7 +8,7 @@ CXXFILES =\ HEADERFILES = \ OrientationConverter.h -LIBS += -losgProducer -lProducer -losgText -losg -losgUtil -losgGA -losgDB $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgText -losg -losgUtil -losgGA -losgDB $(GL_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/applications/osgconv/GNUmakefile.inst b/applications/osgconv/GNUmakefile.inst index 7b8cad085..393444c01 100644 --- a/applications/osgconv/GNUmakefile.inst +++ b/applications/osgconv/GNUmakefile.inst @@ -5,7 +5,7 @@ CXXFILES =\ OrientationConverter.cpp\ osgconv.cpp\ -LIBS += -losgProducer -lProducer -losgText -losg -losgUtil -losgDB $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgText -losg -losgUtil -losgDB $(GL_LIBS) $(OTHER_LIBS) EXEC = osgconv @@ -13,7 +13,4 @@ INSTFILES =\ $(CXXFILES)\ Makefile.inst=Makefile -INC += $(PRODUCER_INCLUDE_DIR) $(X_INC) -LDFLAGS += $(PRODUCER_LIB_DIR) - include $(TOPDIR)/Make/makerules diff --git a/applications/osgconv/osgconv.cpp b/applications/osgconv/osgconv.cpp index ebadbf6c0..168751d43 100644 --- a/applications/osgconv/osgconv.cpp +++ b/applications/osgconv/osgconv.cpp @@ -19,32 +19,50 @@ #include #include -#include - #include #include "OrientationConverter.h" typedef std::vector FileNameList; -class GraphicsContext { +class MyGraphicsContext { public: - GraphicsContext() + MyGraphicsContext() { - rs = new Producer::RenderSurface; - rs->setWindowRectangle(0,0,1,1); - rs->useBorder(false); - rs->useConfigEventThread(false); - rs->realize(); - std::cout<<"Realized window"< traits = new osg::GraphicsContext::Traits; + traits->x = 0; + traits->y = 0; + traits->width = 1; + traits->height = 1; + traits->windowDecoration = false; + traits->doubleBuffer = false; + traits->sharedContext = 0; + traits->pbuffer = true; + + _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + + if (!_gc) + { + osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<pbuffer = false; + _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + } - virtual ~GraphicsContext() - { + if (_gc.valid()) + + + { + _gc->realize(); + _gc->makeCurrent(); + std::cout<<"Realized window"<isRealized(); } + private: - Producer::ref_ptr rs; + osg::ref_ptr _gc; }; class CompressTexturesVisitor : public osg::NodeVisitor @@ -89,7 +107,12 @@ public: void compress() { - GraphicsContext context; + MyGraphicsContext context; + if (!context.valid()) + { + osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context - cannot run compression"< state = new osg::State; diff --git a/applications/osgdem/GNUmakefile b/applications/osgdem/GNUmakefile index 0e636ca8f..664286763 100644 --- a/applications/osgdem/GNUmakefile +++ b/applications/osgdem/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgdem.cpp\ -LIBS += -losgProducer -lProducer -losgTerrain -losgFX -losgText -losgGA -losgDB -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgTerrain -losgFX -losgText -losgGA -losgDB -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/applications/osgdem/GNUmakefile.inst b/applications/osgdem/GNUmakefile.inst index 771b63e8d..45beb6b96 100644 --- a/applications/osgdem/GNUmakefile.inst +++ b/applications/osgdem/GNUmakefile.inst @@ -5,7 +5,7 @@ CXXFILES =\ osgdem.cpp\ -LIBS += -losgProducer -lProducer -losgTerrain -losgFX -losgDB -losgText -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgTerrain -losgFX -losgDB -losgText -losgUtil -losg $(GDAL_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgdem diff --git a/applications/osgdem/osgdem.cpp b/applications/osgdem/osgdem.cpp index a2bafd4a1..4b217d93a 100644 --- a/applications/osgdem/osgdem.cpp +++ b/applications/osgdem/osgdem.cpp @@ -13,6 +13,7 @@ #pragma warning(disable : 4503) #endif // WIN32 +#include #include #include #include @@ -32,29 +33,50 @@ #include -#include #include #include -class GraphicsContext { +#include + +class MyGraphicsContext { public: - GraphicsContext() + MyGraphicsContext() { - rs = new Producer::RenderSurface; - rs->setWindowRectangle(0,0,1,1); - rs->useBorder(false); - rs->useConfigEventThread(false); - rs->realize(); - std::cout<<"Realized window"< traits = new osg::GraphicsContext::Traits; + traits->x = 0; + traits->y = 0; + traits->width = 1; + traits->height = 1; + traits->windowDecoration = false; + traits->doubleBuffer = false; + traits->sharedContext = 0; + traits->pbuffer = true; - virtual ~GraphicsContext() - { + _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + + if (!_gc) + { + osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<pbuffer = false; + _gc = osg::GraphicsContext::createGraphicsContext(traits.get()); + } + + if (_gc.valid()) + + + { + _gc->realize(); + _gc->makeCurrent(); + std::cout<<"Realized window"<isRealized(); } + private: - Producer::ref_ptr rs; + osg::ref_ptr _gc; }; osg::Matrixd computeGeoTransForRange(double xMin, double xMax, double yMin, double yMax) @@ -635,7 +657,12 @@ int main( int argc, char **argv ) // generate the database { - GraphicsContext context; + MyGraphicsContext context; + if (!context.valid()) + { + osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context - cannot run osgdem"<loadSources(); diff --git a/applications/osgversion/GNUmakefile.inst b/applications/osgversion/GNUmakefile.inst index 482d9d332..35aa4cdc3 100644 --- a/applications/osgversion/GNUmakefile.inst +++ b/applications/osgversion/GNUmakefile.inst @@ -4,11 +4,8 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgversion.cpp\ -LIBS += -losgProducer -lProducer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgversion -INC += $(PRODUCER_INCLUDE_DIR) $(X_INC) -LDFLAGS += $(PRODUCER_LIB_DIR) - include $(TOPDIR)/Make/makerules