Re: [osg-users] probs running OSG on non-dev system?

2007-09-17 Thread Olaf Flebbe
Hi,

 
 Thanks for the suggestion, but now my problem wont repro, so I guess 
 that isn't the problem.
 
 But a further question, are manifests relevant to native win32 binaries, 
 or windows managed assemblies?  If the former, then that including of a 
 manifest better be captured the cmake build process somewhere.

manifests are even relevant to native win32 binaries beginning with w2k. 
You can distribute the msvcrt80.dll beneath your exe iff you provide it 
with a manifest. If you don't windows will not accept the dll. This is 
called you are distributing a private assembly.

The manifest is even more relevant for Vista: It is used for the User 
Access Control, if you need to run with admin priviledges.

Cheers
Olaf

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


Re: [osg-users] Object Array

2007-09-17 Thread Robert Osfield
On 9/17/07, Carlos Nava [EMAIL PROTECTED] wrote:
 Hi,

   I need to declare arrays of various types of objects, like transformations
 and groups, can you help me?

C++ question really:

typedef std::list osg::ref_ptrosg::Transform   TransformList;
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for use as texture

2007-09-17 Thread Robert Osfield
HI John,

Um... there really isn't much to go on to know why your app might be
crashing, a good place to start is to provide a stack trace.

Robert.

On 9/17/07, John Steinbis [EMAIL PROTECTED] wrote:
 Hi,
 I'm trying to convert an IplImage (OpenCV) type to osg::Image type for
 use as a texture within OSG. My conversion routine attempts to utilize
 setImage(...) of image class. It crashes and I havent been able to
 track down the problem.

 Does anyone have experience with a conversion like this or advise
 about building osg images from other types? Thank you!

 -- John
 ___
 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


Re: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for use as texture

2007-09-17 Thread Thomas Petit
Hi,

Just in case, Have you check the format of yours iplImage ?

Because there is  two main difference between an osg::image and an iplImage
:  the origin of a iplImage is the top left corner of the screen (down left
corner for osg) and the colors are BGR (RGB for osg).

And I also remember a similar crash when I used setImage(). Perhaps its the
same thing : the third dimension of the image must be 1 and not 0, like this
:

 osg::Image* image= new osg::Image();
 image-allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_CHAR);
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] FBO question

2007-09-17 Thread John Donovan
Igor Naigovzin wrote:
 Hello to all!
 I have a simple question.
 I want to render a two cameras (two different render surfaces) by exactly
 the same scene.

Hi Igor,
if I understand you correctly, you're doing the same sort of thing I am. I have
a few cameras rendering to the same texture.
This is the code I use:
ref_ptrGraphicsContext::Traits traits = new GraphicsContext::Traits;
traits-x = 500;
traits-y = 800;
traits-width = totalWidth;
traits-height = vpHeight;
traits-windowDecoration = true;
traits-doubleBuffer = true;
traits-sharedContext = 0;
ref_ptrGraphicsContext _gc =
GraphicsContext::createGraphicsContext(traits.get());

osgViewer::Viewer _viewer;

for (int i = 0; i  _numCameras; ++i) {
   rot.makeRotate(_startAng + (_angStep * i), 0.0, 1.0, 0.0);
   ref_ptrCamera cam = new Camera;
   cam-setViewport(new Viewport(_cameraWidth * i, 0.0, _cameraWidth,
_totalHeight));
   cam-setRenderOrder(osg::Camera::PRE_RENDER);
   cam-setGraphicsContext(_gc);
   cam-setAllowEventFocus(false);
   cam-setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);
   cam-attach(Camera::COLOR_BUFFER, _texture.get());
   cam-setDataVariance(Object::DYNAMIC);
   cam-addChild(group.get());

   _viewer.addSlave(cam.get(), Matrixd(), rot, false);
}

_viewer.getCamera()-setProjectionMatrixAsPerspective(_cameraFoVX /
_aspectRatio, _aspectRatio, 1.0, 1000.0);
_viewer.getCamera()-setViewMatrix(trans);
_viewer.getCamera()-setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
_viewer.getCamera()-setClearColor(Vec4(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX));
_viewer.setDataVariance(Object::DYNAMIC);

I'm using a floating-point texture, but it works just as well with a regular
8-bit RGB texture. Note I'm setting up the viewports for each camera. My
application is a piecewise linear approximation of a cylindrical projection.
I then set up another viewer and another scene graph to render the textured
quad to the screen, then call _both_ viewers in my render loop.

