Re: [osg-users] osg::Image with signed int

2009-08-07 Thread Pau Moreno
Hi J.P.,

Finally I can figure out a way so I don't need the signed int. Anyway, I think 
my really problem is that by some reason, the texture is not uploading 
correctly to the GPU :S

In my OGL code I have:


Code:
glGenTextures(1, (this-triTableTex));
glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, this-triTableTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA16I_EXT, 16, 256, 0, 
GL_ALPHA_INTEGER_EXT, GL_INT, triTable);



and in osg I do:


Code:
osg::Texture2D *tex = new osg::Texture2D();

tex-setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST );
tex-setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST );
tex-setWrap( osg::Texture2D::WRAP_S , osg::Texture2D::CLAMP_TO_EDGE );
tex-setWrap( osg::Texture2D::WRAP_T , osg::Texture2D::CLAMP_TO_EDGE );
tex-setWrap( osg::Texture2D::WRAP_R , osg::Texture2D::CLAMP_TO_EDGE );
//tex-setDataVariance( osg::Object::DYNAMIC );

unsigned char *cc = new unsigned char[256*16];

for ( int i = 0 ; i  256 ; i++)
for ( int ii = 0 ; ii  16 ; ii++)
{
//cc[ ii + i*16 ] = triTable[i][ii];
cc[ ii + i*16 ] = 127;
}


osg::Image *i = new osg::Image();
i-setImage( 16 , 256 , 0 , GL_ALPHA16I_EXT , GL_ALPHA_INTEGER_EXT , 
GL_INT , (unsigned char *)triTable , osg::Image::NO_DELETE );

tex-setImage( i );
brickState-setTextureAttributeAndModes(1,tex,osg::StateAttribute::ON);



I'm just setting all the values to 127 so I can check in the GPU if the texture 
is uploaded to the geometry shader. I need this values to work in the GPU, as 
I'm using it for an Marching Cubes Algorithm based.

Do you think I need to do something else? Thanks!

Cheers,
Pau[/code]

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-07 Thread Pau Moreno
Hi,

Thanks Ulrich, but I think this set one parameter for each vertex, and I really 
need 32 values for each vertex (that's what I'm using multitexcoord) Finally I 
think I have this problem solved, I had some problems with the glew 
initialization. Now I'm having other problems uploading a texture to the GPU :P

Thank you!

Cheers,
Pau

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





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


Re: [osg-users] osg::Image with signed int

2009-08-07 Thread Pau Moreno
Hi,

I'm sorry about that, but the texture upload it wasn't the problem. That's the 
problem working in the GPU, something is wrong but you don't have a way to 
determine what's wrong :P The problem was that in the GPU i had a vec3 array of 
8 values, and I was setting it like 

Code:

osg::Uniform* vtxDecal0U = new osg::Uniform(vertDecals[0], osg::Vec3f( 0.0f   
 , 0.0f , 0.0f  
) );


...

which goes ok in OGL, but seems to not work ok with osg, the value was not set. 
I work now with 8 diferents variables, but if anyone know how to solve it, it 
would be great :)


Thank you!

Cheers,
Pau

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-06 Thread Pau Moreno
Hi,

I saw this mistake before and I correct it but I'm still having the same error. 
With all the shaders :S Any idea?

Thank you!

Cheers,
Pau

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-06 Thread Pau Moreno
Ok, I finally can solve it with this function:

loadShaderSourceFromFile(...)

No I'm not having errors of compiling shaders, and executing it. Returning to 
the topic of this post: If I comment the MultitexCoord line, nothing is showing 
in the viewer, but that's logic. The problem if is it uncommented ( I need 
theis function so I can pass my parameters to the shader in each vertex I have) 
the application crashes, and I got a Warning:

Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,)

Any Ideas? Thanksss!!

Cheers,
Pau

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





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


[osg-users] osg::Image with signed int

2009-08-06 Thread Pau Moreno
Hi,

I've create an int matrix[16][256] and I need to pass it to the GPU. So what 
I've done is create a osg::Image, but when I have to pass the data to setImage, 
I have to do a cast to my data, because it needs an unsigned char *.

My matrix contains signed ints so I cannot cast it to a unsigned char, as I 
loose information. How can I do it?

Thanks!

Cheers,
Pau

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-05 Thread Pau Moreno
Hi,

Since I know, OSG doesn't have support for geometry shaders, does it? I'll 
check it again.

Thank you!

Cheers,
Pau

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-05 Thread Pau Moreno
Hi,

Ok, I've decided to follow your idea and do it with the osg shaders but I'm 
getting the next error


Code:
FRAGMENT glCompileShader  FAILED
FRAGMENT Shader  infolog:
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom

VERTEX glCompileShader  FAILED
VERTEX Shader  infolog:
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom

GEOMETRY glCompileShader  FAILED
GEOMETRY Shader  infolog:
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom

glLinkProgram  FAILED
Program  infolog:
Vertex info
---
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom

Geometry info
-
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom

