Re: [osg-users] Integer vertex attribute issue. Repro included.

2011-05-17 Thread Fred Smith

robertosfield wrote:
 I didn't even realize there was a glVertexAttribIPointer... so yes
 this does sound like it will be the issue.  Either
 osg::Geometry::drawImplementation or osg::State will need to be
 adapted to detect the use of the interger array and use the
 glVertexAttribIPointer.  Feel free to dive into the code and add this
 handling.

Thanks.
I actually didn't know this either.
OK I'm going to look at the code, I think I should be able to make this change.

Cheers,
Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39456#39456





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Integer vertex attribute issue. Repro included.

2011-05-16 Thread Fred Smith
It looks like a problem with OSG to me. OSG should be using 
glVertexAttribIPointer instead of glVertexAttribPointer when dealing with 
integer attributes.

See:

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflatNumber=296704#Post296704

Not sure this is the actual problem but it looks like it.

Cheers,
Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39414#39414





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Integer vertex attribute issue. Repro included.

2011-05-16 Thread Robert Osfield
Hi Fred,

I didn't even realize there was a glVertexAttribIPointer... so yes
this does sound like it will be the issue.  Either
osg::Geometry::drawImplementation or osg::State will need to be
adapted to detect the use of the interger array and use the
glVertexAttribIPointer.  Feel free to dive into the code and add this
handling.

Cheers,
Robert.

On Mon, May 16, 2011 at 4:56 PM, Fred Smith osgfo...@tevs.eu wrote:
 It looks like a problem with OSG to me. OSG should be using 
 glVertexAttribIPointer instead of glVertexAttribPointer when dealing with 
 integer attributes.

 See:

 http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflatNumber=296704#Post296704

 Not sure this is the actual problem but it looks like it.

 Cheers,
 Fred

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=39414#39414





 ___
 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


[osg-users] Integer vertex attribute issue. Repro included.

2011-05-14 Thread Fred Smith
Hi,

I can successfully bind a Vec3 attribute to my vertices. But somehow, calling 
setVertexAttribArray with an IntArray doesn't work for me.
I have attached a modified osggeometryshaders.cpp file to illustrate my issue.

Summary of changes:


Code:
// all shader versions changed to #version 150

// Vertex shader changes
in int inIndex;\n // declare attribute
void main(void)\n
{\n
v_color = vec4(inIndex == 1234 ? 1.0 : 0.0, 0.0, 1.0, 1.0);\n // if the 
attribute is the expected value, the color will be violet - blue otherwise
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n
}\n

// C++ code changes
// createShader() changes:
#ifdef ENABLE_GEOMETRY_SHADER
pgm-addShader( new osg::Shader( osg::Shader::GEOMETRY, geomSource ) );
pgm-setParameter( GL_GEOMETRY_VERTICES_OUT_EXT, 4 );
pgm-setParameter( GL_GEOMETRY_INPUT_TYPE_EXT, GL_POINTS );
pgm-setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_LINE_STRIP );
pgm-addBindAttribLocation(inIndex, 6); // bind vertex attribute
#endif

// SomePoints() changes at the end of the constructor:
osg::IntArray *intArray = new osg::IntArray();
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-push_back(1234);
intArray-setName(inIndex);
this-setVertexAttribArray(6, intArray);
this-setVertexAttribNormalize(6, false);
this-setVertexAttribBinding(6, osg::Geometry::BIND_PER_VERTEX);



I've looked at the GL trace and it seems correct. There must be something I'm 
missing.

Cheers,
Fred

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39367#39367



/* OpenSceneGraph example, osgshaders2
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the Software), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

/* file:examples/osgshaders2/osgshaders2.cpp
 * author:  Mike Weiblen 2008-01-03
 * copyright:   (C) 2008 Zebra Imaging
 * license: OpenSceneGraph Public License (OSGPL)
 *
 * A demo of GLSL geometry shaders using OSG
 * Tested on Dell Precision M4300 w/ NVIDIA Quadro FX 360M
*/


#include osg/Notify
#include osg/ref_ptr
#include osg/Geode
#include osg/Geometry
#include osg/Point
#include osg/Vec3
#include osg/Vec4
#include osg/Program
#include osg/Shader
#include osg/Uniform
#include osgViewer/Viewer

// play with these #defines to see their effect
#define ENABLE_GLSL
#define ENABLE_GEOMETRY_SHADER

///

#ifdef ENABLE_GLSL

class SineAnimation: public osg::Uniform::Callback
{
public:
SineAnimation( float rate = 1.0f, float scale = 1.0f, float offset = 0.0f ) :
_rate(rate), _scale(scale), _offset(offset)
{}

void operator()( osg::Uniform* uniform, osg::NodeVisitor* nv )
{
float angle = _rate * nv-getFrameStamp()-getSimulationTime();
float value = sinf( angle ) * _scale + _offset;
uniform-set( value );
}

private:
const float _rate;
const float _scale;
const float _offset;
};

///

static const char* vertSource = {
#version 150\n
#extension GL_EXT_geometry_shader4 : enable\n
uniform float u_anim1;\n
varying vec4 v_color;\n
in int inIndex;\n
void main(void)\n
{\n
v_color = vec4(inIndex == 1234 ? 1.0 : 0.0, 0.0, 1.0, 1.0);\n // gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n
}\n
};

static const char* geomSource = {
#version 150\n
#extension GL_EXT_geometry_shader4 : enable\n
uniform float u_anim1;\n
varying in vec4 v_color[];\n
varying out vec4 v_color_out;\n
void main(void)\n
{\n
vec4 v = gl_PositionIn[0];\n
v_color_out = v_color[0];\n
\n
gl_Position = v + vec4(u_anim1,0.,0.,0.);  EmitVertex();\n
gl_Position = v - vec4(u_anim1,0.,0.,0.);  EmitVertex();\n
EndPrimitive();\n
\n