Updates to osgprerender to support use of rendering to an image, rather then
just a texture.
This commit is contained in:
parent
7f56ceaea1
commit
b3ac26f3dc
@ -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
|
||||
|
@ -4,6 +4,12 @@ sgv Town.osg
|
||||
|
||||
osghangglide
|
||||
|
||||
osggeometry cow.osg
|
||||
|
||||
osgprerender cow.osg
|
||||
|
||||
osgparticle cow.osg
|
||||
|
||||
osgbillboard lz.rgb
|
||||
|
||||
osgcube
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -32,11 +32,15 @@ class MyCullCallback : public osg::NodeCallback
|
||||
_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<osgUtil::CullVisitor*>(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<osg::Node> _subgraph;
|
||||
osg::ref_ptr<osg::Texture> _texture;
|
||||
osg::ref_ptr<osg::Image> _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;
|
||||
|
@ -59,6 +59,7 @@ Registry::Registry()
|
||||
initFilePathLists();
|
||||
|
||||
// register file extension alias.
|
||||
addFileExtensionAlias("sgi", "rgb");
|
||||
addFileExtensionAlias("rgba", "rgb");
|
||||
addFileExtensionAlias("int", "rgb");
|
||||
addFileExtensionAlias("inta", "rgb");
|
||||
|
Loading…
Reference in New Issue
Block a user