Replaced deprecated osg::Shader::reaDShaderFile()/loadShaderFromSource() usage
This commit is contained in:
parent
5f13a3aa11
commit
284f91b3e0
@ -200,15 +200,10 @@ public:
|
||||
|
||||
ComputeNode()
|
||||
{
|
||||
const char* envOsgFilePath = getenv("OSG_FILE_PATH");
|
||||
std::stringstream computeshaderpath; computeshaderpath << envOsgFilePath << "/shaders/osgssboComputeShader.cs";
|
||||
_computeShaderSourcePath = computeshaderpath.str();
|
||||
std::stringstream vertexshaderpath; vertexshaderpath << envOsgFilePath << "/shaders/osgssboVertexShader.vs";
|
||||
_vertexShaderSourcePath = vertexshaderpath.str();
|
||||
std::stringstream geometryshaderpath; geometryshaderpath << envOsgFilePath << "/shaders/osgssboGeometryShader.gs";
|
||||
_geometryShaderSourcePath = geometryshaderpath.str();
|
||||
std::stringstream fragmentshaderpath; fragmentshaderpath << envOsgFilePath << "/shaders/osgssboFragmentShader.fs";
|
||||
_fragmentShaderSourcePath = fragmentshaderpath.str();
|
||||
_computeShaderSourcePath = "shaders/osgssboComputeShader.cs";
|
||||
_vertexShaderSourcePath = "shaders/osgssboVertexShader.vs";
|
||||
_geometryShaderSourcePath = "shaders/osgssboGeometryShader.gs";
|
||||
_fragmentShaderSourcePath = "shaders/osgssboFragmentShader.fs";
|
||||
}
|
||||
|
||||
};
|
||||
@ -243,7 +238,7 @@ public:
|
||||
if (_computeNode->_computeShader.valid())
|
||||
{
|
||||
runningSource = _computeNode->_computeShader->getShaderSource();
|
||||
reloadedshader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath);
|
||||
reloadedshader = osgDB::readRefShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath);
|
||||
|
||||
reloadedstring = reloadedshader->getShaderSource();
|
||||
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
|
||||
@ -258,7 +253,7 @@ public:
|
||||
{
|
||||
|
||||
runningSource = _computeNode->_vertexShader->getShaderSource();
|
||||
reloadedshader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath);
|
||||
reloadedshader = osgDB::readRefShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath);
|
||||
|
||||
reloadedstring = reloadedshader->getShaderSource();
|
||||
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
|
||||
@ -274,7 +269,7 @@ public:
|
||||
if (_computeNode->_geometryShader.valid())
|
||||
{
|
||||
runningSource = _computeNode->_geometryShader->getShaderSource();
|
||||
reloadedshader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath);
|
||||
reloadedshader = osgDB::readRefShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath);
|
||||
|
||||
reloadedstring = reloadedshader->getShaderSource();
|
||||
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
|
||||
@ -288,7 +283,7 @@ public:
|
||||
if (_computeNode->_fragmentShader.valid())
|
||||
{
|
||||
runningSource = _computeNode->_fragmentShader->getShaderSource();
|
||||
reloadedshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath);
|
||||
reloadedshader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath);
|
||||
|
||||
reloadedstring = reloadedshader->getShaderSource();
|
||||
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
|
||||
@ -517,13 +512,13 @@ void ComputeNode::addComputationResultsRenderTree()
|
||||
|
||||
_computationResultsRenderProgram = new osg::Program;
|
||||
|
||||
_vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _vertexShaderSourcePath);
|
||||
_vertexShader = osgDB::readRefShaderFile(osg::Shader::VERTEX, _vertexShaderSourcePath);
|
||||
_computationResultsRenderProgram->addShader(_vertexShader.get());
|
||||
|
||||
_geometryShader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _geometryShaderSourcePath);
|
||||
_geometryShader = osgDB::readRefShaderFile(osg::Shader::GEOMETRY, _geometryShaderSourcePath);
|
||||
_computationResultsRenderProgram->addShader(_geometryShader.get());
|
||||
|
||||
_fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _fragmentShaderSourcePath);
|
||||
_fragmentShader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, _fragmentShaderSourcePath);
|
||||
_computationResultsRenderProgram->addShader(_fragmentShader.get());
|
||||
|
||||
|
||||
@ -628,7 +623,7 @@ void ComputeNode::initComputingSetup()
|
||||
|
||||
_computeProgram = new osg::Program;
|
||||
_computeProgram->setComputeGroups((NUM_ELEMENTS_X / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_X / WORK_GROUP_SIZE), (NUM_ELEMENTS_Y / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_Y / WORK_GROUP_SIZE), 1);
|
||||
_computeShader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeShaderSourcePath);
|
||||
_computeShader = osgDB::readRefShaderFile(osg::Shader::COMPUTE, _computeShaderSourcePath);
|
||||
_computeProgram->addShader(_computeShader.get());
|
||||
|
||||
setDataVariance(osg::Object::DYNAMIC);
|
||||
|
@ -87,7 +87,7 @@ struct MyRigTransformHardware : public osgAnimation::RigTransformHardware
|
||||
//set default source if _shader is not user setted
|
||||
if (!vertexshader.valid())
|
||||
{
|
||||
vertexshader = osg::Shader::readShaderFile(osg::Shader::VERTEX,"skinning.vert");
|
||||
vertexshader = osgDB::readRefShaderFile(osg::Shader::VERTEX,"skinning.vert");
|
||||
}
|
||||
|
||||
if (!vertexshader.valid())
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "GameOfLifePass.h"
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <iostream>
|
||||
|
||||
ProcessPass::ProcessPass(osg::TextureRectangle *in_tex,
|
||||
@ -110,16 +111,13 @@ void ProcessPass::setupCamera()
|
||||
|
||||
void ProcessPass::setShader(std::string filename)
|
||||
{
|
||||
std::string foundFile = osgDB::findDataFile(filename);
|
||||
if (foundFile.empty())
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Could not file shader file: "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(foundFile);
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Texture3D>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgUtil/Optimizer>
|
||||
|
||||
#include <osg/Program>
|
||||
@ -141,10 +140,10 @@ ModelInstance()
|
||||
static void
|
||||
LoadShaderSource( osg::Shader* shader, const std::string& fileName )
|
||||
{
|
||||
std::string fqFileName = osgDB::findDataFile(fileName);
|
||||
if( fqFileName.length() != 0 )
|
||||
osg::ref_ptr<osg::Shader> loaded_shader = osgDB::readRefShaderFile(fileName);
|
||||
if (loaded_shader)
|
||||
{
|
||||
shader->loadShaderSourceFromFile( fqFileName.c_str() );
|
||||
shader->setShaderSource( loaded_shader->getShaderSource() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "StereoMultipass.h"
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <iostream>
|
||||
|
||||
SubtractPass::SubtractPass(osg::TextureRectangle *left_tex,
|
||||
@ -132,8 +132,12 @@ void SubtractPass::createOutputTextures()
|
||||
|
||||
void SubtractPass::setShader(std::string filename)
|
||||
{
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(osgDB::findDataFile(filename));
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile( osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: could not file shader file : "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
@ -259,8 +263,12 @@ void AggregatePass::setupCamera()
|
||||
|
||||
void AggregatePass::setShader(std::string filename)
|
||||
{
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(osgDB::findDataFile(filename));
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile( osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: could not file shader file : "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
@ -375,8 +383,12 @@ void SelectPass::createOutputTextures()
|
||||
|
||||
void SelectPass::setShader(std::string filename)
|
||||
{
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(osgDB::findDataFile(filename));
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile( osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: could not file shader file : "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
@ -524,8 +536,12 @@ void StereoMultipass::createOutputTextures()
|
||||
|
||||
void StereoMultipass::setShader(std::string filename)
|
||||
{
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(osgDB::findDataFile(filename));
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile( osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: could not file shader file : "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "StereoPass.h"
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <iostream>
|
||||
|
||||
StereoPass::StereoPass(osg::TextureRectangle *left_tex,
|
||||
@ -129,8 +129,12 @@ void StereoPass::createOutputTextures()
|
||||
|
||||
void StereoPass::setShader(std::string filename)
|
||||
{
|
||||
osg::ref_ptr<osg::Shader> fshader = new osg::Shader( osg::Shader::FRAGMENT );
|
||||
fshader->loadShaderSourceFromFile(osgDB::findDataFile(filename));
|
||||
osg::ref_ptr<osg::Shader> fshader = osgDB::readRefShaderFile( osg::Shader::FRAGMENT, filename);
|
||||
if (!fshader)
|
||||
{
|
||||
OSG_NOTICE<<"Warning: could not file shader file : "<<filename<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_FragmentProgram = 0;
|
||||
_FragmentProgram = new osg::Program;
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
|
||||
// $Id: osgwidgetshader.cpp 28 2008-03-26 15:26:48Z cubicool $
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgWidget/Util>
|
||||
#include <osgWidget/WindowManager>
|
||||
#include <osgWidget/Canvas>
|
||||
@ -60,15 +60,9 @@ int main(int, char**)
|
||||
|
||||
osg::Program* program = new osg::Program();
|
||||
|
||||
program->addShader(osg::Shader::readShaderFile(
|
||||
osg::Shader::VERTEX,
|
||||
osgDB::findDataFile("osgWidget/osgwidgetshader-vert.glsl")
|
||||
));
|
||||
|
||||
program->addShader(osg::Shader::readShaderFile(
|
||||
osg::Shader::FRAGMENT,
|
||||
osgDB::findDataFile("osgWidget/osgwidgetshader-frag.glsl")
|
||||
));
|
||||
program->addShader(osgDB::readRefShaderFile( osg::Shader::VERTEX, "osgWidget/osgwidgetshader-vert.glsl" ) );
|
||||
program->addShader(osgDB::readRefShaderFile( osg::Shader::FRAGMENT, "osgWidget/osgwidgetshader-frag.glsl" ) );
|
||||
|
||||
canvas->getGeode()->getOrCreateStateSet()->setAttribute(program);
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <osgAnimation/MorphGeometry>
|
||||
#include <osgAnimation/BoneMapVisitor>
|
||||
#include <osg/TextureBuffer>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <sstream>
|
||||
|
||||
using namespace osgAnimation;
|
||||
@ -137,10 +138,8 @@ bool MorphTransformHardware::init(MorphGeometry& morphGeometry)
|
||||
//set default source if _shader is not user setted
|
||||
if (!vertexshader.valid())
|
||||
{
|
||||
if (!_shader.valid())
|
||||
vertexshader = osg::Shader::readShaderFile(osg::Shader::VERTEX,"morphing.vert");
|
||||
else
|
||||
vertexshader=_shader;
|
||||
if (!_shader.valid()) vertexshader = osgDB::readRefShaderFile(osg::Shader::VERTEX,"morphing.vert");
|
||||
else vertexshader=_shader;
|
||||
}
|
||||
|
||||
if (!vertexshader.valid())
|
||||
@ -157,7 +156,7 @@ bool MorphTransformHardware::init(MorphGeometry& morphGeometry)
|
||||
if (std::string::npos == start)
|
||||
{
|
||||
// perhaps remanance from previous init (if saved after init) so reload shader
|
||||
vertexshader = osg::Shader::readShaderFile(osg::Shader::VERTEX,"morphing.vert");
|
||||
vertexshader = osgDB::readRefShaderFile(osg::Shader::VERTEX,"morphing.vert");
|
||||
if (!vertexshader.valid())
|
||||
{
|
||||
OSG_WARN << "RigTransformHardware can't load VertexShader" << std::endl;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <osgAnimation/RigTransformHardware>
|
||||
#include <osgAnimation/RigGeometry>
|
||||
#include <osgAnimation/BoneMapVisitor>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <sstream>
|
||||
|
||||
using namespace osgAnimation;
|
||||
@ -315,8 +316,7 @@ bool RigTransformHardware::init(RigGeometry& rig)
|
||||
//set default source if _shader is not user setted
|
||||
if (!vertexshader.valid())
|
||||
{
|
||||
if (!_shader.valid())
|
||||
vertexshader = osg::Shader::readShaderFile(osg::Shader::VERTEX,"skinning.vert");
|
||||
if (!_shader.valid()) vertexshader = osgDB::readRefShaderFile(osg::Shader::VERTEX,"skinning.vert");
|
||||
else vertexshader = _shader;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgUtil/CullVisitor>
|
||||
#include <osgSim/OverlayNode>
|
||||
@ -1028,7 +1029,7 @@ OverlayNode::OverlayData* OverlayNode::getOverlayData(osgUtil::CullVisitor* cv)
|
||||
std::string vertexShaderFile = osgDB::findDataFile("shaders/overlay_perspective_rtt.vert");
|
||||
if (!vertexShaderFile.empty())
|
||||
{
|
||||
program->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX, vertexShaderFile));
|
||||
program->addShader(osgDB::readRefShaderFile(osg::Shader::VERTEX, vertexShaderFile));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1119,7 +1120,7 @@ OverlayNode::OverlayData* OverlayNode::getOverlayData(osgUtil::CullVisitor* cv)
|
||||
std::string fragmentShaderFile = osgDB::findDataFile("shaders/overlay_perspective_main.frag");
|
||||
if (!fragmentShaderFile.empty())
|
||||
{
|
||||
overlayData->_mainSubgraphProgram->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT, fragmentShaderFile));
|
||||
overlayData->_mainSubgraphProgram->addShader(osgDB::readRefShaderFile(osg::Shader::FRAGMENT, fragmentShaderFile));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -47,10 +47,7 @@ bool Shader_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
|
||||
osg::ref_ptr<Shader> s = osgDB::readRefShaderFile(fr[1].getStr(), fr.getOptions());
|
||||
if(s.get())
|
||||
shader.setShaderSource(s->getShaderSource());
|
||||
else
|
||||
shader.loadShaderSourceFromFile( osgDB::findDataFile(fr[1].getStr()) );
|
||||
if(s.get()) shader.setShaderSource(s->getShaderSource());
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
|
Loading…
Reference in New Issue
Block a user