Re: [osg-users] Draw instance quads not working

2017-05-22 Thread Raymond de Vries

Hi Bruno,

Can you provide more information about your setup? Platform, gfx card, 
osg version, etc. Have you seen and tried the osg example 
osgdrawinstanced? Writing "not working" is probably too little info for 
people to help you ;-)


Cheers,
Raymond



On 5/22/2017 8:17 PM, Bruno Oliveira wrote:

Hi,


I want to render several simple quads ( a simple rectangle). I pass 
the quad centers via a 2D texture, and try to render them with the 
following vertex shader:




"#version 120\n"
"#extension GL_EXT_draw_instanced : enable\n"
"\n"
"uniform sampler2D texVert;\n"
"uniform sampler2D texColor;\n"
"uniform float  texSize;\n"
"\n"
"void main() {\n"
"\n"
"  float row   = float(gl_InstanceID) / texSize;\n"
"\n"
"  vec2  uv= vec2(fract(row), floor(row) / texSize);\n"
"  vec4  vert  = gl_Vertex + texture2D(texVert, uv);\n"
"\n"
"  gl_Position = gl_ModelViewProjectionMatrix * vert;\n"
"\n"
"}\n"



*This is my code for creating 1000 quads:*

this->setUseDisplayList(false),
this->setUseVertexBufferObjects(true);

// Build Geometry
// Simple Quad
  osg::ref_ptr vertices = new osg::Vec3Array(4);
  (*vertices)[0].set(-500, -500, 0.f );
  (*vertices)[1].set( 500, -500, 0.f );
  (*vertices)[2].set( 500,  500, 0.f );
  (*vertices)[3].set(-500,  500, 0.f );

  this->setUseDisplayList(false);
  this->setUseVertexBufferObjects(true);
  this->setVertexArray(vertices.get());
  this->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4, 1000));


*IMPORTANT NOTE*: *If I use simple GL_POINTS, my code works fine and 
renders correclty 1000 points:

*

  osg::ref_ptr vertices = new osg::Vec3Array(1);
  (*vertices)[0].set(0, 0, 0.f );

  this->setVertexArray(vertices);

this->addPrimitiveSet( new osg::DrawArrays(GL_POINTS, 0, 1, 1000) );





AVG logo    

This email has been checked for viruses by AVG antivirus software.
www.avg.com 


<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


___
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] Draw instance quads not working

2017-05-22 Thread Bruno Oliveira
Hi,


I want to render several simple quads ( a simple rectangle). I pass the
quad centers via a 2D texture, and try to render them with the following
vertex shader:



"#version 120\n"
"#extension GL_EXT_draw_instanced : enable\n"
"\n"
"uniform sampler2D texVert;\n"
"uniform sampler2D texColor;\n"
"uniform float  texSize;\n"
"\n"
"void main() {\n"
"\n"
"  float row   = float(gl_InstanceID) / texSize;\n"
"\n"
"  vec2  uv= vec2(fract(row), floor(row) / texSize);\n"
"  vec4  vert  = gl_Vertex + texture2D(texVert, uv);\n"
"\n"
"  gl_Position = gl_ModelViewProjectionMatrix * vert;\n"
"\n"
"}\n"



*This is my code for creating 1000 quads:*

this->setUseDisplayList(false),
this->setUseVertexBufferObjects(true);

// Build Geometry
// Simple Quad
  osg::ref_ptr vertices = new osg::Vec3Array(4);
  (*vertices)[0].set(-500, -500, 0.f );
  (*vertices)[1].set( 500, -500, 0.f );
  (*vertices)[2].set( 500,  500, 0.f );
  (*vertices)[3].set(-500,  500, 0.f );

  this->setUseDisplayList(false);
  this->setUseVertexBufferObjects(true);
  this->setVertexArray(vertices.get());
  this->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4, 1000));


*IMPORTANT NOTE*:
*If I use simple GL_POINTS, my code works fine and renders correclty 1000
points:*

  osg::ref_ptr vertices = new osg::Vec3Array(1);
  (*vertices)[0].set(0, 0, 0.f );

  this->setVertexArray(vertices);

this->addPrimitiveSet( new osg::DrawArrays(GL_POINTS, 0, 1, 1000) );
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OpenGL error when using TextureBuffer

2017-05-22 Thread Glenn Waldron
When using an osg::TextureBuffer, be sure to call setTextureAttribute(...)
instead of setTextureAttributeAndModes(...).



Glenn Waldron

On Mon, May 22, 2017 at 9:40 AM, Marius Dransfeld <
marius.dransf...@gmail.com> wrote:

> Hi,
>
> I'm getting the following error when using osg::TextureBuffer (current OSG
> git):
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode
> 0x8c2a
>
> According to CodeXL this occurs because glEnable(GL_TEXTURE_BUFFER) is
> called. Looks like this is a bug in OSG?
>
> Thank you!
>
> Cheers,
> Marius
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70952#70952
>
>
>
>
>
> ___
> 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] OpenGL error when using TextureBuffer

2017-05-22 Thread Marius Dransfeld
Hi,

I'm getting the following error when using osg::TextureBuffer (current OSG git):
Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0x8c2a

According to CodeXL this occurs because glEnable(GL_TEXTURE_BUFFER) is called. 
Looks like this is a bug in OSG?

Thank you!

Cheers,
Marius

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





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