Fragment info
-
(0) : error C: syntax error, unexpected $end at token EOF
(0) : error C0501: type name expected at token null atom




Here I have where I initialize the shader:


Code:
osg::StateSet* brickState = node-getOrCreateStateSet();

osg::Program* brickProgramObject= new osg::Program;
osg::Shader* brickVertexObject  = new osg::Shader( 
osg::Shader::VERTEX );
osg::Shader* brickFragmentObject= new osg::Shader( 
osg::Shader::FRAGMENT );
osg::Shader* brickGeometryObject= new osg::Shader( 
osg::Shader::GEOMETRY );

brickProgramObject-addShader( brickFragmentObject );
brickProgramObject-addShader( brickVertexObject   );
brickProgramObject-addShader( brickGeometryObject );

brickVertexObject-readShaderFile  ( osg::Shader::VERTEX   , 
/home/Pau/OSG/Test1/Debug/Shaders/TestG80_VS.glsl );
brickFragmentObject-readShaderFile( osg::Shader::FRAGMENT , 
/home/Pau/OSG/Test1/Debug/Shaders/TestG80_GS2.glsl );
brickGeometryObject-readShaderFile( osg::Shader::GEOMETRY , 
/home/Pau/OSG/Test1/Debug/Shaders/TestG80_FS.glsl );

brickProgramObject-setParameter( GL_GEOMETRY_INPUT_TYPE_EXT   , 
GL_POINTS );
brickProgramObject-setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT  , 
GL_TRIANGLE_STRIP );
brickProgramObject-setParameter( GL_GEOMETRY_VERTICES_OUT_EXT , 16 );


glGenTextures(1, triTableTex );
glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, triTableTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA16I_EXT, 16, 256, 0, 
GL_ALPHA_INTEGER_EXT, GL_INT, triTable);

float isolevel = 0.2;
osg::Uniform* triTableU = new osg::Uniform(triTableTex, 0 );
osg::Uniform* isolevelU = new osg::Uniform(isolevel, isolevel );

osg::Uniform* vtxDecal0U = new osg::Uniform(vertDecals[0], 
osg::Vec3f( 0.0f, 0.0f , 0.0f   
   ) );
osg::Uniform* vtxDecal1U = new osg::Uniform(vertDecals[1], 
osg::Vec3f( this-m_vStep.x , 0.0f , 0.0f   
   ) );
osg::Uniform* vtxDecal2U = new osg::Uniform(vertDecals[2], 
osg::Vec3f( this-m_vStep.x , this-m_vStep.y  , 0.0f   
   ) );
osg::Uniform* vtxDecal3U = new osg::Uniform(vertDecals[3], 
osg::Vec3f( 0.0f, this-m_vStep.y  , 0.0f   
   ) );
osg::Uniform* vtxDecal4U = new osg::Uniform(vertDecals[4], 
osg::Vec3f( 0.0f, 0.0f , 
this-m_vStep.z   ) );
osg::Uniform* vtxDecal5U = new osg::Uniform(vertDecals[5], 
osg::Vec3f( this-m_vStep.x , 0.0f , this-m_vStep.z
   ) );
osg::Uniform* vtxDecal6U = new osg::Uniform(vertDecals[6], 
osg::Vec3f( this-m_vStep.x , this-m_vStep.y  , this-m_vStep.z   ) );
osg::Uniform* vtxDecal7U = new osg::Uniform(vertDecals[7], 
osg::Vec3f( 0.0f, this-m_vStep.y  , this-m_vStep.z
   ) );

brickState-addUniform( triTableU );
brickState-addUniform( isolevelU );
brickState-addUniform( vtxDecal0U );
brickState-addUniform( vtxDecal1U );
brickState-addUniform( vtxDecal2U );
brickState-addUniform( vtxDecal3U );
brickState-addUniform( vtxDecal4U );
brickState-addUniform( vtxDecal5U );
brickState-addUniform( vtxDecal6U );
brickState-addUniform( vtxDecal7U );