Hope this helps,
-J



__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Addition and Subtraction

2007-09-17 Thread David Callu
Hi Renan

   If it just for display your CSG operation, there are
openCSGhttp://www.opencsg.org/
   If it is for building a eometrey then display it, there are effectively
BRL CAD, or OpenCascade http://www.opencascade.org/.
   The best I found is CGAL http://www.cgal.org/ but it have a double
licence like Qt, depending if you do opensource or close source application.

HTH
David

2007/9/16, Renan Mendes [EMAIL PROTECTED]:

 I'll check into that. Thanks, both of you.

 Renan M Z Mendes

 ___
 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] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
Hi,
 first I would like to reask the question I sent few days ago since it might 
have been overlooked so here it is:

Hello,
 in the osg examples there are several examples of how to use RTT.
I would like to concatenate several renderings. I mean, render the scene to 
texture1, then use texture1 to create texture2, then use texture1  texture2 to 
create texture3 and so on.

I don't understand how to control the order of the rendering. I tried to change 
the rendering order number of the camera's I used in PRE_RENDER and it didn't 
seem to have any effect. The results seems fine, but I don't know if it used 
the data in the texture from the current frame or the previous.

(in the example I made to check this ability, I render the cow to texture, then 
using PRE_REND
ER  shader I remove the red plane and later I remove the green plane, changing 
the order should result in different images)

this brings me to the next question. I tried to clear the texture used to 
render the Scene to. I tried setting the texture image to new allocated image, 
dirty the texture parameters and dirty the texture object and nothing seems to 
have the required result. dirty the texture object results as blank screen, the 
other operation doesn't seem to clear the texture since changing the order in 
the multipass didn't change the results.

another problem I had was to render in different passes to the same texture. 
(Even if it was in the POST_RENDER sub tree). is there a way to reuse the same 
texture in different passes?

the last problem I encountered is that I rendered the resulting textures, using 
several cameras NESTED_RENDER each drawing a square with different texture 
attached 2 it and each camera has different viewport. The problem is the is the 
cameras viewport intersected, I couldn't change the order they are rendered (to 
make one of them on top of the other). I tried setting the RenderDetaill with 
higher and lower numbers, both for the Camera and for the Geodes, with no 
success.

any ideas concerning any of the problems would be appriciated.

thanks,
  Guy.

second, I want to render single or several (4 - 8) values which represnt some 
calculation. So I use render to texture. The texture is 1D and to render to it 
I use orthographic projection, and the viewport fits to the texture dimension. 
The geometry I render is points. One point per calculation, and each point 
should result as one pixel. Is this the right way? I has to set the point size 
to 1.5 to see anything, any ideas why?

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


Re: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for useas texture

2007-09-17 Thread Poirier, Guillaume

Hi John,

I wrote a osgImage2IplImage, not sure if it could help you, but here it is:

/*! Image conversion functions
Utility functions to convert between different image representations */
IplImage* osgImage2IplImage(const osg::Image p_osgImage)
{
  const unsigned char *buffer = p_osgImage.data();
  
  IplImage* pImg = cvCreateImage(cvSize(p_osgImage.s(), p_osgImage.t()), 
IPL_DEPTH_8U, p_osgImage.r() );
  
  if(p_osgImage.r() == 3)
  {
struct pixelStruct { unsigned char r, g, b; };
struct pixelStruct* pPixel = ( struct pixelStruct * ) ( buffer );
struct pixelStruct* pCurrentPixel = NULL;
for(int x = 0; x  p_osgImage.s(); x++ ) {
  for(int y = 0; y  p_osgImage.t(); y++ ) { 
pCurrentPixel = pPixel[ y * p_osgImage.s() + x ]; 
int invertedY = p_osgImage.t()-1-y;
// blue
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3] = 
pCurrentPixel-b;
// green
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+1] = 
pCurrentPixel-g;
// red
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+2] = 
pCurrentPixel-r;
  }
}
  }
  else if(p_osgImage.r() == 4)
  {
struct pixelStruct { unsigned char r, g, b, a; };
struct pixelStruct* pPixel = ( struct pixelStruct * ) ( buffer );
struct pixelStruct* pCurrentPixel = NULL;
for(int x = 0; x  p_osgImage.s(); x++ ) {
  for(int y = 0; y  p_osgImage.t(); y++ ) { 
pCurrentPixel = pPixel[ y * p_osgImage.s() + x ]; 
int invertedY = p_osgImage.t()-1-y;
// alpha
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3] = 
pCurrentPixel-a;
// blue
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+1] = 
pCurrentPixel-b;
// green
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+2] = 
pCurrentPixel-g;
// red
((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+3] = 
pCurrentPixel-r;
  }
} 
  }
  else
  {
osg::notify(osg::NOTICE)osgImage2IplImage: Error, unrecognized image 
depth.std::endl;
  }
  
  return pImg;
}



