Hi David,
I don't personally use Windows, it must a decade now since I last used
one for development... so I can't answer your question specifically.
Best I can do is say in general OpenGL releated features not working
across different systems is usually down to either a problem with the
driver/hardware or a problem in the portability of the OpenGL being
used. Something shaders might be permitted by one driver but cause a
problem in an another, but the problem can be traced back to use of
OpenGL (shders in particular) in ways that are at edge of the official
GLSL spec. This type of problem isn't usually affected by compilers
used.
I recall a tweak made to the OSG to address percularities in driver
implementations in the OSG-3.x era, but can't recall the specific
dates, perhaps this fix might address the problems you have. Could
you try out the svn/trunk or OSG-3.1.3 dev release?
Robert.
On 24 October 2012 16:17, David Sellin davse...@student.liu.se wrote:
Hi,
I ported my program from mingw and Code Blocks to Visual Studio 2010 Express
and found that I couldn't get uniform arrays to work. Has anyone experienced
this? I'm new to Visual Studio so I might have missed something.
I made a small test program that works on my old system but not on my new
system:
(sorry for the weird symbols and that the include dirs fell off)
Code:
#include osg/Group
#include osgDB/ReadFile
#include osgViewer/Viewer
#include osgGA/TrackballManipulator
int main( int argc, char **argv )
{
osg::setNotifyLevel( osg::WARN );
osg::Group *root = new osg::Group;
std::string url = cow.osg;
osg::Node* modelNode = osgDB::readNodeFile( url );
//setup shaders
osg::Shader *vertshader = new osg::Shader( osg::Shader::VERTEX );
vertshader-loadShaderSourceFromFile( uniformarray.vert );
osg::Shader *fragshader = new osg::Shader( osg::Shader::FRAGMENT );
fragshader-loadShaderSourceFromFile( uniformarray.frag );
osg::Program *shaderprog = new osg::Program();
shaderprog-addShader( vertshader );
shaderprog-addShader( fragshader );
modelNode-getOrCreateStateSet()-setAttributeAndModes( shaderprog );
// Array uniform
osg::Uniform *arrayUFM = new osg::Uniform( osg::Uniform::FLOAT, array,
2 );
arrayUFM-setElement( 0, 0.5f );
arrayUFM-setElement( 1, 1.0f );
modelNode-getOrCreateStateSet()-addUniform( arrayUFM );
root-addChild( modelNode );
// Graphics Context and Traits
osg::ref_ptrosg::GraphicsContext::Traits traits = new
osg::GraphicsContext::Traits;
traits-x = 10;
traits-y = 10;
traits-width = 800;
traits-height = 600;
traits-doubleBuffer = true;
const std::string version( 3.1 );
traits-glContextVersion = version;
osg::ref_ptrosg::GraphicsContext gc =
osg::GraphicsContext::createGraphicsContext( traits.get() );
// Viewer
osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer();
viewer-getCamera()-setGraphicsContext( gc.get() );
viewer-getCamera()-setViewport( new osg::Viewport( 0, 0, traits-width,
traits-height ) );
viewer-setSceneData( root );
viewer-setCameraManipulator( new osgGA::TrackballManipulator() );
viewer-run();
return 0;
}
Vertex shader:
Code:
#version 140
uniform mat4 osg_ModelViewProjectionMatrix;
in vec4 osg_Vertex;
void main()
{
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
};
Fragment shader using the array:
Code:
#version 140
uniform float array[2];
out vec4 fragData;
void main()
{
fragData = vec4( 1.0, array[0], array[1], 1.0 );
}
Old system:
OSG 3.0 (revision 12753)
MinGW and Code Blocks
NVIDIA GEFORCE 260
WIN 7
New system
OSG 3.0.1 (stable release)
Visual C++ 2010 Express
NVIDIA GEFORCE 680
WIN 7
Thank you!
Cheers,
David[/code]
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50756#50756
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org