Hi Robert,
I am trying the code below. I will blend two texture on GPU ( I will
try different GLSL algorithms). But the code gives error at osg\state
file at line 1377 ( while applying each attribute in the attribute
list). When I remove the last 4 line of the below code it is working
withour error. Do you have any idea about the error?


osg::Node* p_Drawable = osgDB::readNodeFile("C:\\Cube.osg");

osg::StateSet* m_StateSet = new osg::StateSet();
p_Drawable->setStateSet(m_StateSet);

osg::Program* p_Program = new osg::Program();
osg::Shader* VertexShader = new osg::Shader(osg::Shader::VERTEX,
g_VertexShaderSource);
osg::Shader* FragmentShader = new osg::Shader(osg::Shader::FRAGMENT,
g_FragmentShaderSource);
p_Program->addShader(VertexShader);
p_Program->addShader(FragmentShader);
m_StateSet->setAttributeAndModes(p_Program, osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE );

osg::Uniform* p_Sampler1 = new osg::Uniform("Tex1", 0);
osg::Uniform* p_Sampler2 = new osg::Uniform("Tex2", 1);
m_StateSet->addUniform(p_Sampler1);
m_StateSet->addUniform(p_Sampler2);

osg::Image* p_Image1 = osgDB::readImageFile("c:\\Texture1.jpg");
osg::Texture2D* p_Texture1 = new osg::Texture2D;
p_Texture1->setImage( p_Image1 );
m_StateSet->setTextureAttributeAndModes(0, p_Texture1,
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);

osg::Image* p_Image2 = osgDB::readImageFile("c:\\Texture2.jpg");
osg::Texture2D* p_Texture2 = new osg::Texture2D;
p_Texture2->setImage( p_Image2 );
m_StateSet->setTextureAttributeAndModes(1, p_Texture2,
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to