bill


-Original Message-
From: [EMAIL PROTECTED] on behalf of John Steinbis
Sent: Sun 9/16/2007 9:23 PM
To: OpenSceneGraph Users
Subject: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for useas 
texture
 
Hi,
I'm trying to convert an IplImage (OpenCV) type to osg::Image type for
use as a texture within OSG. My conversion routine attempts to utilize
setImage(...) of image class. It crashes and I havent been able to
track down the problem.

Does anyone have experience with a conversion like this or advise
about building osg images from other types? Thank you!

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

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


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
thanks, I'll try that.

more problems I'm facing is setting the image internal data type, I've seen
in the examples setting the internal type to 3 or 4. what does it mean? how
do I set it to float or int?
and I couldn't read from the image even that I used code very similar to
osgprerender example :(, the image-data() return buffer filled with
garbage.

but thanks anyway,
 Guy.
- Original Message -
From: John Donovan [EMAIL PROTECTED]
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Sent: Monday, September 17, 2007 3:43 PM
Subject: Re: [osg-users] multipass  calculating with shaders


 [EMAIL PROTECTED] wrote:

  second, I want to render single or several (4 - 8) values which represnt
some calculation. So I use render to texture. The texture is 1D and to
render to it I use orthographic projection, and the viewport fits to the
texture dimension. The geometry I render is points. One point per
calculation, and each point should result as one pixel. Is this the right
way? I has to set the point size to 1.5 to see anything, any ideas why?

 It sounds like you need to offset your point centres by 0.5 I don't have
the
 spec in front of me, but I think you've got to shift it in the positive
 direction on both axes, but you may have to play with the signs until it
works :)

 -J



 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __
 ___
 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


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread John Donovan
[EMAIL PROTECTED] wrote:
 thanks, I'll try that.
 
 more problems I'm facing is setting the image internal data type, I've seen
 in the examples setting the internal type to 3 or 4. what does it mean? how
 do I set it to float or int?

I use the following code for rendering to a floating-point texture:
_texture = new Texture2D;
_texture-setResizeNonPowerOfTwoHint(false);
_texture-setTextureSize(_totalWidth, _totalHeight);
_texture-setSourceType(GL_FLOAT);
_texture-setSourceFormat(GL_RGB);
_texture-setInternalFormat(GL_RGB32F_ARB);
_texture-setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST);
_texture-setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST);


 and I couldn't read from the image even that I used code very similar to
 osgprerender example :(, the image-data() return buffer filled with
 garbage.

If I understand it correctly, the Image associated with a Texture is used for
uploading the data into the texture. If you want to read from the texture,
you'll need to copy it to a buffer. I can't remember how to do that off-hand,
but it'll likely be fairly slow.

-J


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Background image texture rescaling problem

2007-09-17 Thread Eric Sokolowsky
Robert Osfield wrote:
 Hi John,
 
 On 9/15/07, John Steinbis [EMAIL PROTECTED] wrote:
 Thanks Robert,
 I have this working now without rescaling the image. My solution was
 to pad the image with zeros making it a power of two and then specify
 the correct percentage of the image to use as 2D texture. Not sure if
 this is the best solution but it works and is fast enough for me.
 
 This is not an elegant way to tackle the problem, workable yes, but
 I'd recommend spending a little time - readying up about
 TextureRectangle or just disabling the resize of non power of two
 textures, you'll end up with a more efficient and elegant solution.

I've used two of these methods to avoid the resizing penalty. The first 
was to use John's solution to create power-of-two images and only fill 
it with a subimage that is actually used. I then use the texture matrix 
to change the texture coordinates so no recoding is necessary. This has 
worked very well for my application. The second method was to use the 
TextureRectangle solution, but there are a few drawbacks to this method: 
it may not be hardware-accelerated, especially on older cards; you lose 
the ability to generate mipmapped textures; and your texture coordinates 
become non-normalized, so that you have to know the size of the image 
when you set up your scene if you do anything fancy.

Texture Rectangles are useful but are not the ultimate solution to all 
problems.

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


[osg-users] release and flush GL Objects?

2007-09-17 Thread Rafa Gaitan
Hi Robert,

We are using the osgViewer::Viewer to integrate our app with
Java using jogl to create a GL context and
GraphicsWindowEmbedded class. In the past using the
SimpleViewer we had the call releaseAllGLObjects(),
which internally calls to sceneView-releaseAllGLObjects()
and some more stuff.

Is there any similar call inside osgViewer::Viewer?, with jogl
there is an special Panel that use internally pbuffers to create
the context, but when we resize the component the context is
lost, so calling releaseGLObjects did the trick for us, but now
I don't find a good way to get the same things working.

I tried with viewer-getCamera()-releaseGLObjects(); but doesn't
work. Maybe adding a releaseAllGLObjects method in View, or
in Viewer is a good place. thoughts?

Rafa.


-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial  http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] release and flush GL Objects?