brickState-setAttributeAndModes( 

[osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-04 Thread Pau Moreno
Hi,

I'm trying to use multitexture in a class that inherit from Drawable. I use 
glMultiTexCoord4f inside of the drawImplementation, because I need this 
function to work with this parameters I have in a geomtryShader, but by some 
reason a get  a Segmentation Fault while I'm using it... Shall I have to 
activate something? I've read something about activate the texture in the 
StateSet, but I don't know what exactly do...


Thank you!

Cheers,
Pau

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





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


Re: [osg-users] glMultiTexCoord4f , OSG with OGL code

2009-08-04 Thread Pau Moreno
Hi,

I've realized that the problem is that I'm losing the graphics context. I'm 
having the same problem with the inicialization of a shader, and it crashes 
here before the glMultiTexCoord4f(), so I think if I solve the problem with the 
shader this maybe solves my first issue.
My problem is that I have to work with a geometry shader, so I have to do all 
the initializations in OGL. I finally found a solution to initialize glew doing 
viewer.setRealizeOperation( ... ); but when I do viewer.realize, seems that I 
loose the Graphics Context again. I want to initialize my shader 
(glCreateProgramObjectARB) in a diferent place than where I do glewInit... how 
I can do that?

Thank you!

Cheers,
Pau

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





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


Re: [osg-users] Transformations

2009-07-23 Thread Pau Moreno
Hi,

It was the loading of the rotation Matrix, the Y-up Rotation just rotates 90 
degrees on the wrong axis, but the animation was still working OK :)

Pau

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





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


Re: [osg-users] Transformations

2009-07-21 Thread Pau Moreno
Hi,

Thank you very much Ulrich!! It works! I don't know why the other things I've 
tried didn't work but now is working!!!

Thank you!

Cheers,
Pau

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





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


Re: [osg-users] Transformations

2009-07-18 Thread Pau Moreno
Hi Ümit,

I try to use osg::Switch to insert all the data I have in the files( each file 
in a separate node with his own transform matrix ), so I can switch the nodes 
in each frame, but I don't know why it seems that the second and following data 
I insert accumulates the previous matrix transformation, and I don't want this. 
I write it seems because I cannot be sure about that, my models are doing 
some strange movements that are not correctly. I also have a sphere attached to 
the root node after I attach the switch node, and it seems to be also afected 
by the previous transformation... Althought, that's not my biggest problem, I 
can just fix it by adding and deleting one by one the nodes to the root node.

My problem is that the transformation I apply in OGL is not the same as in OSG, 
and I need the same transformation. So the gridOrientation is a Matrix3x3 wich 
contains the rotation in the object. , that's why I'm adding some more values. 
My matrix rotation in OGL is like that:

gridOrientation.set(0,0,rotation.get(0,0));
gridOrientation.set(0,1,rotation.get(1,0));
gridOrientation.set(0,2,rotation.get(2,0));
gridOrientation.set(0,3,0.0f);
gridOrientation.set(1,0,rotation.get(0,1));
gridOrientation.set(1,1,rotation.get(1,1));
gridOrientation.set(1,2,rotation.get(2,1));
gridOrientation.set(1,3,0.0f);
gridOrientation.set(2,0,rotation.get(0,2));
gridOrientation.set(2,1,rotation.get(1,2));
gridOrientation.set(2,2,rotation.get(2,2));
gridOrientation.set(2,3,0.0f);
gridOrientation.set(3,0,0.0f);
gridOrientation.set(3,1,0.0f);
gridOrientation.set(3,2,0.0f);
gridOrientation.set(3,3,1.0f);

As I can understand about the precedence of OGL and OSG, if I do translate and 
then rotate in ogl, I have to do rotate * translate in OSG Otherwise, I've 
tried both combinations, and no one is working... :S

Cheers,

Pau.

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





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


[osg-users] Transformations

2009-07-17 Thread Pau Moreno Font
 Hi,

I'm trying to change my OGL code to OSG but I'm having really problems with
the transformations... I have 174 data files that each contains a cloud of
points, a vector3 with the translartion, and the matrix of rotation of each
cloud. So in OGL, i just do:

{
LoadFile( x++)  //Loads a diferent file in each
iteration
glPushMatrix();
  glTranslate( x , y , z )
  glMultMatrixf( rotation );

  glBegin( GL_POINTS )

  glEnd();
glPopMatrix();
}


So in OSG first of all I try to do it with a osg::Switch but seems that
this node accumulate the transformations... is that right?? So what I
finally do is to attach a diferent node in  each iteration and detach the
previous one. But the real problem is that OSG is not doing the same as OGL.
I do this for each node:

{
  osg::Matrixf rotation;
  osg::Matrixf translation;
  osg::Matrixf result;

  rotation.set(   gridOrientation.get( 0 , 0 ) , gridOrientation.get( 0 , 1
) , gridOrientation.get( 0 , 2 ) , 0.0,
  gridOrientation.get( 1 , 0 ) , gridOrientation.get( 1
, 1 ) , gridOrientation.get( 1 , 2 ) , 0.0,
  gridOrientation.get( 2 , 0 ) , gridOrientation.get( 2
, 1 ) , gridOrientation.get( 2 , 2 ) , 0.0,
  0.0f , 0.0f , 0.0f , 1.0f );
  translation.setTrans(  x , y , z );

  result = rotation * translation;

  osg::MatrixTransform *transformation = new osg::MatrixTransform();

  transformation-addChild( gNode );
  transformation-setMatrix( result );
}


rotationOGL.makeRotate( osg::DegreesToRadians(90.0) , osg::Vec3d( 0.0 , 1.0
, 0.0 ));
transformationOGL-setMatrix(rotationOGL);
transformationOGL-addChild(m_root);
m_vViewer.setSceneData( transformationOGL );

m_root-addChild( transformation );

.


What I'm doing wrong? I've tried a lot of combinations of creating rotation
, translation, result, but no one is the correct!! I think I'm doing
something wrong I cannot apreciate.


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