From b3ac26f3dc35fd8de1baac696cc9d3ed54fd9b7e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 10 Jul 2002 13:33:25 +0000 Subject: [PATCH] Updates to osgprerender to support use of rendering to an image, rather then just a texture. --- Make/debugtests.bat | 12 ++ Make/osgtests.bat | 6 + .../Demos/osgprerender/osgprerender.dsp | 121 ++++++++++++++++-- src/Demos/osggeometry/osggeometry.cpp | 2 +- src/Demos/osgprerender/osgprerender.cpp | 22 +++- src/osgDB/Registry.cpp | 1 + 6 files changed, 146 insertions(+), 18 deletions(-) diff --git a/Make/debugtests.bat b/Make/debugtests.bat index 54a19359b..d5743922a 100755 --- a/Make/debugtests.bat +++ b/Make/debugtests.bat @@ -14,6 +14,18 @@ echo osghangglide osghangglide more memleaks.log +echo osggeometry cow.osg +osggeometry cow.osg +more memleaks.log + +echo osgprerender cow.osg +osgprerender cow.osg +more memleaks.log + +echo osgparticle cow.osg +osgparticle cow.osg +more memleaks.log + echo osgbillboard lz.rgb osgbillboard lz.rgb more memleaks.log diff --git a/Make/osgtests.bat b/Make/osgtests.bat index 20a9d686c..49bbc4edb 100755 --- a/Make/osgtests.bat +++ b/Make/osgtests.bat @@ -4,6 +4,12 @@ sgv Town.osg osghangglide +osggeometry cow.osg + +osgprerender cow.osg + +osgparticle cow.osg + osgbillboard lz.rgb osgcube diff --git a/VisualStudio/Demos/osgprerender/osgprerender.dsp b/VisualStudio/Demos/osgprerender/osgprerender.dsp index e01ae42e3..19fac0571 100644 --- a/VisualStudio/Demos/osgprerender/osgprerender.dsp +++ b/VisualStudio/Demos/osgprerender/osgprerender.dsp @@ -1,95 +1,190 @@ # Microsoft Developer Studio Project File - Name="Demo osgprerender" - Package Owner=<4> + # Microsoft Developer Studio Generated Build File, Format Version 6.00 + # ** DO NOT EDIT ** + + # TARGTYPE "Win32 (x86) Console Application" 0x0103 + + CFG=Demo osgprerender - Win32 Release + !MESSAGE This is not a valid makefile. To build this project using NMAKE, + !MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "osgprerender.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "osgprerender.mak" CFG="Demo osgprerender - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Demo osgprerender - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "Demo osgprerender - Win32 Debug" (based on "Win32 (x86) Console Application") + !MESSAGE +!MESSAGE NMAKE /f "osgprerender.mak". + +!MESSAGE + +!MESSAGE You can specify a configuration when running NMAKE + +!MESSAGE by defining the macro CFG on the command line. For example: + +!MESSAGE + +!MESSAGE NMAKE /f "osgprerender.mak" CFG="Demo osgprerender - Win32 Release" + +!MESSAGE + +!MESSAGE Possible choices for configuration are: + +!MESSAGE + +!MESSAGE "Demo osgprerender - Win32 Release" (based on "Win32 (x86) Console Application") + +!MESSAGE "Demo osgprerender - Win32 Debug" (based on "Win32 (x86) Console Application") + +!MESSAGE + + + # Begin Project + # PROP AllowPerConfigDependencies 0 + # PROP Scc_ProjName "" + # PROP Scc_LocalPath "" + CPP=cl.exe + RSC=rc.exe + + !IF "$(CFG)" == "Demo osgprerender - Win32 Release" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 0 + # PROP BASE Output_Dir "Release" + # PROP BASE Intermediate_Dir "Release" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 0 + # PROP Output_Dir "Release" + # PROP Intermediate_Dir "Release" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # 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" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c + # ADD BASE RSC /l 0x809 /d "NDEBUG" + # ADD RSC /l 0x809 /d "NDEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # 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 /machine:I386 + # ADD LINK32 /nologo /subsystem:console /pdb:none /machine:I386 /out:"../../../bin/osgprerender.exe" /libpath:"../../../lib" + + !ELSEIF "$(CFG)" == "Demo osgprerender - Win32 Debug" + + # PROP BASE Use_MFC 0 + # PROP BASE Use_Debug_Libraries 1 + # PROP BASE Output_Dir "Debug" + # PROP BASE Intermediate_Dir "Debug" + # PROP BASE Target_Dir "" + # PROP Use_MFC 0 + # PROP Use_Debug_Libraries 1 + # PROP Output_Dir "Debug" + # PROP Intermediate_Dir "Debug" + # PROP Ignore_Export_Lib 0 + # PROP Target_Dir "" + # 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 /vd0 /GR /GX /Zi /Od /I "../../../include" /D "_CONSOLE" /D "_MBCS" /D "FL_DLL" /D "WIN32" /D "_DEBUG" /FR /YX /FD /c + # ADD BASE RSC /l 0x809 /d "_DEBUG" + # ADD RSC /l 0x809 /d "_DEBUG" + BSC32=bscmake.exe + # ADD BASE BSC32 /nologo + # 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 /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgprerenderd.exe" /pdbtype:sept /libpath:"../../../lib" + +# ADD LINK32 glut32.lib glu32.lib opengl32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcmt" /out:"../../../bin/osgprerenderd.exe" /pdbtype:sept /libpath:"../../../lib" + # SUBTRACT LINK32 /incremental:no + + !ENDIF + + # Begin Target + + # Name "Demo osgprerender - Win32 Release" + # Name "Demo osgprerender - Win32 Debug" + # Begin Source File + + SOURCE=..\..\..\src\Demos\osgprerender\osgprerender.cpp + # End Source File + # End Target + # Begin Group "Resource Files" + + # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + # End Group + # End Project + diff --git a/src/Demos/osggeometry/osggeometry.cpp b/src/Demos/osggeometry/osggeometry.cpp index 39231131c..cecfce50f 100644 --- a/src/Demos/osggeometry/osggeometry.cpp +++ b/src/Demos/osggeometry/osggeometry.cpp @@ -608,7 +608,7 @@ osg::Node* createBackground() osg::Texture* texture = new osg::Texture; texture->setImage(image); - stateset->setAttributeAndModes(texture,osg::StateAttribute::ON); + stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON); polyGeom->setStateSet(stateset); diff --git a/src/Demos/osgprerender/osgprerender.cpp b/src/Demos/osgprerender/osgprerender.cpp index 63852ab4e..23592c51a 100644 --- a/src/Demos/osgprerender/osgprerender.cpp +++ b/src/Demos/osgprerender/osgprerender.cpp @@ -31,12 +31,16 @@ class MyCullCallback : public osg::NodeCallback MyCullCallback(osg::Node* subgraph,osg::Texture* texture): _subgraph(subgraph), _texture(texture) {} + + MyCullCallback(osg::Node* subgraph,osg::Image* image): + _subgraph(subgraph), + _image(image) {} virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { osgUtil::CullVisitor* cullVisitor = dynamic_cast(nv); - if (cullVisitor && _texture.valid() && _subgraph.valid()) + if (cullVisitor && (_texture.valid()|| _image.valid()) && _subgraph.valid()) { doPreRender(*node,*cullVisitor); @@ -55,6 +59,7 @@ class MyCullCallback : public osg::NodeCallback osg::ref_ptr _subgraph; osg::ref_ptr _texture; + osg::ref_ptr _image; }; @@ -277,8 +282,11 @@ void MyCullCallback::doPreRender(osg::Node& node, osgUtil::CullVisitor& cv) // dependancy list. cv.getCurrentRenderBin()->_stage->addToDependencyList(rtts.get()); - // attach texture to the RenderToTextureStage. - rtts->setTexture(_texture.get()); + // if one exist attach texture to the RenderToTextureStage. + if (_texture.valid()) rtts->setTexture(_texture.get()); + + // if one exist attach image to the RenderToTextureStage. + if (_image.valid()) rtts->setImage(_image.get()); } @@ -333,7 +341,12 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph) osg::StateSet* stateset = new osg::StateSet; // set up the texture. + osg::Image* image = new osg::Image; + image->setInternalTextureFormat(GL_RGBA); + //osg::Image* image = osgDB::readImageFile("lz.rgb"); osg::Texture* texture = new osg::Texture; + texture->setSubloadMode(osg::Texture::IF_DIRTY); + texture->setImage(image); stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE_OFF); @@ -346,7 +359,8 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph) billboard->addDrawable(polyGeom,bs.center()); osg::Group* parent = new osg::Group; - parent->setCullCallback(new MyCullCallback(subgraph,texture)); +// parent->setCullCallback(new MyCullCallback(subgraph,texture)); + parent->setCullCallback(new MyCullCallback(subgraph,image)); parent->addChild(billboard); return parent; diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 1463ab670..5f0b0ba5d 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -59,6 +59,7 @@ Registry::Registry() initFilePathLists(); // register file extension alias. + addFileExtensionAlias("sgi", "rgb"); addFileExtensionAlias("rgba", "rgb"); addFileExtensionAlias("int", "rgb"); addFileExtensionAlias("inta", "rgb");