2007-09-17 Thread Robert Osfield
Hi Rafa,

I'm not 100% sure it will work but try:

 viewer-getSceneData()-releaseAllGLObjects();

Robert.

On 9/17/07, Rafa Gaitan [EMAIL PROTECTED] wrote:
 Hi Robert,

 We are using the osgViewer::Viewer to integrate our app with
 Java using jogl to create a GL context and
 GraphicsWindowEmbedded class. In the past using the
 SimpleViewer we had the call releaseAllGLObjects(),
 which internally calls to sceneView-releaseAllGLObjects()
 and some more stuff.

 Is there any similar call inside osgViewer::Viewer?, with jogl
 there is an special Panel that use internally pbuffers to create
 the context, but when we resize the component the context is
 lost, so calling releaseGLObjects did the trick for us, but now
 I don't find a good way to get the same things working.

 I tried with viewer-getCamera()-releaseGLObjects(); but
 doesn't
 work. Maybe adding a releaseAllGLObjects method in View, or
 in Viewer is a good place. thoughts?

 Rafa.


 --
 Rafael Gaitán Linares
 Instituto de Automática e Informática Industrial   http://www.ai2.upv.es
 Ciudad Politécnica de la Innovación
 Universidad Politécnica de Valencia
 ___
 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


Re: [osg-users] release and flush GL Objects?

2007-09-17 Thread Rafa Gaitan
Hi Robert,

On 9/17/07, Robert Osfield [EMAIL PROTECTED] wrote:

 Hi Rafa,

 I'm not 100% sure it will work but try:

 viewer-getSceneData()-releaseAllGLObjects();


Node doesn't have a releaseAllGLObjects, and trying with
releaseGLObjects, doesn't work as I expect. Maybe I'm using
a bad approach to the problem! :(.

releaseAllGLObjects method is only inside SceneView class
which is not easily accessible in the osgViewer::Viewer.

Thanks,
Rafa.

Robert.

 On 9/17/07, Rafa Gaitan [EMAIL PROTECTED] wrote:
  Hi Robert,
 
  We are using the osgViewer::Viewer to integrate our app with
  Java using jogl to create a GL context and
  GraphicsWindowEmbedded class. In the past using the
  SimpleViewer we had the call releaseAllGLObjects(),
  which internally calls to sceneView-releaseAllGLObjects()
  and some more stuff.
 
  Is there any similar call inside osgViewer::Viewer?, with jogl
  there is an special Panel that use internally pbuffers to create
  the context, but when we resize the component the context is
  lost, so calling releaseGLObjects did the trick for us, but now
  I don't find a good way to get the same things working.
 
  I tried with viewer-getCamera()-releaseGLObjects(); but
  doesn't
  work. Maybe adding a releaseAllGLObjects method in View, or
  in Viewer is a good place. thoughts?
 
  Rafa.
 
 
  --
  Rafael Gaitán Linares
  Instituto de Automática e Informática Industrial   http://www.ai2.upv.es
  Ciudad Politécnica de la Innovación
  Universidad Politécnica de Valencia
  ___
  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




-- 
Rafael Gaitán Linares
Instituto de Automática e Informática Industrial  http://www.ai2.upv.es
Ciudad Politécnica de la Innovación
Universidad Politécnica de Valencia
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] release and flush GL Objects?

2007-09-17 Thread Robert Osfield
HI Rafa,

On 9/17/07, Rafa Gaitan [EMAIL PROTECTED] wrote:
 Node doesn't have a releaseAllGLObjects, and trying with
 releaseGLObjects, doesn't work as I expect. Maybe I'm using
 a bad approach to the problem! :(.

Sorry,

  viewer-releaseGLObjects();

Is the call I was thinking of.

 releaseAllGLObjects method is only inside SceneView class
 which is not easily accessible in the osgViewer::Viewer.

You get get the SceneView via the Renderer object which is attached
the Camera in 2.1.x.

However, you shouldn't need it.

All SceneView::releaseAllGLobjects() does is:

void SceneView::releaseAllGLObjects()
{
if (!_camera) return;

_camera-releaseGLObjects(_renderInfo.getState());

// we need to reset State as it keeps handles to Program objects.
if (_renderInfo.getState()) _renderInfo.getState()-reset();
}

And all SceneView::flushAllDeletedGLObjects() does is:

void SceneView::flushAllDeletedGLObjects()
{
_requiresFlush = false;

osg::flushAllDeletedGLObjects(getState()-getContextID());
}

So you could try:

viewer.getSceneData()-releaseGLObjects(); // or getCamera()...
viewer.getCamera()-getGraphicsContext()-getState()-reset();
osg::flushAllDeletedGLObjects(0);
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for useas texture

2007-09-17 Thread John Steinbis
Thank you everyone for replies to my problem...
Bill's code was instructive by showing that the basic idea behind what
I was trying to do was correct. My old method (and Bill's) would
attempt to perform a deep copy. In this method, I'd simply forgotten
to initialize something before using it. Sorry! My new method performs
a shallow copy and is working now, with very little code required.
I've posted it below.

-- John


osg::Image* Convert_OpenCV_TO_OSG_IMAGE(IplImage* cvImg)
{

if(cvImg-nChannels == 3)
{
// Flip image from top-left to bottom-left origin
if(cvImg-origin == 0) {
cvConvertImage(cvImg , cvImg, CV_CVTIMG_FLIP);
cvImg-origin = 1;
}

// Convert from BGR to RGB color format
//printf(Color format %s\n,cvImg-colorModel);
cvCvtColor( cvImg, cvImg, CV_BGR2RGB );

osg::Image* osgImg = new osg::Image();

osgImg-setImage(
cvImg-width, //s
cvImg-height, //t
3, //r
3, //GLint internalTextureformat, (GL_LINE_STRIP, 
0x0003)
6407, // GLenum pixelFormat, (GL_RGB, 0x1907)
5121, // GLenum type, (GL_UNSIGNED_BYTE, 0x1401)
(BYTE*)(cvImg-imageData), // unsigned char* data
osg::Image::AllocationMode::NO_DELETE // AllocationMode 
mode (shallow copy)
);//int packing=1); (???)

//printf(Conversion completed\n);
return osgImg;
}
else {
printf(Unrecognized image type);
return 0;
}

}




On 9/17/07, Poirier, Guillaume [EMAIL PROTECTED] wrote:

 Hi John,

 I wrote a osgImage2IplImage, not sure if it could help you, but here it is:

 /*! Image conversion functions
 Utility functions to convert between different image representations */
 IplImage* osgImage2IplImage(const osg::Image p_osgImage)
 {
   const unsigned char *buffer = p_osgImage.data();

   IplImage* pImg = cvCreateImage(cvSize(p_osgImage.s(), p_osgImage.t()), 
 IPL_DEPTH_8U, p_osgImage.r() );

   if(p_osgImage.r() == 3)
   {
 struct pixelStruct { unsigned char r, g, b; };
 struct pixelStruct* pPixel = ( struct pixelStruct * ) ( buffer );
 struct pixelStruct* pCurrentPixel = NULL;
 for(int x = 0; x  p_osgImage.s(); x++ ) {
   for(int y = 0; y  p_osgImage.t(); y++ ) {
 pCurrentPixel = pPixel[ y * p_osgImage.s() + x ];
 int invertedY = p_osgImage.t()-1-y;
 // blue
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3] = 
 pCurrentPixel-b;
 // green
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+1] = 
 pCurrentPixel-g;
 // red
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+2] = 
 pCurrentPixel-r;
   }
 }
   }
   else if(p_osgImage.r() == 4)
   {
 struct pixelStruct { unsigned char r, g, b, a; };
 struct pixelStruct* pPixel = ( struct pixelStruct * ) ( buffer );
 struct pixelStruct* pCurrentPixel = NULL;
 for(int x = 0; x  p_osgImage.s(); x++ ) {
   for(int y = 0; y  p_osgImage.t(); y++ ) {
 pCurrentPixel = pPixel[ y * p_osgImage.s() + x ];
 int invertedY = p_osgImage.t()-1-y;
 // alpha
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3] = 
 pCurrentPixel-a;
 // blue
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+1] = 
 pCurrentPixel-b;
 // green
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+2] = 
 pCurrentPixel-g;
 // red
 ((uchar*)(pImg-imageData + pImg-widthStep*invertedY))[x*3+3] = 
 pCurrentPixel-r;
   }
 }
   }
   else
   {
 osg::notify(osg::NOTICE)osgImage2IplImage: Error, unrecognized image 
 depth.std::endl;
   }

   return pImg;
 }



 bill


 -Original Message-
 From: [EMAIL PROTECTED] on behalf of John Steinbis
 Sent: Sun 9/16/2007 9:23 PM
 To: OpenSceneGraph Users
 Subject: [osg-users] Convertion to osg::Image from IplImage (OpenCV) for 
 useas texture

 Hi,
 I'm trying to convert an IplImage (OpenCV) type to osg::Image type for
 use as a texture within OSG. My conversion routine attempts to utilize
 setImage(...) of image class. It crashes and I havent been able to
 track down the problem.

 Does anyone have experience with a conversion like this or advise
 about building osg images from other types? Thank you!

 -- John
 ___
 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




Re: [osg-users] release and flush GL Objects?

2007-09-17 Thread Robert Osfield
On 9/17/07, Rafa Gaitan [EMAIL PROTECTED] wrote:
  viewer.getSceneData()-releaseGLObjects(); // or getCamera()...
 
 viewer.getCamera()-getGraphicsContext()-getState()-reset();
  osg::flushAllDeletedGLObjects(0);


 Yes, This works better, Thank You!, there is some issues with
 PagedLOD nodes, so I need to debug more and see how to solve
 them.

It might well be the database pager has objects still held into its
internal lists but not just merged.

Once you get to the bottom of it we could possibly wrap up all that is
required in a clean up method in
osgViewer::Viewer/CompositeViewer/GraphicsWindowEmbedded.

BTW, could you try removing the original GraphicsWindowEmbedded and
replace it with new one as this is effectively you are doing -
changing the graphics context from underneath the viewer.

Robert.

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


Re: [osg-users] multipass calculating with shaders

2007-09-17 Thread [EMAIL PROTECTED]
thank Jhon.

I want to read the buffer from the texture only for debug purposes. In the
final program I won't do it. I need to  associate image with the texture to
set it's initial values, and later some passes in the multipass sequences
are updating this data. The problem is that after associating image with the
texture, I think the image reads automatically the texture buffer (take the
osgprerender example for instance, there is an image and in the post render
they play with it's buffer, which means the image read the current texture),
and this might slow down the program.

Another thing is as I mentioned earlier: I need to set the initial values of
the texture, and the only way I know how to do it is using images, so the
question is how do I set images internal type, pixel type and gltype, to be
float, long, etc... (unsigned char appears in the examples).

btw, I offset the point by half and it worked for one pass that renders
about 3 pixels. it didn't work for other pass that renders 1 pixel. is there
a problem when the viewport is 1x1?

thanks a lot,
 Guy.
- Original Message -
From: John Donovan [EMAIL PROTECTED]
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Sent: Monday, September 17, 2007 4:54 PM
Subject: Re: [osg-users] multipass  calculating with shaders


 [EMAIL PROTECTED] wrote:
  thanks, I'll try that.
 
  more problems I'm facing is setting the image internal data type, I've
seen
  in the examples setting the internal type to 3 or 4. what does it mean?
how
  do I set it to float or int?

 I use the following code for rendering to a floating-point texture:
 _texture = new Texture2D;
 _texture-setResizeNonPowerOfTwoHint(false);
 _texture-setTextureSize(_totalWidth, _totalHeight);
 _texture-setSourceType(GL_FLOAT);
 _texture-setSourceFormat(GL_RGB);
 _texture-setInternalFormat(GL_RGB32F_ARB);
 _texture-setFilter(Texture2D::MIN_FILTER, Texture2D::NEAREST);
 _texture-setFilter(Texture2D::MAG_FILTER, Texture2D::NEAREST);


  and I couldn't read from the image even that I used code very similar to
  osgprerender example :(, the image-data() return buffer filled with
  garbage.

 If I understand it correctly, the Image associated with a Texture is used
for
 uploading the data into the texture. If you want to read from the texture,
 you'll need to copy it to a buffer. I can't remember how to do that
off-hand,
 but it'll likely be fairly slow.

 -J


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __
 ___
 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