Re: [osg-users] [build] error compiling the stable version

2014-04-24 Thread Sajjadul Islam
Hi,

I did not find any option inside the cmake-gui


Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] [build] error compiling the stable version

2014-04-20 Thread Sajjadul Islam
Hi,

How to disable the plugin from within the cmake ?

I did not find any opetion to do it


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] [build] error compiling the stable version

2014-04-19 Thread Sajjadul Islam
Hi forum,

I am trying to compile the recent stable version from source on ubuntu 12.04 
and i am having the following compilation error:


Code:

[ 85%] Built target osgdb_qfont
[ 86%] Built target osgdb_zip
[ 86%] Building CXX object 
src/osgPlugins/svg/CMakeFiles/osgdb_svg.dir/ReaderWriterSVG.o
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:
 In member function ‘osg::Image* ReaderWriterSVG::createImage(RsvgHandle*, 
unsigned int, unsigned int) const’:
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:96:17:
 error: ‘cairo_surface_t’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:96:34:
 error: ‘cairo_surface’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:97:41:
 error: ‘CAIRO_FORMAT_ARGB32’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:97:103:
 error: ‘cairo_image_surface_create_for_data’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:98:17:
 error: ‘cairo_t’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:98:26:
 error: ‘cr’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:98:57:
 error: ‘cairo_create’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:99:104:
 error: ‘cairo_scale’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:100:52:
 error: ‘rsvg_handle_render_cairo’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:102:33:
 error: ‘cairo_destroy’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/OpenSceneGraphStable/OpenSceneGraph-3.2.1-rc2/src/osgPlugins/svg/ReaderWriterSVG.cpp:103:52:
 error: ‘cairo_surface_destroy’ was not declared in this scope
make[2]: *** [src/osgPlugins/svg/CMakeFiles/osgdb_svg.dir/ReaderWriterSVG.o] 
Error 1
make[1]: *** [src/osgPlugins/svg/CMakeFiles/osgdb_svg.dir/all] Error 2
make: *** [all] Error 2





Any hint to get rid of this?


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] texture completeness

2014-01-14 Thread Sajjadul Islam
Hi,

I am creating an empty texture object as follows:


Code:

osg::ref_ptr osgCuda::Texture2D  trgTexture = new osgCuda::Texture2D;  
trgTexture-setName( Target Texture );
trgTexture-addIdentifier( TRG_BUFFER );
// Note: GL_RGBA8 Bit format is not yet supported by CUDA, use 
GL_RGBA8UI_EXT instead.
// GL_RGBA8UI_EXT requires the additional work of scaling the fragment 
shader
// output from 0-1 to 0-255.
trgTexture-setInternalFormat( GL_RGBA32F_ARB );
trgTexture-setSourceFormat( GL_RGBA );
trgTexture-setSourceType( GL_FLOAT );
// in case you choose a texture size which is not a multiple of the 
alignment restriction CUDA 
// will allocate more memory to fulfill the alignemnt requirements. To get 
the
// actual pitch (bytes of a single row) call osgCompute::Memory::getPitch()
trgTexture-setTextureWidth( srcImage-s());
trgTexture-setTextureHeight( srcImage-t() );




Source image's width and height is assigned, but not the image data itself, 
because there is no data yet. So the texture is empty. Is there any way to make 
sure that the texture is complete or not ?

One more thing  - is there any way within osg to initialize the texture with 
the zero value ?

Cheers,
Sajjadul

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





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


Re: [osg-users] OpenCL and OSG interop

2013-10-19 Thread Sajjadul Islam
Hi Forum,

I would like to thank Carlos to share his code with me of his attempt to bring 
OSG and OpenCL together. I tried the code but i am having a segmentation fault. 
So i am putting the code here for all your kind review and share with the forum 
your ideas here:


Code:

#include iostream
#include osg/GL
#include osgGA/TrackballManipulator
#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers
#include osgViewer/api/X11/GraphicsWindowX11
#include cassert

#define __CL_ENABLE_EXCEPTIONS
#include CL/cl.hpp

const int nElements = 4;

osg::ref_ptrosg::Geode CreateGeometry()
{
osg::Geometry * g = new osg::Geometry;
g-setUseDisplayList(false);
g-setUseVertexBufferObjects(true);
g-getOrCreateVertexBufferObject()-setUsage(GL_STATIC_DRAW);

osg::DrawElementsUInt * puint = new osg::DrawElementsUInt(GL_TRIANGLES);
puint-addElement(0);
puint-addElement(1);
puint-addElement(2);
g-addPrimitiveSet(puint);

osg::Vec4Array * varray = new osg::Vec4Array(nElements);
(*varray)[0]= osg::Vec4f(0,0,0,1);
(*varray)[1] = osg::Vec4f(0,0,1,1);
(*varray)[2] = osg::Vec4f(1,0,0,1);
g-setVertexArray(varray);

osg::ref_ptrosg::Geode ans = new osg::Geode;
ans-addDrawable(g);
return ans;
}

const std::string rotateprog =
__kernel void ROT(global float4 * v,float dt) {\n
   int i = get_global_id(0);\n
   v[i].x = v[i].x - v[i].z*dt;\n
   v[i].z = v[i].z + v[i].x*dt;\n
}\n;

int main(int argc, char **argv) {

try {
osg::ref_ptrosg::Group root = new osg::Group;
osgViewer::Viewer theViewer;

//This is crucial
theViewer.setThreadingModel( 
osgViewer::ViewerBase::SingleThreaded);

theViewer.setUpViewInWindow(0,0,800,600);

theViewer.setSceneData(root.get());
theViewer.setCameraManipulator(new 
osgGA::TrackballManipulator());
theViewer.addEventHandler(new osgViewer::StatsHandler);
theViewer.realize();

osg::ref_ptrosg::Geode g = CreateGeometry();
root-addChild(g);
theViewer.frame();

std::vectorcl::Platform platforms;
cl::Platform::get(platforms);

std::vectorcl::Device devices;
platforms[0].getDevices(CL_DEVICE_TYPE_GPU,devices);

cl::Device dev = devices[0];

osgViewer::GraphicsWindowX11 * X11Wnd = 
dynamic_castosgViewer::GraphicsWindowX11*(theViewer.getCamera()-getGraphicsContext());


if(!X11Wnd)
  {
exit(EXIT_FAILURE);
  }


cl_context_properties prop[] = {
CL_GL_CONTEXT_KHR,(cl_context_properties) 
X11Wnd-getContext(),

CL_GLX_DISPLAY_KHR,(cl_context_properties)X11Wnd-getDisplay(),
0
};

cl::Context cntx (devices,prop);
cl::CommandQueue mainq (cntx,dev);

int cntxtid = 
theViewer.getCamera()-getGraphicsContext()-getState()-getContextID();

osg::Geometry * geo = 
dynamic_castosg::Geometry*(g-getDrawable(0));
osg::BufferObject * buff = geo-getOrCreateVertexBufferObject();
osg::GLBufferObject * glbuff = buff-getGLBufferObject(cntxtid);

int reqsize = buff-computeRequiredBufferSize();
int needsize = nElements*sizeof(cl_float4);
assert (reqsize == needsize);

//  cl::Program rProg (cntx,cl::Program::Sources ({ 
std::make_pair(rotateprog.c_str(),0)}));
//  rProg.build(devices,-g);

cl::Program::Sources srcs;
srcs.push_back(std::make_pair(rotateprog.c_str(),0));
cl::Program rProg(cntx,srcs);
rProg.build(devices,-g);

cl::Kernel k (rProg,ROT);
assert(glbuff-getGLObjectID());

//This may be a bug of my opencl implementation
//Opencl documentation doesn't say if the user is required to 
make the GL context current, but i need this or it doesn't work.
X11Wnd-makeCurrent();

std::cout  OBJID=   glbuff-getGLObjectID()  std::endl;
cl::BufferGL 
buffgl(cntx,CL_MEM_READ_WRITE,glbuff-getGLObjectID());

while(!theViewer.done()) {
glFinish();
std::vectorcl::Memory globjects;
globjects.push_back(buffgl);
mainq.enqueueAcquireGLObjects(globjects);
k.setArg(0, buffgl());
k.setArgcl_float(1,0.1);

mainq.enqueueNDRangeKernel(k,cl::NDRange(0),cl::NDRange(nElements),cl::NDRange());
   

Re: [osg-users] Invalid GL buffer object

2013-10-18 Thread Sajjadul Islam
Thanks Robert,

I am not calling glGenBuffers() in my code. I am calling the following :


Code:

osg::GLBufferObject *glBO = 
vbo-getOrCreateGLBufferObject(osgCompute::GLMemory::getContext()-getState()-getContextID());




Since i am getting undefined behavior, i used the debugger to get inside the 
above statement and found that  i am having the issue inside the GLBufferObject 
constructor.


Code:

GLBufferObject::GLBufferObject(unsigned int contextID, BufferObject* 
bufferObject, unsigned int glObjectID):
_contextID(contextID),
_glObjectID(glObjectID),
_profile(0,0,0),
_allocatedSize(0),
_dirty(true),
_bufferObject(0),
_set(0),
_previous(0),
_next(0),
_frameLastUsed(0),
_extensions(0)
{
assign(bufferObject);

_extensions = GLBufferObject::getExtensions(contextID, true);

if (glObjectID==0)
{
_extensions-glGenBuffers(1, _glObjectID);
}

// OSG_NOTICEConstucting BufferObject thisstd::endl;
}




The immediate above snippet is from the BufferObject file that came along with 
the API.

And i found that _glObjectID is carrying the value 0 even after call:


Code:

_extensions-glGenBuffers(1, _glObjectID);




I believe that 0 is not a valid value here. 

Any more thoughts ?

Regards,
Sajjadul

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





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


Re: [osg-users] Invalid GL buffer object

2013-10-17 Thread Sajjadul Islam
Hi Forum,

It has been a while and i did not get any feed-back over my last post. I 
realized that i was not clear enough in my explanation. Let me try again. 

I store the current graphics context and part of the code snippet shows that 
the current context is stored:


Code:

   void Context::operator() (osg::GraphicsContext *gc)
   {
  if(gc-getState() == NULL)
  {
 osg::notify(osg::FATAL)  __FUNCTION__  : 
  osg::GraphicsContext must have a valid 
state. 
  std::endl;
 exit(EXIT_FAILURE);
  }

  //make this context current if not the current context
  if(!gc-isCurrent())
gc-makeCurrent();

 .

..

  // Bind context to osgCompute::GLMemory
  if( osgCompute::GLMemory::getContext() == NULL )
 osgCompute::GLMemory::bindToContext( *gc );

 .

 .
   }




As you can see that inside the realize operation i store the current context 
for later reference.

Now i use this context reference id to create the buffer object as follows:


Code:


..
..
  //get or create a vertex buffer object from the geometry 
  osg::VertexBufferObject *vbo = 
_m_clGeomRef-getOrCreateVertexBufferObject();

  //make sure that we have the vertex buffer object
  //AND i checked the vbo creation is successful
  if(!vbo)
 return NULL;

 ..
 ..

 //get the buffer object 
 // I HAVE THE PROBLEM WITH THE FOLLOWING STATEMENT.
 // event though i get a valid pointer to glBO, i checked though the 
debugger that
 //glGenBuffers is generating a buffer id with 0 value 
 osg::GLBufferObject *glBO = 
vbo-getOrCreateGLBufferObject(osgCompute::GLMemory::getContext()-getState()-getContextID());

 //make sure that we have the buffer object
 if(!glBO)
return NULL;






I have no idea why am i getting 0 value for the buffer id with glGenBuffers(..) 
call inside the constructor of GLBufferObject() - the class that came along 
with the repository.

I am using the context id that i have stored inside the realize operation.

Any hint on what might have went wrong ? Where should i look into ?

I shall be eagerly looking forward to your hint over this issue.

Thanks,
Sajjadul

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





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


Re: [osg-users] Invalid GL buffer object

2013-10-17 Thread Sajjadul Islam
Hi Forum,

I forgot to mention  that i get a valid glBO pointer even though i have 0 
buffer object id with 
glGenBuffers(..)

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Hi Forum,

I think this is one of the most common linking error you usually get, but i 
could not find the reason behind it. 


Code:

Linking CXX executable ../../../bin/osgOpenCLEndiannessDemod
../../../lib/libosgOpenCLd.so: undefined reference to `typeinfo for 
osgViewer::GraphicsWindowX11'
collect2: ld returned 1 exit status
make[2]: *** [bin/osgOpenCLEndiannessDemod] Error 1
make[1]: *** 
[examples/osgOpenCLEndiannessDemo/src/CMakeFiles/example_osgOpenCLEndiannessDemo.dir/all]
 Error 2
make: *** [all] Error 2





I have over-ridden the following realize operation in the sub-class definition 
of osg::GraphicsOperation:


Code:

   void Context::operator() (osg::GraphicsContext *gc)
   {
 ...
 ...

  osgViewer::GraphicsWindowX11 *unixWindow = 
dynamic_castosgViewer::GraphicsWindowX11*(gc);

   if(unixWindow == NULL)
   {
osg::notify(osg::FATAL)  __FUNCTION__  :   __LINE__  
: 
 Unix Graphics Handle Casting is not 
successful.   std::endl;


exit(EXIT_FAILURE);

   }
  




   }


 

I have the graphics context that i am trying to dynamically cast to something 
platform specific stuff .

Is there anything i am missing folks ?

Please let me know if you need more details 

Thanks,
Sajjadul

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





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


Re: [osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Hi,

I am not sure when do we usually cast to osgViewer::GraphicsWindowX11 or to 
osgViewerGraphicsHandleX11 .

I have checked the examples and i did not find anything related to either of 
them. Let me know if i miss it. 

I need access to  the reference of Display and Context and i think both the 
class provide with the access to them.

Any more thoughts on this ?


Thanks,
Sajjadul

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





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


Re: [osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Thanks for the hint!

I tried to compile with verbose and i got the following output:


Code:

Linking CXX executable ../../../bin/osgOpenCLEndiannessDemod
cd 
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/examples/osgOpenCLEndiannessDemo/src
  /usr/bin/cmake -E cmake_link_script 
CMakeFiles/example_osgOpenCLEndiannessDemo.dir/link.txt --verbose=1
/usr/bin/c++   -gCMakeFiles/example_osgOpenCLEndiannessDemo.dir/main.cpp.o  
-o ../../../bin/osgOpenCLEndiannessDemod -rdynamic 
../../../lib/libosgComputed.so ../../../lib/libosgOpenCLd.so 
/usr/local/lib/libOpenThreadsd.so /usr/local/lib/libosgd.so 
/usr/local/lib/libosgUtild.so -lOpenCL ../../../lib/libosgComputed.so 
/usr/local/lib/libOpenThreadsd.so /usr/local/lib/libosgd.so 
/usr/local/lib/libosgUtild.so /usr/local/lib/libosgDBd.so -lGLU -lGL -lSM -lICE 
-lX11 -lXext 
-Wl,-rpath,/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/lib:/usr/local/lib:
 
../../../lib/libosgOpenCLd.so: undefined reference to `typeinfo for 
osgViewer::GraphicsWindowX11'
collect2: ld returned 1 exit status
make[2]: *** [bin/osgOpenCLEndiannessDemod] Error 1
make[2]: Leaving directory 
`/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute'
make[1]: *** 
[examples/osgOpenCLEndiannessDemo/src/CMakeFiles/example_osgOpenCLEndiannessDemo.dir/all]
 Error 2
make[1]: Leaving directory 
`/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute'
make: *** [all] Error 2





As you can see the linker output does not contain any flag -fno-rtti. 

Any further hint to get around this issue.

Thank you!

Regards,
Sajjadul

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





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


Re: [osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Hi ,

I ahe installed the OSG (Revision 13850) in Debug Mode. I have following flags 
entered through CMake:


Code:

CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG  -g
CMAKE_CXX_FLAGS_MINSIZEREL  -Os  -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE   -O3  -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO -O2 -g




The C flags are the same .

then I have osgCompute installed in my sytem with the very same compiler flag i 
mentioned above. All the  EXE linker flags fields that are to be mentioned in 
CMake are empty.


Is anything missing here?

Regards,
Sajjadul

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





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


Re: [osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Thanks for the support so far guys,

I sorted it out. My Bad. I was not linking against the osgViewer . Now i have 
the question 

Even though i was not linking before i did not have the error if cast the 
graphics context to 

osgGraphicsHandleX11 instead of osgGraphicsWindowX11. 

Any explanation?


Regards,
Sajjadul

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





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


Re: [osg-users] undefined reference to typeinfo for 'osgViewer::GraphicsWindowX11'

2013-10-16 Thread Sajjadul Islam
Ok , Let me explain it again.

I need to dynamically cast the osg::GraphicsContext to something platform 
specific so that i can access to the OS specific context and display . But i am 
not sure which class to cast to : osgViewer::GraphicsWindowX11 or 
osgViewer::GraphicsHandleX11

I started with  osgViewer::GraphicsHandleX11 and i did not get the linking 
error as i was having.


I am not sure if i had understood your question properly.

In the general case if you have to cast the osg::GraphicsContext to OS specific 
, where do you usually cast to in order to have access of the context and 
display ?


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] Invalid GL buffer object

2013-10-14 Thread Sajjadul Islam
Hi forum,

I am getting the invalid buffer object with the following source snippet:


Code:

...
...

 osg::VertexBufferObject* vbo = 
_m_clGeomRef-getOrCreateVertexBufferObject();

 if(!vbo)
 {
osg::notify(osg::FATAL)
 __FUNCTION__ :   __LINE__  : 
 _m_clGeomRef-getName()  : no buffer object found.
 std::endl;

return false;
 } // END OF - !vbo

 //get the context id
 unsigned int contextID = 
osgCompute::GLMemory::getContext()-getState()-getContextID();

 //compile vertex buffer
 osg::GLBufferObject *glBO = vbo-getOrCreateGLBufferObject( contextID 
);

 if( !glBO )
 {
osg::notify(osg::FATAL)
__FUNCTION__ :   __LINE__  : 
_m_clGeomRef-getName()  : no GL buffer object found.
std::endl;

return false;
 } // END OF - !glBO

 if( glBO-isDirty())
 {
osg::GLBufferObject::Extensions* ext = 
osg::GLBufferObject::getExtensions( 
osgCompute::GLMemory::getContext()-getState()-getContextID(),true);

if(!ext)
{
   osg::notify(osg::FATAL)
   __FUNCTION__ :   __FUNCTION__  : 
   _m_clGeomRef-getName()  : cannot find required 
extensions to compile buffer object.
   std::endl;

   return false;
}

//the following function call the glBufferData()
glBO-compileBuffer();

//unbind the buffer objects
ext-glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
ext-glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);

 } // END OF - glBO-isDirty()

 //avoid copy operation during osgCompute::MAP_HOST
 memory._m_clLastModifiedCount.clear();

 for( unsigned int d = 0; d  vbo-getNumBufferData(); ++d )
memory._m_clLastModifiedCount.push_back( 
vbo-getBufferData(d)-getModifiedCount());

 GLuint objectid = glBO-getGLObjectID();

 //create the vertex buffer from the gl buffer object
 (memory._m_clDevBuffer) = clCreateFromGLBuffer(cxt-_m_clContext, // 
the valid opencl context
CL_MEM_READ_WRITE, // 
the memory has both the read and write access
objectid,
errNum);

 if( errNum != CL_SUCCESS )
 {
osg::notify(osg::FATAL)
__FUNCTION__ :   __LINE__  : 
_m_clGeomRef-getName()  : unable to create opencl buffer 
object (clCreateFromGLBuffer): 
cxt-getErrorString(errNum) .
std::endl;

return false;
 }

...
...




As you can see that there is also one line of OpenCL code snippet where i am 
trying to create an OpenCL buffer from the OpenGL buffer object. But the buffer 
creation is not successful because the error string is telling that the 
Code:
  GLuint objectid = glBO-getGLObjectID();  

 is not returning the valid GL buffer object id or GL buffer object does not 
have an existing data store. I guess that i have to make it sure on the OSG 
side. AND this is where i seek your help. 

Could you provide me with some hint to make sure that i got the valid GL buffer 
object and GL buffer object do have the existing data store. Please make some 
time to go through the code i have pasted above and let me know if i have 
missed something or at least where to look into. 

Thank you!

Regards,
Sajjadul

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





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


Re: [osg-users] singleton instane

2013-10-12 Thread Sajjadul Islam
Hi David,

Thanks for the suggestion of the singleton design . I tried to design a 
template base class as follows :


Code:

namespace osgOpenCL
{

/**
   This class helps to build the singleton design pattern.
   Here you have full control over construction and deconstruction
   of the object.
*/
   templateclass T
   class Singleton
   {
   public:
  /**
   * Init the actual singleton.
   * Must be called BEFORE the class is used, like this:
   */
  static void init()
  {
 assert( singletonClass_.get() == NULL);
 singletonClass_ = new T;
  }


  /**
   * Get Pointer of the actual class
   * @return Pointer of the actual class
   */
  static T* getPtr()
  {
 assert( singletonClass_.get() != NULL);
 return singletonClass_.release();
  }

  /**
   * Get reference of the actual class
   * @return reference of the actual class
   */
  static T getRef()
  {
 assert( singletonClass_.get() != NULL );
 return *singletonClass_;
  }




  /**
   * Has the actual class been inited?
   */
  static bool isInited()
  {
 return (singletonClass_.valid());
  }

   private:
  static osg::ref_ptrT singletonClass_;
   };

/// init static pointers with 0
   templateclass T
   osg::ref_ptrT SingletonT::singletonClass_ = 0;

} // namespace

#endif // TGT_SINGLETON_H




But it crashes at the assertion. I tried without assertion , then debugger 
simply exits at the point where i call:


Code:

  //pull out the  singleton context
  //get the singleton context - which will be widely used in the rest of 
this function definition
  osgOpenCL::Context *cxt = 
osgOpenCL::SingletonosgOpenCL::Context::getPtr();






Any idea how to get around these issues ?

Thanks,
Sajjadul

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





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


[osg-users] how many Graphics Context each viewer object return ?

2013-10-10 Thread Sajjadul Islam
Hi forum,

If i declare a osgViewer::Viewer , how many Graphics Context does it return . I 
read from somewhere that OSG creates separate context for each window.

Does it also return several contexts even if i declare 
osgViewer::ViewerBase::setThreadingModel( osgViewer::ViewerBase::SingleThreaded 
) ?


I need a single OSG/OpenGL context. Any idea how to extract it ?

I was thinking subclass the osg::GraphicsOperation and override the realize 
operator where i shall get only one osg::GraphicsContext as follows:


Code:

void Context::operator() (osg::GraphicsContext *gc)
{
..
..
}




Is that the current context or i have to make it current with 
gc-makeCurrent()? 
I need to do some initialization for single OSG graphics context.

Thanks,
Sajjadul

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





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


Re: [osg-users] Graphics Context and Window Handle

2013-10-09 Thread Sajjadul Islam
Hi forum,

I have not got any response from the forum so far. Let me narrate what i have 
been trying so far. I subclassed the osg::GraphicsOperation and inside the 
Context::operator() (osg::GraphicsContext *gc) 


Code:

class LIBRARY_EXPORT Context : public  osg::GraphicsOperation
{
.
   ..
 }





i am trying to create the opencl context as follows:


Code:

   void Context::operator() (osg::GraphicsContext *gc)
   {

  if(gc-getState() == NULL)
  {
 osg::notify(osg::FATAL)  __FUNCTION__  : 
  osg::GraphicsContext must have a valid 
state. 
  std::endl;
 exit(EXIT_FAILURE);
  }

  //make this context as the currrent one
  gc-makeCurrent();

  if( NULL != osgCompute::GLMemory::getContext() 
  osgCompute::GLMemory::getContext()-getState()-getContextID() != 
gc-getState()-getContextID() )
  {
 osg::notify(osg::WARN)
 __FUNCTION__  : osgOpenCL can handle only a single context.
  However multiple contexts are detected.
  Please make sure to share a GL context among all windows.
 std::endl;

 exit(EXIT_FAILURE);

  }

  // Bind context to osgCompute::GLMemory
  if( osgCompute::GLMemory::getContext() == NULL )
 osgCompute::GLMemory::bindToContext( *gc );

  //declare some variables to create OpenCL
  //specific
   cl_uint numPlatforms;
   cl_platform_id  *platformIDs;
   cl_int errNum;
   cl_device_id deviceID;

   //first query the total number of platforms
   errNum = clGetPlatformIDs(0,NULL,numPlatforms);

   if(errNum != CL_SUCCESS || numPlatforms = 0)
   {
  osg::notify(osg::FATAL)  Failed to find any OpenCL platform  
std::endl;

  exit(EXIT_FAILURE);

   }

   //next, allocate memory for the installed platforms, and query
   //to get the list
   platformIDs = (cl_platform_id *)alloca(sizeof(cl_platform_id) * 
numPlatforms);


   errNum = clGetPlatformIDs(numPlatforms,platformIDs,NULL);

   if(errNum != CL_SUCCESS)
   {
  osg::notify(osg::FATAL)  Failed to find any OpenCL platform  
std::endl;

  exit(EXIT_FAILURE);

   }


   //now choose the very first platform and store it
   _m_clPlatform = platformIDs[0];

   char cBuffer[1024];
   char deviceName[48];
   char deviceExtensions[1024];

   //get the platform information from the selected platform
   errNum = 
clGetPlatformInfo(_m_clPlatform,CL_PLATFORM_NAME,sizeof(cBuffer),cBuffer,NULL);

   if(errNum == CL_SUCCESS)
   {
  osg::notify(osg::INFO)  OpenCL platform name:   cBuffer  
std::endl;
   }


   cl_uint clDevCount = 0;

   //get the number of devices under the platform
   errNum = 
clGetDeviceIDs(_m_clPlatform,CL_DEVICE_TYPE_GPU,0,NULL,clDevCount);

   if(errNum != CL_SUCCESS)
   {
 osg::notify(osg::FATAL)  __FUNCTION__  :   __LINE__  : 
  Error with clGetDeviceIDs(): 
 getErrorString(errNum)  std::endl;

 exit(EXIT_FAILURE);

   }

   //create a device list with the number of devices
   cl_device_id* clDevices = new cl_device_id[clDevCount];

   //populate the device list with another call to the clGetDeviceIDs()
   errNum = clGetDeviceIDs(_m_clPlatform, 
CL_DEVICE_TYPE_GPU,clDevCount,clDevices,NULL);

   if(errNum != CL_SUCCESS)
   {
 osg::notify(osg::FATAL)  __FUNCTION__  :   __LINE__  : 
  Error with clGetDeviceIDs(): 
 getErrorString(errNum)  std::endl;

 exit(EXIT_FAILURE);
   }

   unsigned int clDevUsed = 0;
   unsigned int clEndDev = clDevCount - 1;


   //browse through all the found devices in the platform for the CL-GL 
interpolation support
   for( unsigned int i = clDevUsed ; (!_m_glInterOpSupported  (i = 
clEndDev)); ++i)
   {
 size_t extensionSize;

 //get the size of the supported device extensions to allocate memory 
for each device in the loop
 errNum = 
clGetDeviceInfo(clDevices[i],CL_DEVICE_EXTENSIONS,0,NULL,extensionSize);

 if(errNum != CL_SUCCESS)
 {
 osg::notify(osg::FATAL)  __FUNCTION__  :   __LINE__  : 
   Error with clGetDeviceInfo(): 
  getErrorString(errNum)  std::endl;


 exit(EXIT_FAILURE);
 }

 if(extensionSize  0)
 {
 //we have some extensions to allocate memory with
 char *extensions = (char*)malloc(extensionSize);

 errNum = 
clGetDeviceInfo(clDevices[i],CL_DEVICE_EXTENSIONS,extensionSize,extensions,extensionSize);

 if(errNum != CL_SUCCESS)
 {
   osg::notify(osg::FATAL)  __FUNCTION__  :   __LINE__  
: 
  

[osg-users] Getting ZERO value with getGLObjectID()

2013-10-09 Thread Sajjadul Islam
Hi Forum,

I am creating a buffer object as follows and i need to access the id of the 
buffer object for later references , but i am getting ZERO value:


Code:

.

 osg::VertexBufferObject* vbo = 
_m_clGeomRef-getOrCreateVertexBufferObject();

 if(!vbo)
 {
osg::notify(osg::FATAL)
__FUNCTION__ :   __LINE__
_m_clGeomRef-getName()  : no buffer object found.
std::endl;

return false;
 } // END OF - !vbo

 unsigned int contextID = 
osgCompute::GLMemory::getContext()-getState()-getContextID();

 //compile vertex buffer
 osg::GLBufferObject *glBO = vbo-getOrCreateGLBufferObject( contextID 
);

 if( !glBO )
 {
osg::notify(osg::FATAL)
__FUNCTION__ :   __LINE__  : 
_m_clGeomRef-getName()  : no GL buffer object found.
std::endl;

return false;
 } // END OF - !glBO

 if( glBO-isDirty())
 {
osg::GLBufferObject::Extensions* ext = 
osg::GLBufferObject::getExtensions( 
osgCompute::GLMemory::getContext()-getState()-getContextID(),true);

if(!ext)
{
   osg::notify(osg::FATAL)
   __FUNCTION__ :   __FUNCTION__  : 
   _m_clGeomRef-getName()  : cannot find required 
extensions to compile buffer object.
   std::endl;

   return false;
}

//the following function call the glBufferData()
glBO-compileBuffer();

//unbind the buffer objects
ext-glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
ext-glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);

 } // END OF - glBO-isDirty()

 //avoid copy operation during osgCompute::MAP_HOST
 memory._m_clLastModifiedCount.clear();

 for( unsigned int d = 0; d  vbo-getNumBufferData(); ++d )
memory._m_clLastModifiedCount.push_back( 
vbo-getBufferData(d)-getModifiedCount());

 GLuint objectid = glBO-getGLObjectID();
...
..





In debuffer i found that objectid is always zero.

Where should i look into to correct this issue ?

Thanks
Sajjadul

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





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


[osg-users] matrix as uniform

2013-10-06 Thread Sajjadul Islam
Hi forum,

I am sending a osg::Matrix as uniform value to the shader and i am getting a 
warning and a blank screen:


Code:

Warning: detected OpenGL error 'invalid operation' at After Renderer::compile




I am sending the uniform as follows:


Code:

#include osg/ref_ptr
#include osgDB/Registry
#include osgDB/WriteFile
#include osg/Notify
#include osg/Geode
#include osg/GraphicsContext
#include osg/Geometry
#include osg/Shader
#include osg/Program
#include osg/Camera
#include osgViewer/Viewer
#include osg/Uniform
#include osg/MatrixTransform

#include iostream

using std::endl;

osg::ref_ptrosg::Node createSceneGraph();

int main()
{
  osg::ref_ptrosg::Node root = createSceneGraph();

  const std::string version(4.2);
  osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits();
  traits-x = 20;
  traits-y = 30;
  traits-width = 800;
  traits-height = 600;
  traits-windowDecoration = true;
  traits-doubleBuffer = true;
  traits-glContextVersion = version;


  osg::ref_ptr osg::GraphicsContext  gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() );



  if( !gc.valid() )
   {
   osg::notify( osg::FATAL )  Unable to create OpenGL v  version   
context.  std::endl;
   return( 1 );
   }

  osg::ref_ptrosg::Camera camera = new osg::Camera;
  camera-setGraphicsContext(gc.get());
  camera-setViewport(new osg::Viewport(0,0,traits-width,traits-height));

  osgViewer::Viewer viewer;
  viewer.setCamera(camera.get());
  viewer.setSceneData(root.get());

  return viewer.run() ;
}

osg::ref_ptrosg::Node createSceneGraph()
{
  //create an object to store the geometry in
  osg::ref_ptrosg::Geometry geom = new osg::Geometry;

  //create an array of four vertices
  osg::ref_ptrosg::Vec3Array v = new osg::Vec3Array;

  v-push_back(osg::Vec3(-0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.0f,  0.8f, 0.0f));

//  geom-setVertexArray(v.get());

  //make sure that vertex array is used
  geom-setUseDisplayList(false);
  geom-setVertexAttribArray(0,v.get());
  geom-setVertexAttribBinding(0,osg::Geometry::BIND_PER_VERTEX);

  //create an array of three colors
  osg::ref_ptrosg::Vec3Array c = new osg::Vec3Array;
  c-push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 1.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 0.0f, 1.0f));

//  geom-setColorArray(c.get());
  geom-setColorBinding(osg::Geometry::BIND_PER_VERTEX);
  geom-setVertexAttribArray(1,c.get());
  geom-setVertexAttribBinding(1,geom-getColorBinding());


  //draw a three-vertex tringle from the stored data
  geom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,3));

  //add the geometry to the geode and return the geode
  osg::ref_ptrosg::Geode geode = new osg::Geode;
  geode-addDrawable(geom.get());


  osg::ref_ptrosg::StateSet primitiveState = geode-getOrCreateStateSet();

  //declare a rotation matrix
  osg::Matrix rotationMatrix;
  rotationMatrix.rotate(50,osg::Vec3(0.0f,0.0f,1.0f));

  //add the rotation matrix as uniform to primitives state
  primitiveState-addUniform(new osg::Uniform(RotationMatrix, 
rotationMatrix));

  osg::ref_ptrosg::Program basicPrimitiveShaderProg = new osg::Program;

  osg::ref_ptrosg::Shader 
primitiveVertexShader(osg::Shader::readShaderFile(osg::Shader::VERTEX,shader/basicUniform.vert));
  osg::ref_ptrosg::Shader 
elephantFragmentShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT,shader/basicUniform.frag));

  basicPrimitiveShaderProg-addShader(primitiveVertexShader.get());
  basicPrimitiveShaderProg-addShader(elephantFragmentShader.get());

  basicPrimitiveShaderProg-addBindAttribLocation(VertexPosition,0);
  basicPrimitiveShaderProg-addBindAttribLocation(VertexColor,1);

  
primitiveState-setAttributeAndModes(basicPrimitiveShaderProg.get(),osg::StateAttribute::ON);


  return geode.get();
}





Any idea ?

Regards,
Sajjadul

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





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


Re: [osg-users] matrix as uniform

2013-10-06 Thread Sajjadul Islam
Thanks !!

Now i at least got the triangle on the screen. I have checked the examples 
where they have used addUniform and it works fine . Check osgparametric. Any 
more explanation ?

And the matirx that i am sending as uniform has no effect at all.  I should see 
a triangle rotated to a certain angle.

The application has the following addition as follows:


Code:

  //declare a rotation matrix
  osg::Matrix rotationMatrix;
  float angle = osg::inDegrees((float)80);
  rotationMatrix.rotate(angle,osg::Vec3(0.0f,0.0f,1.0f));

..
..

primitiveState-getOrCreateUniform(RotationMatrix,osg::Uniform::FLOAT_MAT4)-set(rotationMatrix);



 


And the shader are as follows:

Vertex Shader

Code:

#version 400

in vec3 VertexPosition;
in vec3 VertexColor;

out vec3 Color;

uniform mat4 RotationMatrix;

void main()
{
Color = VertexColor;

gl_Position = RotationMatrix * vec4(VertexPosition,1.0);

}





And the fragment shader


Code:

#version 400

in vec3 Color;
out vec4 FragColor;

void main() {
FragColor = vec4(Color, 1.0);
}





It will be nice if you try this at your end and recreate the behavior i am 
having here. 

Thanks
Sajjadul

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





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


Re: [osg-users] compatibity profile

2013-10-05 Thread Sajjadul Islam
Thanks Robert!!

I got it worked. There is some minor issue though .

The mouse interaction is not functional. I checked the simplegl3 example and 
the mouse interaction is working fine there. What i could have missed again ?

Here goes the whole source so that you can try it in your end.


Code:

#include osg/ref_ptr
#include osgDB/Registry
#include osgDB/WriteFile
#include osg/Notify
#include osg/Geode
#include osg/GraphicsContext
#include osg/Geometry
#include osg/Shader
#include osg/Program
#include osg/Camera
#include osgViewer/Viewer

#include iostream

using std::endl;

osg::ref_ptrosg::Node createSceneGraph();

int main()
{
  osg::ref_ptrosg::Node root = createSceneGraph();

  const std::string version(3.1);
  osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits();
  traits-x = 20;
  traits-y = 30;
  traits-width = 800;
  traits-height = 600;
  traits-windowDecoration = true;
  traits-doubleBuffer = true;
  traits-glContextVersion = version;


  osg::ref_ptr osg::GraphicsContext  gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() );

  if( !gc.valid() )
   {
   osg::notify( osg::FATAL )  Unable to create OpenGL v  version   
context.  std::endl;
   return( 1 );
   }

  osg::ref_ptrosg::Camera camera = new osg::Camera;
  camera-setGraphicsContext(gc.get());
  camera-setViewport(new osg::Viewport(0,0,traits-width,traits-height));

  osgViewer::Viewer viewer;
  viewer.setCamera(camera.get());
  viewer.setSceneData(root.get());

  return viewer.run() ;
}

osg::ref_ptrosg::Node createSceneGraph()
{
  //create an object to store the geometry in
  osg::ref_ptrosg::Geometry geom = new osg::Geometry;

  //create an array of four vertices
  osg::ref_ptrosg::Vec3Array v = new osg::Vec3Array;

  v-push_back(osg::Vec3(-0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.0f,  0.8f, 0.0f));

//  geom-setVertexArray(v.get());

  //make sure that vertex array is used
  geom-setUseDisplayList(false);
  geom-setVertexAttribArray(0,v.get());
  geom-setVertexAttribBinding(0,osg::Geometry::BIND_PER_VERTEX);

  //create an array of three colors
  osg::ref_ptrosg::Vec3Array c = new osg::Vec3Array;
  c-push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 1.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 0.0f, 1.0f));

//  geom-setColorArray(c.get());
  geom-setColorBinding(osg::Geometry::BIND_PER_VERTEX);
  geom-setVertexAttribArray(1,c.get());
  geom-setVertexAttribBinding(1,geom-getColorBinding());


  //draw a three-vertex tringle from the stored data
  geom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,3));

  //add the geometry to the geode and return the geode
  osg::ref_ptrosg::Geode geode = new osg::Geode;
  geode-addDrawable(geom.get());


  osg::ref_ptrosg::StateSet primitiveState = geode-getOrCreateStateSet();


  osg::ref_ptrosg::Program basicPrimitiveShaderProg = new osg::Program;

  osg::ref_ptrosg::Shader 
primitiveVertexShader(osg::Shader::readShaderFile(osg::Shader::VERTEX,shader/basic.vert));
  osg::ref_ptrosg::Shader 
elephantFragmentShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT,shader/basic.frag));

  basicPrimitiveShaderProg-addShader(primitiveVertexShader.get());
  basicPrimitiveShaderProg-addShader(elephantFragmentShader.get());

  basicPrimitiveShaderProg-addBindAttribLocation(VertexPosition,0);
  basicPrimitiveShaderProg-addBindAttribLocation(VertexColor,1);

  
primitiveState-setAttributeAndModes(basicPrimitiveShaderProg.get(),osg::StateAttribute::ON);


  return geode.get();
}




And the shaders are :


Code:

#version 400

in vec3 VertexPosition;
in vec3 VertexColor;

out vec3 Color;

void main()
{
Color = VertexColor;

gl_Position = vec4(VertexPosition,1.0);
}




And the fragment shader


Code:

#version 400

in vec3 Color;

out vec4 FragColor;

void main()
{
FragColor = vec4(Color,1.0);
}




Please try it on your end and let me know!!

Regards
Sajjadul

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





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


[osg-users] compatibity profile

2013-10-04 Thread Sajjadul Islam
Hi Forum,

I know that this topic is widely discussed here to run shading language 4 with 
OpenGL 3 and onwards using the compatibility profile. I checked the 
osgsimplegl3 and osgvertexattrib array example. Then i try to compile the a 
simple application with a pass through shader only , but i am having the 
following error:


Code:

Got an X11ErrorHandling call display=0x9c41880 event=0xb3fadf2c
GLXBadDrawable
Major opcode: 135
Minor opcode: 11
Error code: 146
Request serial: 9503
Current serial: 9503
  ResourceID: 73400323




I am also attaching the code snippet for your kind review:


Code:

int main()
{
  osg::ref_ptrosg::Node root = createSceneGraph();

  const std::string version(3.1);
  osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits();
  traits-windowDecoration = true;
  traits-doubleBuffer = true;
  traits-glContextVersion = version;


  osg::ref_ptr osg::GraphicsContext  gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() );

  if( !gc.valid() )
   {
   osg::notify( osg::FATAL )  Unable to create OpenGL v  version   
context.  std::endl;
   return( 1 );
   }

  osg::ref_ptrosg::Camera camera = new osg::Camera;
  camera-setGraphicsContext(gc.get());

  osgViewer::Viewer viewer;
  viewer.setCamera(camera.get());
  viewer.setSceneData(root.get());

  return viewer.run() ;
}

osg::ref_ptrosg::Node createSceneGraph()
{
  //create an object to store the geometry in
  osg::ref_ptrosg::Geometry geom = new osg::Geometry;

  //create an array of four vertices
  osg::ref_ptrosg::Vec3Array v = new osg::Vec3Array;

  v-push_back(osg::Vec3(-0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.8f, -0.8f, 0.0f));
  v-push_back(osg::Vec3(0.0f,  0.8f, 0.0f));

//  geom-setVertexArray(v.get());

  //make sure that vertex array is used
  geom-setUseDisplayList(false);
  geom-setVertexAttribArray(0,v.get());
  geom-setVertexAttribBinding(0,osg::Geometry::BIND_PER_VERTEX);

  //create an array of three colors
  osg::ref_ptrosg::Vec3Array c = new osg::Vec3Array;
  c-push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 1.0f, 0.0f));
  c-push_back(osg::Vec3(0.0f, 0.0f, 1.0f));

//  geom-setColorArray(c.get());
  geom-setColorBinding(osg::Geometry::BIND_PER_VERTEX);
  geom-setVertexAttribArray(1,c.get());
  geom-setVertexAttribBinding(1,geom-getColorBinding());


  //draw a three-vertex tringle from the stored data
  geom-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,0,3));

  //add the geometry to the geode and return the geode
  osg::ref_ptrosg::Geode geode = new osg::Geode;
  geode-addDrawable(geom.get());


  osg::ref_ptrosg::StateSet primitiveState = geode-getOrCreateStateSet();


  osg::ref_ptrosg::Program basicPrimitiveShaderProg = new osg::Program;

  osg::ref_ptrosg::Shader 
primitiveVertexShader(osg::Shader::readShaderFile(osg::Shader::VERTEX,shaders/basic.vert));
  osg::ref_ptrosg::Shader 
elephantFragmentShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT,shaders/basic.frag));

  basicPrimitiveShaderProg-addShader(primitiveVertexShader.get());
  basicPrimitiveShaderProg-addShader(elephantFragmentShader.get());

  basicPrimitiveShaderProg-addBindAttribLocation(VertexPosition,0);
  basicPrimitiveShaderProg-addBindAttribLocation(VertexColor,1);

  
primitiveState-setAttributeAndModes(basicPrimitiveShaderProg.get(),osg::StateAttribute::ON);


  return geode.get();
}





If i miss anything, i would be glad to be notified .

Thanks
Sajjadul

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





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


Re: [osg-users] Graphics Context and Window Handle

2013-09-22 Thread Sajjadul Islam
Hi Robert,

I am not sure if i understood you properly . Did you mean to create the context 
as follows :


Code:


class Context : public GraphicsOperation
{

public:
   Context() : osg::GraphicsOperation(Context,false)
   {
// initialize some of the opencl related member variables
   }


   virtual void operator() (osg::GraphicsContext *gc)
   {
   //in the argument we get the current and valid graphics context
   //that i shall cast to the OS specific handle and then i shall 
initialize all the 
   //opencl related variables here
   }

   //declare some opencl related variables here


}





Inside the main function i do the following  as mentioned in osgvolume:


Code:

int main()
{
...
...
osg::ref_ptrContext context = new Context;

viewer.setRealizeOperation(context.get());

.


}




Please let me know i got you right. 


One more thing  I want the Context class to be available to the rest of the 
other files in the application . So i was thinking to declare the Context 
object as follows instead :


Code:

   //create a singleton opencl context to make sure that
   //we are only working on one context
   osgOpenCL::SingletonosgOpenCL::Context::init();

   
viewer.setRealizeOperation(osgOpenCL::SingletonosgOpenCL::Context::getPtr());




It will be nice to hear from you if there is better way to access Context class 
variables. 
I saw that GraphicsOperation constructor takes a boolean variable keep. All the 
examples shows that the boolean variable is initialized to false. What is the 
purpose of this variable ? 

Thanks,
Sajjadul

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





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


Re: [osg-users] Graphics Context and Window Handle

2013-09-19 Thread Sajjadul Islam
Thanks Robert,

I am providing you with more details on this.  I think i am realizing the 
graphics window before using the handle. Still to make sure i am providing with 
the code for your kind review.
Please Check the following code snippet:


Code:

int main(int argc, char *argv[])
{
   osg::setNotifyLevel( osg::FATAL );

   //load the model
   osg::ref_ptrosg::Node model = osgDB::readNodeFile(cow.osg);
   
   //
   // SETUP VIEWER //
   //
   osgViewer::Viewer viewer;
   viewer.addEventHandler(new osgViewer::StatsHandler);
   viewer.addEventHandler(new osgOpenCL::StatsHandler);
   viewer.addEventHandler(new osgViewer::HelpHandler);
   viewer.setUpViewInWindow( 50, 50, 640, 480);
   viewer.getCamera()-setClearColor( osg::Vec4(0.15, 0.15, 0.15, 1.0) );

   //create a singleton opencl context to make sure that
   //we are only working on one context
   osgOpenCL::SingletonosgOpenCL::Context::init();
   
   
osgOpenCL::SingletonosgOpenCL::Context::getPtr()-setupOsgOpenCLAndViewer(viewer);

   viewer.setSceneData(setupScene());

   return viewer.run();

}



 

osgOpenCL::SingletonosgOpenCL::Context::getPtr()-setupOsgOpenCLAndViewer(viewer);
  is doing the OpenCL context creation from the OpenGL context. As i mentioned 
before you do not need to worry about OpenCL related stuff. Now Lets get indie 
the function setupOsgOpenCLAndViewer(viewer)


Code:

   bool Context::setupOsgOpenCLAndViewer(osgViewer::ViewerBase viewer,
  int ctxID /*= -1 */)
   {
  // You must use single threaded version since osgCompute currently
  // does only support single threaded applications.
  viewer.setThreadingModel( osgViewer::ViewerBase::SingleThreaded );

  // Does create a single OpenGL context
  // which is not released at the end of a frame to secure
  // CUDA launches everywhere
  viewer.setReleaseContextAtEndOfFrameHint(false);

  // Create the current OpenGL context and make it current
  if( !viewer.isRealized() )
 viewer.realize();

  osgViewer::ViewerBase::Contexts ctxs;
  //return a list of all active contexts
  viewer.getContexts( ctxs, true );

  //make sure that we are not getting any empty context
  if( ctxs.empty() )
  {
 osg::notify(osg::FATAL) __FUNCTION__  : no valid OpenGL context is 
found.std::endl;
 return false;
  }


  osg::GraphicsContext* ctx = NULL;


  if( ctxID != -1 )
  {   // Find context with ctxID and make it current.
 for( unsigned int c=0; cctxs.size(); ++c )
 {
if( ctxs[c]-getState()-getContextID() == ctxID )
{
   ctx = ctxs[c];
}
 }
  }
  else
  {
//make the very first context in the list
//the current context
ctx = ctxs.front();
  }

  //make sure that the context is not NULL
  if( NULL == ctx )
  {
osg::notify(osg::FATAL) __FUNCTION__  : cannot find valid OpenGL 
context.std::endl;
return false;
  }

  if(!setupDeviceAndContext(*ctx))
  {
 osg::notify(osg::FATAL) __FUNCTION__  : cannot setup OpenGL with 
OpenCL.std::endl;
 return false;
  }
  return true;
   }




Now Inside the setupDeviceAndContext() i am doing the opencl initialization and 
only part of the snippet is related for your review. Here it goes:


Code:

   bool Context::setupDeviceAndContext(osg::GraphicsContext ctx)
   {
  if( ctx.getState() == NULL )
  {
 osg::notify(osg::WARN)
 __FUNCTION__  : osg::GraphicsContext must have a valid state.
 std::endl;

 return false;
  }

  // Use first context to be found and make it current.
  ctx.makeCurrent();

  if( NULL != osgCompute::GLMemory::getContext() 
  osgCompute::GLMemory::getContext()-getState()-getContextID() != 
ctx.getState()-getContextID() )
  {
 osg::notify(osg::WARN)
 __FUNCTION__  : osgOpenCL can handle only a single context.
  However multiple contexts are detected.
  Please make sure to share a GL context among all windows.
 std::endl;

 return false;
  }

  // Bind context to osgCompute::GLMemory
  if( osgCompute::GLMemory::getContext() == NULL )
 osgCompute::GLMemory::bindToContext( ctx );
  else
 return false;


#ifdef defined(_WIN32)
  osgViewer::GraphicsHandleWin32 *windowsContext = NULL;
#elif defined( __GNUC__)
  osgViewer::GraphicsHandleX11 *linuxContext = NULL;
#elif defined( __APPLE__ )
  osgViewer::GraphicsHandleCarbon *osxContext = NULL;
#endif

  //platform dependent casting for the OpenCL context creation
#ifdef defined(_WIN32)
  windowsContext = dynamic_castosgViewer::GraphicsHandleWin32*(ctx);

  if(NULL == windowsContext)
  {
 osg::notify(osg::FATAL)  Win32 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
#elif defined(__GNUC__)
  linuxContext = 

[osg-users] Graphics Context and Window Handle

2013-09-18 Thread Sajjadul Islam
Hi forum, 

I think Graphics Context actually encapsulates information on the way in which 
scene objects are drawn and rendering states are applied. OSG uses the 
osg::GraphicsContext class to represent the abstract graphics context. 

In one of the functions that i am writing now, takes a osg::GraphicsContext 
class object as parameter and from this i need to derive a OS specific window 
handle and i am not sure how to do it. I did not find any example to it either. 

Right now i am doing it in the following manner and i think it is not correct. 


Code:


#ifdef _WIN32
#include osgViewer/api/Win32/GraphicsHandleWin32
#elif defined(__GNUC__)
#include osgViewer/api/X11/GraphicsHandleX11
#elif defined( __APPLE__)
#include osgViewer/api/Carbon/GraphicsHandleCarbon
#endif
..
..

bool Context::setupDeviceAndContext(osg::GraphicsContext ctx)
{
...
#ifdef defined(_WIN32)
  osgViewer::GraphicsHandleWin32 *windowsContext = NULL;
#elif defined( __GNUC__)
  osgViewer::GraphicsHandleX11 *linuxContext = NULL;
#elif defined( __APPLE__ )
  osgViewer::GraphicsHandleCarbon *osxContext = NULL;
#endif

  //platform dependent casting for the OpenCL context creation
#ifdef defined(_WIN32)
  windowsContext = dynamic_castosgViewer::GraphicsHandleWin32*(ctx);

  if(NULL == windowsContext)
  {
 osg::notify(osg::FATAL)  Win32 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
#elif defined(__GNUC__)
  linuxContext = dynamic_castosgViewer::GraphicsHandleX11*(ctx);

  if(NULL == linuxContext)
  {
 osg::notify(osg::FATAL)  X11 Graphics Context Casting is unsuccessful 
 std::endl;
 return false;
  }
#elif defined(__APPLE__)
  osxContext = dynamic_castosgViewer::GraphicsHandleCarbon*(ctx);

  if(NULL == osxContext)
  {
 osg::notify(osg::FATAL)  MACOSX Graphics Context Casting is 
unsuccessful.   std::endl;
 return false;
  }
#endif

}




.
I need this OS specific Window Handle to create a context property for OpenCL 
device as follows:


Code:

 cl_context_properties contextProperties[] =
{
#ifdef defined(_WIN32)
   CL_CONTEXT_PLATFORM, (cl_context_properties) _m_clPlatform,
   CL_GL_CONTEXT_KHR, (cl_context_properties) 
windowsContext-getWGLContext(),
   CL_WGL_HDC_KHR, (cl_context_properties) windowsContext-getHDC(),
#elif defined(__GNUC__)
   CL_CONTEXT_PLATFORM, (cl_context_properties) _m_clPlatform,
   CL_GL_CONTEXT_KHR, (cl_context_properties) 
linuxContext-getContext(),
   CL_GLX_DISPLAY_KHR, (cl_context_properties) 
linuxContext-getDisplay(),
#elif defined(__APPLE__)
   CGLContextObj glContext = CGLGetCurrentContext(); // get the current 
GL context
   CGLShareGroupObj shareGroup = CGLGetShareGroup(glContext); // share 
group

   CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
   (cl_context_properties) shareGroup,
#endif
   0
};





You do not need to worry about the OpenCL stuff here. I just need to know how 
to derive OS specific window handles from osg::GraphicsContext ?

Is it the proper way to do it as i am doing right now ? I am having trouble in 
this manner because OpenCL context creation is giving me undefined behavior. 

If i  am correct , then i have to concentrate some where else in the code.

I really need your hint over this issue.
 

Cheers,
Sajjadul

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





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


[osg-users] complete texture

2013-09-16 Thread Sajjadul Islam
Hi,

Does the following line return a complete texture object 


Code:

osg::Texture::TextureObject* tex = _texref-getTextureObject( 
osgCompute::GLMemory::getContext()-getState()-getContextID() );




I am going through a source and to map it to my own requirement i need to know 
if i have a complete texture or not.



Thanks
Sajjadul

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





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


[osg-users] OSG and OpenGL command

2013-07-13 Thread Sajjadul Islam
Hi forum,

I believe that there are 3 ways to integrate opengl commands into the OSG.

1. Derive and customize a osg::Drawable class.
2. Define the pre-draw and post-draw callbacks that are defined in the 
osg::Camera class.
3. Make use of the rendering context directly. Now is it fine to issue OpenGL 
command once the rendering context is made current ? 

At the very beginning of the initialization i make sure that i am dealing with 
single threaded application. 

Regards,
Sajjadul

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





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


[osg-users] [osgCompute] OpenGL sync object and OSG

2013-07-11 Thread Sajjadul Islam
Hi forum,

To Synchronize the data transfer between the GPU(OpenCL) and CPU i need to use 
the OpenGL Sync object. If i have to code in OpenGL , the snippet could be laid 
out as follows:


Code:


cl_event release_event;
cl_int  errNum;

//OpenGL fence object is created. This creates and inserts a fence sync into
//OpenGL command stream
GLSync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE,0);

//The following command creates an OpenCL event linked to the fence. The OpenCL 
//event is then used in the event list for clEnqueueAcquireGLObjects(), 
ensuring that
//the acquire call will proceed only after the fence has completed. 
cl_event gl_event = clCreateEventFromGLsyncKHR(context,sync,NULL);

errNum = clEnqueueAcquireGLObjects(commandQueue,1,cl_tex_mem,0,gl_event,NULL);

//Several other OpenCL commands go on here - mainly kernel execution that will 
//be handled by the computation node


//The following command will return an event object and stored in the 
release_event. 
//It can be used to sync upon its completion
errNum = 
clEnqueueReleaseGLObjects(commandQueue,1,cl_tex_mem,0,NULL,release_event);

//creates the OpenGL sync object linked to the release_event
GLsync cl_sync = glCreateSyncFromCLeventARB(context, release_event,0);

//a wait is inserted into the OpenGL command stream
//that will wait upon the completion of the release_event associated with the 
clEnqueueReleaseGLObjects(). 
glWaitSync(cl_sync,0, GL_TIMEOUT_IGNORED);



 

Please Avoid the OpenCL references if it does not make any sense to you. I need 
some hint on how the gl commands will be distributed in pre and post draw 
callbacks.

Should i create two separate classes that deals with the pre draw callback and 
post draw callback or just post draw callback will be enough?



Best Regards
Sajjadul

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





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


[osg-users] glFinish

2013-06-29 Thread Sajjadul Islam
Hi forum,

I have a class that indirectly inherits from osg::Object and in some functions 
of the custom class's public function i have to use the OpenGL call 
glFinish() to make sure that all the OpenGL calls encapsulated inside the OSG 
has finished execution. Is there any equivalent function is OSG that does the 
same as glFinish ?



Thank you!

Cheers,
Sajjadul

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





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


[osg-users] osg Notification

2013-05-24 Thread Sajjadul Islam
Hi forum,

I am going through a source of a plugin and they have mentioned something as 
follows:


Code:

.
.
 osg::notify(osg::WARN)   
 __FUNCTION__  : osg::GraphicsContext must have a valid state.
 std::endl;






What is __FUNCTION__ here ?


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] OSX rendering context

2013-05-11 Thread Sajjadul Islam
Hi forum,

I need to dynamically cast the osgviewer graphics context to more platform 
specific context for some platform oriented window creation .  I am doing it as 
followS:


Code:

#ifdef WIN32
dynamic_castosgViewer::GraphicsHandleWin32*( firstContext )
#else
dynamic_castosgViewer::GraphicsHandleX11*( firstContext )
#endif


 


What would be the handle for OSX ? 

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] OpenCL context creation

2013-05-08 Thread Sajjadul Islam
Hi forum,

I believe that there are similar threads almost about this issue, but they did 
not answer the problem i am having now. I have been the going through the 
source of osgCuda and took the hint from it about context creation. I created a 
separate class that handles all the OpenCL context creation from osg as follows:


Code:

  osgOpenCLContext::osgOpenCLContext(): m_clContext(NULL),
 m_clPlatform(NULL),
 m_clDevice(NULL),
 m_clCommandQueue(NULL)
   {

   }

   osgOpenCLContext::~osgOpenCLContext()
   {
  if(m_clCommandQueue) clReleaseCommandQueue(m_clCommandQueue);
  if(m_clContext) clReleaseContext(m_clContext);
   }


   bool osgOpenCLContext::setupOsgOpenCLAndViewer(osgViewer::ViewerBase viewer,
  int ctxID /*= -1 */)
   {
  // You must use single threaded version since osgCompute currently
  // does only support single threaded applications. 
  viewer.setThreadingModel( osgViewer::ViewerBase::SingleThreaded );
  
  // Does create a single OpenGL context
  // which is not released at the end of a frame to secure 
  // CUDA launches everywhere
  viewer.setReleaseContextAtEndOfFrameHint(false);
  
  // Create the current OpenGL context and make it current
  if( !viewer.isRealized() )
 viewer.realize();
  
  osgViewer::ViewerBase::Contexts ctxs;
  viewer.getContexts( ctxs, true );

  if( ctxs.empty() )
  {
 osg::notify(osg::FATAL) __FUNCTION__  : no valid OpenGL context 
is found.std::endl;
 return false;
  }


  osg::GraphicsContext* ctx = NULL;

#ifdef WIN32
  osgViewer::GraphicsHandleWin32 *windowsContext = NULL;
#else
  osgViewer::GraphicsHandleX11 *linuxContext = NULL;
#endif
  
  if( ctxID != -1 )
  {   // Find context with ctxID and make it current.
 for( unsigned int c=0; cctxs.size(); ++c )
 {
if( ctxs[c]-getState()-getContextID() == ctxID )
{   
   ctx = ctxs[c];
}
 }
  }
  else
  {   
 ctx = ctxs.front();
  }

  if( NULL == ctx )
  {
 osg::notify(osg::FATAL) __FUNCTION__  : cannot find valid OpenGL 
context.std::endl;
 return false;
  }
 
  //platform dependent casting
#ifdef WIN32
  windowsContext = dynamic_castosgViewer::GraphicsHandleWin32*(ctx);
  
  if(NULL == windowsContext)
  {
 osg::notify(osg::FATAL)  Win32 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
  else
 osg::notify(osg::INFO)  Win32 Graphics Context Casting is 
successful  std::endl;  
  
#else
  linuxContext = dynamic_castosgViewer::GraphicsHandleX11*(ctx);
  
  if(NULL == linuxContext)
  {
 osg::notify(osg::FATAL)  X11 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
  else
 osg::notify(osg::INFO)  X11 Graphics Context Casting is successful 
 std::endl;
  
#endif


  cl_uint numPlatforms;
  cl_platform_id  *platformIDs;
  cl_int errNum;  
  
  //first query the total number of platforms
  errNum = clGetPlatformIDs(0,NULL,numPlatforms);
  
  if(errNum != CL_SUCCESS || numPlatforms = 0)
  {
 osg::notify(osg::FATAL)  Failed to find any OpenCL platform  
std::endl;
 return false;
  }
  
  //next, allocate memory for the installed platforms, and query
  //to get the list
  platformIDs = (cl_platform_id *)alloca(sizeof(cl_platform_id) * 
numPlatforms);


  errNum = clGetPlatformIDs(numPlatforms,platformIDs,NULL);

  if(errNum != CL_SUCCESS)
  {
 osg::notify(osg::FATAL)  Failed to find any OpenCL platform  
std::endl;
 return false;
  }


  //now choose the very first platform
  m_clPlatform = platformIDs[0];


  char cBuffer[1024];
  
  //get the platform information from the selected platform
  errNum = 
clGetPlatformInfo(m_clPlatform,CL_PLATFORM_NAME,sizeof(cBuffer),cBuffer,NULL);

  if(errNum == CL_SUCCESS)
  {
 osg::notify(osg::INFO)  OpenCL platform name:   cBuffer  
std::endl;
  }

  

  //by now the graphics context is found
  //and the platform id is also found
  cl_context_properties contextProperties[] =
  {
#ifdef WIN32
 CL_GL_CONTEXT_KHR, (cl_context_properties) 
windowsContext-getWGLContext(),
 CL_WGL_HDC_KHR, (cl_context_properties) windowsContext-getHDC(),
#else
 CL_GL_CONTEXT_KHR, (cl_context_properties) linuxContext-getContext(),
 CL_GLX_DISPLAY_KHR, (intptr_t) linuxContext-getDisplay(),
#endif
 CL_CONTEXT_PLATFORM, (cl_context_properties) m_clPlatform, 
 0  
  };



  //create context with the 

[osg-users] Graphics Handler

2013-04-29 Thread Sajjadul Islam
Hi,

Getting error while declaring the following :


Code:

  osgViewer::GraphicsHandleX11 *linuxContext = NULL;
  osgViewer::GraphicsHandleWin32 *windowsContext = NULL;

  if( ctxID != -1 )
  {   // Find context with ctxID and make it current.
 for( unsigned int c=0; cctxs.size(); ++c )
 {
if( ctxs[c]-getState()-getContextID() == ctxID )
{   
   ctx = ctxs[c];
}
 }
  }
  else
  {   
 ctx = ctxs.front();
  }

  if( NULL == ctx )
  {
 osg::notify(osg::FATAL) __FUNCTION__  : cannot find valid OpenGL 
context.std::endl;
 return false;
  }
 
  //platform dependent casting
  #ifdef WIN32
  windowsContext = dynamic_castGraphicsHandleWin32*(ctx);

  if(NULL == windowsContext)
  {
 osg::notify(osg::FATAL)  Win32 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
  
  #else
  linuxContext = dynamic_castGraphicsHandleX11*(ctx);

  if(NULL == linuxContext)
  {
 osg::notify(osg::FATAL)  X11 Graphics Context Casting is 
unsuccessful  std::endl;
 return false;
  }
  
  #endif
  

  //by now the graphics context is found
  //and the platform id is also found

  cl_context_properties contextProperties[] =
  {
#ifdef WIN32
 CL_GL_CONTEXT_KHR, (cl_context_properties) 
windowsContext-getWGLContext(),
 CL_WGL_HDC_KHR, (cl_context_properties) windowsContext-getHDC(),
#else
 CL_GL_CONTEXT_KHR, (cl_context_properties) 
linuxContext-getGLXContext(),
 CL_GLX_DISPLAY_KHR, (intptr_t) linuxContext-getDisplay(),
#endif
 CL_CONTEXT_PLATFORM, (cl_context_properties) m_clPlatform, 
 0  
  };





the error is :


Code:

 
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:87:7:
 error: ‘GraphicsHandleWin32’ is not a member of ‘osgViewer’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:87:39:
 error: ‘windowsContext’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:35:
 error: expected type-specifier before ‘GraphicsHandleX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:35:
 error: expected ‘’ before ‘GraphicsHandleX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:35:
 error: expected ‘(’ before ‘GraphicsHandleX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:35:
 error: ‘GraphicsHandleX11’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:35:
 note: suggested alternative:
/usr/local/include/osgViewer/api/X11/GraphicsHandleX11:44:24: note:   
‘osgViewer::GraphicsHandleX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:53:
 error: expected primary-expression before ‘’ token
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:59:
 error: expected ‘)’ before ‘;’ token
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:141:60:
 error: ‘class osgViewer::GraphicsHandleX11’ has no member named ‘getGLXContext’
make[2]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o] 
Error 1
make[1]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/all] Error 2





 
What should be the file inclusion to get it right? I have included as follows:


Code:

#include osg/Notify

#ifdef WIN32
#include  osgViewer/api/Win32/GraphicsHandleWin32
#else
#include  osgViewer/api/X11/GraphicsHandleX11
#endif






Any idea ?

Cheers,
Sajjadul

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





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


[osg-users] META_OBJECT

2013-04-28 Thread Sajjadul Islam
Hi forum,

I am extending a osg::Object as follows:


Code:

class LIBRARY_EXPORT osgOpenCLContext : public osg::Object
{
public:
osgOpenCLContext();

META_OBJECT(osgOpenCL,osgOpenCLContext);


bool setupOsgOpenCLAndViewer(osgViewer::ViewerBase 
viewer,
 int ctxID = -1);

~osgOpenCLContext();

  };




And i am getting the following error among many others:


Code:

[ 62%] Building CXX object 
src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o
In file included from 
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:7:0:
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:16:
 error: ‘osgOpenCL’ is not a type
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:22:42:
 error: ISO C++ forbids declaration of ‘META_OBJECT’ with no type [-fpermissive]





Any idea folks ? i used to know that META_Object and META_Node are just 
convenience macro's that help streamline
the writing of subclasses, have a look at their definition to see what they
do.  The methods that these macros implement are useful for implementing IO
and other ops that require richer RTTI info that C++ provides by default. 

Please fill out if i miss anything in the process

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] META_OBJECT

2013-04-28 Thread Sajjadul Islam
Hi,

If you take a look into the Resource of osgCompute you will also find that they 
have declared META_OBJECT as all caps and they have the declared the copy 
constructor in the private scope and they are not defined in the source, i find 
this strange though.But It compiled fine. 

Now i am extending the this plugin and i am having error while trying to 
compile the following class. (Now i am including the while class definition).


Code:

#ifndef OSGOPENCL_CONTEXT
#define OSGOPENCL_CONTEXT 1

#include osgOpenCL/osgOpenCLDefines


#include osg/GL
#include osg/ref_ptr
#include osg/Referenced
#include osgViewer/ViewerBase

#include osgCompute/Export
#include osgCompute/Callback


namespace osgOpenCL
{
class LIBRARY_EXPORT osgOpenCLContext : public osg::Object
{
public:
osgOpenCLContext();

META_OBJECT(osgOpenCL,osgOpenCLContext);

bool setupOsgOpenCLAndViewer(osgViewer::ViewerBase 
viewer,
 int ctxID = -1);

~osgOpenCLContext();

public:


 //typedef the list of the device within the context
 //IN THIS INITIAL VERSION WE ARE ONLY CONSIDERING ONE 
DEVICE ON ONE CONTEXT
 //SO COMMENT THE FOLLOWING 
 //typedef 
std::vectorosg::ref_ptrosgOpenCL::osgOpenCLDevice  osgOpenCLDeviceList;

 //declare the device list
 //osgOpenCLDeviceList m_osgOpenCLDeviceList;

 //hold the current OpenCL context
 cl_context m_clContext;

 //hold the current platform id
 cl_platform_id m_clPlatform;

 //hold the current device id
 cl_device_id m_clDevice;

 //hold the command queue for the device
 cl_command_queue m_clCommandQueue;

 private:
 // Copy constructor and operator should not be called
 osgOpenCLContext(const osgOpenCLContext ,const 
osg::CopyOp ) {}
 osgOpenCLContext operator=(const osgOpenCLContext) { 
return *this; } 

};
}


#endif





Any more idea to get around this issue?

Cheers,
Sajjadul

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





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


Re: [osg-users] META_OBJECT

2013-04-28 Thread Sajjadul Islam
Hi again,

I should have posted the whole compilation error in the previous post. Here it 
goes:


Code:

sajjad@sajjad-G74Sx:~/Downloads/OpenSceneGraph/osgCompute/osgCompute$ make
[ 15%] Built target osgCompute
[ 25%] Built target osgCuda
[ 32%] Built target osgCudaUtil
[ 55%] Built target osgdb_serializers_osgCuda
[ 57%] Built target osgCudaStats
[ 60%] Built target osgCudaInit
[ 62%] Building CXX object 
src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o
In file included from 
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:10:0:
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:16:
 error: ‘osgOpenCL’ is not a type
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:42:
 error: ISO C++ forbids declaration of ‘META_OBJECT’ with no type [-fpermissive]
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:23:4:
 error: cannot declare parameter ‘anonymous’ to be of abstract type 
‘osgOpenCL::osgOpenCLContext’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/include/osgOpenCL/osgOpenCLContext:18:23:
 note:   because the following virtual functions are pure within 
‘osgOpenCL::osgOpenCLContext’:
/usr/local/include/osg/Object:71:25: note:  virtual osg::Object* 
osg::Object::cloneType() const
/usr/local/include/osg/Object:75:25: note:  virtual osg::Object* 
osg::Object::clone(const osg::CopyOp) const
/usr/local/include/osg/Object:82:29: note:  virtual const char* 
osg::Object::libraryName() const
/usr/local/include/osg/Object:86:29: note:  virtual const char* 
osg::Object::className() const
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:
 In member function ‘bool 
osgOpenCL::osgOpenCLContext::setupOsgOpenCLAndViewer(osgViewer::ViewerBase, 
int)’:
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26:
 error: expected type-specifier before ‘GraphicsWindowX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26:
 error: expected ‘’ before ‘GraphicsWindowX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26:
 error: expected ‘(’ before ‘GraphicsWindowX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26:
 error: ‘GraphicsWindowX11’ was not declared in this scope
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:26:
 note: suggested alternative:
/usr/local/include/osgViewer/api/X11/GraphicsWindowX11:30:24: note:   
‘osgViewer::GraphicsWindowX11’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:44:
 error: expected primary-expression before ‘’ token
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:103:50:
 error: expected ‘)’ before ‘;’ token
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:121:51:
 error: ‘class osg::GraphicsContext’ has no member named ‘getGLXContext’
/home/sajjad/Downloads/OpenSceneGraph/osgCompute/osgCompute/src/osgOpenCL/osgOpenCLContext.cpp:122:39:
 error: ‘class osg::GraphicsContext’ has no member named ‘getDisplay’
make[2]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/osgOpenCLContext.cpp.o] 
Error 1
make[1]: *** [src/osgOpenCL/CMakeFiles/osgOpenCL.dir/all] Error 2
make: *** [all] Error 2





Thank you!

Cheers,
Sajjadul

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





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


[osg-users] singleton instane

2013-04-26 Thread Sajjadul Islam
Hello forum,

I have a class declaration and i want to create a singleton instance to it. 

Is there any utility class inside OSG that enables something like this?

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] LIBRARY_EXPORT

2013-04-26 Thread Sajjadul Islam
Hi forum,

I see the the declaration of LIBRARY_EXPORT  along with function and class 
declaration as the following form. Some explanation will be appreciated.


Code:

bool LIBRARY_EXPORT setupDevice(int device = 0);




and 


Code:

class LIBRARY_EXPORT Resource : public osg::Object
{

}






Thank you!

Cheers,
Sajjadul

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





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


[osg-users] META_OBJECT

2013-04-26 Thread Sajjadul Islam
Hi forum,

Is that mandatory to declare the META_OBJECT() for every class declaration 
that derives from osg::Object ?

What is its purpose? How to decide the parameters inside it ?

Is the osg reference site down ? trying to access the osg::Object reference 

Thank you!

Regards
Sajjadul

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





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


[osg-users] rendering context

2013-04-16 Thread Sajjadul Islam
Hi forum,

I need to get the handle of the current OpenGL rendering context and handle to 
the device context. 

Is there any class in OSG that provides us with these information in a platform 
independent manner. Theses functions are accessed in the windows platform 
through windows.h , in linux through glx.h.

Or may be i need to use some macros to deal with different platforms.  

I need those information to initialize an OpenCL context to share the resources.


Your inputs will be greatly appreciated!

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] site down ?

2013-04-16 Thread Sajjadul Islam
Hi,

Can anyone access the following osg site ? 

http://www.openscenegraph.org/

Cheers,
Sajjadul

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





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


[osg-users] [osgCompute] Export in osgCuda

2013-04-14 Thread Sajjadul Islam
Hi forum,

There is an Export file inside the osgCuda/include/ 

Could anyone explain its purpose ?


I am trying to extend osgcompute for opencl and would it be fine to clone the 
file contents for opencl as well like osgOpenCL/include/osgOpenCLExport or i 
have to make some changes ?

Looking forward to some discussion over this issue. 


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] [osgCompute] documentation

2013-04-13 Thread Sajjadul Islam
Hi,

Is the doxygen documentation really updated. Once i go through the source and 
doxygen i get confused. 

There is no reference to the osgCuda::Buffer in the documentation 


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] [osgCompute] osgCompute restrictions

2013-04-10 Thread Sajjadul Islam
Hi,

In the osgCompute home page it is mentioned that 

The Driver API is currently not supported by osgCuda

what exactly does it mean? I have the latest nvidia driver installed on gtx 
560m and cuda tool-kit 4.2.

Would someone put more light on to this ?


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] [osgCompute] osgTraceDemo

2013-04-10 Thread Sajjadul Islam
Hi forum,

I am getting the following error while trying to run the osgTraceDemo.


Code:

InputStream::readObject(): Unsupported wrapper class osgCuda::Program
 Computation::loadComputation(): cannot find dynamic library 
osgcuda_ptclemitter.
 Computation::loadComputation(): cannot find dynamic library osgcuda_ptcltracer.
[2]+  Done./osgTexDemo






The rest of the examples executed fine.


Any idea ?

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] basic shader implementation

2013-02-17 Thread Sajjadul Islam
Hi forum,

I am trying to implement the diffuse shading using shaders and i need to access 
the model view and projection matrix in the shader. There are built-in uniform 
variables in osg to get those information. 

Is it possible to extract the model , view and projection matrices separately ?

There is only function i found in the sceneview.cpp to extract the viewmatrix 
by the following snippet:


Code:

stateset-getOrCrateUniform(); 




Is there any unifroms to find the rest of the matrices?

In one of the post robert suggested to enable the following:


Code:

osgState state;
state.setUseModelViewAndProjectionUniforms(true); 




How to set the state to the model on which i shall do the shading calculation ?

So far i only know how to extract the stateset of the model by the following 
call:


Code:

osg::StateSet* stateset = model-getOrCreateStateSet();





If there any examples in the repository answer to all my questions, please 
refer me to it.


Thanks
Sajjadul

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





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


[osg-users] osgdepthpeeling or osgoit

2013-02-16 Thread Sajjadul Islam
Hi forum,

are both the same is theory ? What are the differences between them 
implementation-wise ?


Cheers,
Sajjadul

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





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


[osg-users] basic texturing

2013-02-14 Thread Sajjadul Islam
Hi forum, 

I have a textue2D object with a image and i want to warp each face of the cube 
with the same texture. 

In OpenGL, i generate the texture coordinates for each of the cube faces. 

How do it OSG? I have been trying the following, but getting the distorted 
result:


Code:

osg::ref_ptrosg::Vec2Array texCoords = new osg::Vec2Array;
texCoords-push_back(osg::Vec2(0.0f,0.0f));
texCoords-push_back(osg::Vec2(0.0f,1.0f));
texCoords-push_back(osg::Vec2(1.0f,1.0f));
texCoords-push_back(osg::Vec2(1.0f,0.0f));

geom-setTexCoordArray(0,texCoords.get());




The above snippet works fine for one face only and rest of the faces get 
distorted.
I am rendering each element as quad follows:


Code:

// Add primitiveset to draw a cube
osg::ref_ptrosg::DrawElementsUInt drawingElements = new 
osg::DrawElementsUInt(GL_QUADS);

//front face
drawingElements-push_back(0);
drawingElements-push_back(1);
drawingElements-push_back(5);
drawingElements-push_back(4);

//right face
drawingElements-push_back(1);
drawingElements-push_back(2);
drawingElements-push_back(6);
drawingElements-push_back(5);
...
...






Thanks
Sajjadul

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





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


Re: [osg-users] basic texturing

2013-02-14 Thread Sajjadul Islam
Thanks for the hint!

I think i gave you the impression that i am converting the existing opengl 
application to a osg version. It is partially right. More important is to 
understand if it is really efficient the way of duplication of the vertices 
here.

There are quite many redundancies here, any other more efficient way ?


Cheers,
Sajjadul

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





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


[osg-users] porting issue

2012-12-09 Thread Sajjadul Islam
Hi forum,

I have developed some tiny applications with some old release. Now i am trying 
to port them to the new version 3.0 .


And i am getting the following compile error that left me without much clue to 
proceed. Probably you might be able be give some useful hint.


Code:

sajjad@sajjad-G74Sx:~/Documents/realtimerendering/terrainShader$ make
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB 
-DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore 
-I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I/usr/local/include/osg 
-I/usr/local/include/osgAnimation -I/usr/local/include/osgDB 
-I/usr/local/include/osgGA -I/usr/local/include/osgManipulator 
-I/usr/local/include/osgViewer -I/usr/local/include/osgUtil -I. -o main.o 
main.cpp
In file included from /usr/local/include/osgDB/Output:20:0,
 from /usr/local/include/osgDB/DotOsgWrapper:21,
 from /usr/local/include/osgDB/Registry:26,
 from Scene.h:1,
 from main.cpp:2:
/usr/local/include/osgDB/fstream:32:1: error: invalid use of incomplete type 
‘std::fstream {aka struct std::basic_fstreamchar}’
/usr/include/c++/4.6/iosfwd:119:11: error: declaration of ‘std::fstream {aka 
struct std::basic_fstreamchar}’
/usr/local/include/osgDB/fstream:44:1: error: invalid use of incomplete type 
‘std::ifstream {aka struct std::basic_ifstreamchar}’
/usr/include/c++/4.6/iosfwd:113:11: error: declaration of ‘std::ifstream {aka 
struct std::basic_ifstreamchar}’
/usr/local/include/osgDB/fstream:56:1: error: invalid use of incomplete type 
‘std::ofstream {aka struct std::basic_ofstreamchar}’
/usr/include/c++/4.6/iosfwd:116:11: error: declaration of ‘std::ofstream {aka 
struct std::basic_ofstreamchar}’
make: *** [main.o] Error 1




 

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] installation problem on linux

2012-03-14 Thread Sajjadul Islam
Hi forum,

I am trying to compile the osg recent stable bersion from source on linux , but 
getting the following error while making:


Code:

[ 10%] Building CXX object src/osg/CMakeFiles/osg.dir/glu/libtess/sweep.o
[ 10%] Building CXX object src/osg/CMakeFiles/osg.dir/glu/libtess/dict.o
[ 10%] Building CXX object src/osg/CMakeFiles/osg.dir/glu/libtess/geom.o
[ 11%] Building CXX object src/osg/CMakeFiles/osg.dir/glu/libtess/tess.o
make[2]: *** No rule to make target `/usr/lib/i386-linux-gnu/libGL.so', needed 
by `lib/libosg.so.3.0.1'.  Stop.
make[1]: *** [src/osg/CMakeFiles/osg.dir/all] Error 2
make: *** [all] Error 2



 


Any hint to resolve this make problem?

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] Etende light source example

2012-02-16 Thread Sajjadul Islam
Hi,

Is there any example of extended light source for example , rectangular light 
source inside the osg repository. I could not locate it in the repository, 
please help me to locate if i missed it there. 

Thank you!

Cheers,
Sajjadul

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





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


[osg-users] set render bin details

2012-02-16 Thread Sajjadul Islam
Hi,

I am going through an osg example and one point there is a statement as follows:


Code:

stateset-setRenderBinDetails(-1,RenderBin);




Commenting the above statement did not make any changes to the scene.

Any explanation when one should call this function ? 

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] Etende light source example

2012-02-16 Thread Sajjadul Islam

Chris Hanson wrote:
 OpenGL FFP lights are point light sources only.
 
 Generally you have to simulate non-point light sources with arrays of lights 
 (FFP) or a custom shader (GLSL). No examples of either of these are included 
 in OSG.
 
 What are you trying to accomplish?
 
 
 
 -- 
 Chris 'Xenon' Hanson, omo sanza lettere.  http://www.alphapixel.com/ 
 (http://www.alphapixel.com/)
 Training • Consulting • Contracting
 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • 
 GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
 Digital Imaging • GIS • GPS • Telemetry • Cryptography • Digital Audio • 
 LIDAR • Kinect • Embedded • Mobile • iPhone/iPad/iOS • Android
 
  --
 Post generated by Mail2Forum



So it is posible to implement it with GLSL and could you provide me with some 
reference materials ?



I am experimenting and trying to implement summed area variance shadow mapping 
with extended light source.

And i need to define this extended light source first .

Regards
Sajjad

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





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


Re: [osg-users] Shadow Traversal Mask

2011-12-20 Thread Sajjadul Islam
Hi Robert,


Thanks for the suggestion. 

I am trying to implement variance shadow mapping technique and i have checked 
that it is not implemented in osgShadow.

It will be really nice to implement it in osg and upload it in the repository.

I used to know that shadow mapping is view-dependent. You have 
ViewDependentShadowTechnique as a subclass of the shadow technique and in turn 
DebugShadowMap subclass of ViewDependentShadowTechnique.

Then you have another class ShadowMap a subclass of ShadowTechnique. Is it also 
view independent or not ?
 


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] Shadow Traversal Mask

2011-12-19 Thread Sajjadul Islam
Hi,

In  the osgshadow example there is static int defined as follows:

static int RecieveShadowTraversalMask = 0x1

There are several other variables that has been initialized in this manner. 

Is it some kind of enumeration you did ? Some explanation will be helpful if i 
have to implement a new shadowing technique


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] OSG_EXPORT

2011-09-10 Thread Sajjadul Islam
Hello forum,

Al  the class declaration starts as follows:



Code:

class OSG_EXPORT Geometry : public Drawable
{

}





Could someone please explain the OSG_EXPORT here ?

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] OpenSceneGraph hello

2011-05-31 Thread Sajjadul Islam
Hi,

I did not post the last message. I believe my account has been cracked.

I am taking care of it. 

I am terribly sorry if the above  link disturb someone in the forum.

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] 3D texture construction and fill it with magnitudes

2011-03-04 Thread Sajjadul Islam
Hello Ulrich,

Thanks for the hint. I should have explained a little more.

I am calculating a distance map and want to store it in the 3D texture for 
pixel processing.

Which function should i used inside Texture3D to store the 3D data.

Is this data be need to be stored as image. The corresponding OpenGL 

command could be as follows:


Code:


glTexImage3D(GL_TEXTURE_3D, 0, 1, width, height, depth, 0, GL_RED, 
GL_UNSIGNED_SHORT, final.m_data);

DistanceMap final(width, height, depth, 1);

for (int z = 0; z  depth; z++) 
{
  for (int y = 0; y  height; y++) 
  {
for (int x = 0; x  width; x++) 
{
   double value = 0;
   for (int i = 0; i  3; i++) 
   {
  value += dmap(x, y, z, i)*dmap(x, y, z, i);
   }
  
   value = sqrt(value)/depth;
   if (value  1.0) 
  value = 1.0;
 
   final(x, y, z, 0) = value; 
}  
  }   
}






I want to achieve the same scenario using OSG. Even if i set  the distance map 
using the osg::Image, how do i store 3 dimensional data in image using data(int 
col,int row) where i need the depth index as well? 

Regards
Sajjadul

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





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


[osg-users] 3D texture construction and fill it with magnitudes

2011-03-03 Thread Sajjadul Islam
Hello forum,

I need to construct a 3D Texture and fill it with the magnitudes of the 
displacements.


I looked into the class Texture3D . But i did not find any operator or function
that let us to set the value at certain position in the texture as follows:

img(x,y,z) = value.

Any suggestion ?

Thank you!

Regards
Sajjadul

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





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


[osg-users] casting failure

2011-02-22 Thread Sajjadul Islam
Hi forum,

I am trying to do quite a simple thing. I declared a box geode and as follows:


Code:

boxGeode-addDrawable(new osg::ShapeDrawable(new 
osg::Box(osg::Vec3(2.0f,0.0f,0.0f),2*radius),hints.get()));




And then send this geode to a function to do the bump mapping. Inside the 
function , the parameter takes a osg::Node * . So i cast back to geode and try 
to bring out the geometry as follows:


Code:

osg::Geode *tmpGeode = dynamic_castosg::Geode *(subgraph);

osg::Geometry *tmpGeo = dynamic_castosg::Geometry *(tmpGeode-getDrawable(0));



 

But the tmpGeo gives me null pointer . I tried the following as well :


Code:

osg::Geometry *tmpGeo = dynamic_castosg::Geometry 
*(tmpGeode-getDrawable(0)-asGeometry());




So far i could not make it work. Any hint?

Thanks
Sajjadul[/code]

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





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


Re: [osg-users] Render to Texture

2010-12-15 Thread Sajjadul Islam
Hi Delport,

I am getting the several pass with  the chain effect within the dynamic scene. 
But the scene freezes after the third pass. And the scene remains frozen(i mean 
 the animation), i can only see the blurred scene.

What should i look into to debug this?

Thanks for all the useful hint you have put forward so far.

Regards
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-14 Thread Sajjadul Islam
Hi Delport,

Thanks for the support. At least i have a little bit of improvement. I can go 
upto second pass that makes the burred scene blurrer.

1. Initial scene - No blur effect.
2. First key press - Shader activated and scene blurred and scene is visualized.
3. Second key press - the scene is even more blurred and the scene freezes.
4. Fourth key press - The scene goes back to step 2.

Sceneario should be as follows:

With every key press event the scene should be more blurry. I think i am 
getting close.

Something somewhere is missing. Any hint to look into?

Thanks again!

Regards
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-14 Thread Sajjadul Islam
Hi Delport,

I am attaching the code i put inside the keyboard handler. I believe it will 
provide you with more insight to suggest.

'
class BlurPassHandler : public osgGA::GUIEventHandler
{

public:
BlurPassHandler(int key,BlurPass *bp,osg::Node *node):
_bp(bp),
_node(node),
_key(key)
{

}

bool handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter)
{
if (ea.getHandled()) return false;

switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
osg::notify(osg::NOTICE)event handlerstd::endl;

if(ea.getKey() == _key)
{
//find the node with the name in the parameter
FindNamedNode fnn(HUD);

_node-accept(fnn);

if(!_bp-shaderActive())
_bp-activateShader();
else
{
 osg::notify(osg::NOTICE)About to 
flipstd::endl;
 _bp-flip();

 //the hud cameara texture
 //has to be updated, either
 //after updating the shader
 //or after doing the flip
}

if(fnn.getNode() != NULL)
{
osg::notify(osg::NOTICE)HUD foundstd::endl;

//assign to local node variable
_node = fnn.getNode();

osg::Geode *_geode = 
dynamic_castosg::Geode*(_node);

if(_geode)
{
   osg::notify(osg::NOTICE)geode 
foundstd::endl;

   osg::Geometry *_geometry = 
dynamic_castosg::Geometry*(_geode-getDrawable(0));

   if(_geometry)
   {
   osg::notify(osg::NOTICE)geometry 
foundstd::endl;
   }

   osg::StateSet *_stateset = 
_geometry-getOrCreateStateSet();

   _stateset-setTextureAttributeAndModes(0, 
_bp-getOutputTexture().get(),osg::StateAttribute::ON);
}
}
else
{
osg::notify(osg::NOTICE)HUD not 
foundstd::endl;
}


return true;
}

break;
}
default:
break;
}

return false;
}


BlurPass *_bp;
osg::Node *_node;
int _key;

};

* 

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-14 Thread Sajjadul Islam
Hi Delport ,

Is something like happening in osggameflife without adding the pass in the 
scenegraph?

Please correct me if i m wrong.

They have multiple pass and they are are just flip flop the two output textures

... 

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-14 Thread Sajjadul Islam
Hi Delport,

I have added one more pass branch to  the graph and i can see a new behavior. 
The code snippet for it as follows:


***'

//the first pass in the scene, with the key press the following do the blur on 
the initial scene
   _ProcessPass[0] = new 
ProcessPass(_OutTextureBlur[0].get(),_OutTextureBlur[1].get(),
   _TextureWidth,_TextureHeight);

//takes the input of the first pass and blur it even more, and the screen 
freezes   
   _ProcessPass[1] = new 
ProcessPass(_OutTextureBlur[1].get(),_OutTextureBlur[0].get(),
   _TextureWidth,_TextureHeight);


//SOMETHING INTERESTING HAPPENS HERE!
//The following pass make the last scene less blur instead of more blur than 
the last frozen scene, but the scene is not frozen anymore, i can rotate around 
the model, zoom in and zoom out
   _ProcessPass[2] = new 
ProcessPass(_OutTextureBlur[0].get(),_OutTextureBlur[1].get(),
   _TextureWidth,_TextureHeight);

   _BranchSwitch[0]-addChild(_ProcessPass[0]-getRoot().get());
   _BranchSwitch[1]-addChild(_ProcessPass[1]-getRoot().get());
   _BranchSwitch[2]-addChild(_ProcessPass[2]-getRoot().get());

'***

From the above description it seems that the last pass is reversing the blur 
effect.
In ProcessPass[1] - the scene is getting more blurry. It seems that the 
ProcessPass pass is doing the job right, but in the ProcessPass[2] it isnot.


Any idea?


Thank you!

Regards
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-13 Thread Sajjadul Islam
Hi Robert  Delport,

I have the setup with 4 cameras:

1st camera - the slave camera that inherit the master camera's relative frame 
and render the scene to 2 textures with color attachments. One of the texture 
remains as it is and other texture is left for further operation.

2. 2nd camera - the camera is hung under the 1st switch which does some 
operation over the one of texture specified above.   The result of the 
operation is rendered to another texture using the camera.

3. 3rd camera - the camera is hung under the 2nd switch that does some further 
operation over the last result done in step 2. The result is rendered to  the 
texture which was the input texture in step 2.

4. 4th Camera - is the HUD camera to visualize the output of the either of the 
above operation in step 2 / step 3.


Since step 2 and 3 are Switches i make them only one enable at a time. The 
concepts are pretty simple as you can imagine. They have been picked from 
osgdistortion, osgprerender,osgstereomatch and osggameoflife.

During the first pass , i make the first switch enabled with the keypress event 
and can visualize the scene.

With the next key press event, i flip the texture for further pass over the 
result of  the last operation, But the screen freezes without showing the 
result of the operation in the HUD camera. 
 
I need some hint on what might have gone wrong. If need more elaboration please 
ask.

Thank you!

Regards
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-13 Thread Sajjadul Islam
Hi Delport,

Reasons for rendering the scene to two textrues 

With key press event i may want to show the texture using the HUD that have not 
gone through any operation. If i do any post processing on the texture the 
initial texture value is lost. I want to preserve it. This is why i render the 
same scene to two texture.

One Texture that contains the main scene and other texture also contains the 
main scene but will go through further operation.   

All the rendering are in PRE_ORDER except the HUD camera. HUD camera is using 
the NESTED_RENDER.

When the HUD camera is viewing any texture it is accessing the texture as 
follows:

***'


..

//the scene is passed to the followng class
bp = new BlurPass(subgraph,clearColour);

distortionNode-addChild(bp-getRoot().get());


...

//the following function is accessing the texture by checking first the active 
switch node
stateset-setTextureAttributeAndModes(0, 
bp-getOutputTexture().get(),osg::StateAttribute::ON);
...

osg::ref_ptrosg::Texture2D BlurPass::getOutputTexture() const
{
   int out_tex = _ActiveBranch;

   return _ProcessPass[out_tex]-getOutputTexture();
}



//inside the BlurPass class i call the following function that make one switch 
enables while making the other disabled - in other words flip fllop

void BlurPass::activateBranch()
{
   //GET THE current activate branch
   int onb = _ActiveBranch;

   osg::notify(osg::NOTICE)  on bit   onb  std::endl;

   //get teh current inactive branch
   int offb = (onb == 1) ? 0 : 1;

   osg::notify(osg::NOTICE)  off bit   offb  std::endl;

   //make the active switch on
   _BranchSwitch[onb]-setAllChildrenOn();

   //make the inactive switch off
   _BranchSwitch[offb]-setAllChildrenOff();
}


void BlurPass::flip()
{
   _ActiveBranch = (_ActiveBranch == 1) ? 0 : 1;

   osg::notify(osg::NOTICE)active branch  _ActiveBranch  std::endl;

   activateBranch();
}


BlurPass::BlurPass(osg::Node *scene, const osg::Vec4 clearColor)
:_SubGraph(scene),
_ClearColor(clearColor)
{
//pre-define the texture
//width and height, the very same size
//we preserve all over the scene
   _TextureWidth = 1280;
   _TextureHeight = 1280;

   //initially the shader is inactive
   shaderFlag = false;

   _RootGroup = new osg::Group;

   //initialize the texture where we
   //shall render the initial scene
   createInputTexture();

   //initialize the 2 output textures
   //which will be flipped with keypress 
   //for multipass blurring
   createOutputTextures();

   //camera renders the scene to the 0-indexed texture
   //that will be goiing through the blur phase in the process pass
   setupCamera();

   //create two switch to do the flip-flop
   _BranchSwitch[0] = new osg::Switch;
   _BranchSwitch[1] = new osg::Switch;


   //add the camera and the two switches

   //camera that renders the scene to the texture
   _RootGroup-addChild(_Camera.get());


   _RootGroup-addChild(_BranchSwitch[0].get());

   _RootGroup-addChild(_BranchSwitch[1].get());

   //initialize the active switch
   _ActiveBranch = 0;


   //activate the switch based on the
   //current active branch flag
   activateBranch();

//we have both input and output textures initialized and
//the _InOutTextureBlur[0] get the scene rendering that will
//going through the blur operation
   _ProcessPass[0] = new 
ProcessPass(_OutTextureBlur[0].get(),_OutTextureBlur[1].get(),
   _TextureWidth,_TextureHeight);
   
   _ProcessPass[1] = new 
ProcessPass(_OutTextureBlur[1].get(),_OutTextureBlur[0].get(),
   _TextureWidth,_TextureHeight);

   _BranchSwitch[0]-addChild(_ProcessPass[0]-getRoot().get());
   _BranchSwitch[1]-addChild(_ProcessPass[1]-getRoot().get());

   
}

//setup the render to texture camera
//the following function renders the initial scene to 2 textures
void BlurPass::setupCamera()
{
_Camera = new osg::Camera;

_Camera-setClearColor(_ClearColor);
_Camera-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


//just inherit the main cameras view
_Camera-setReferenceFrame(osg::Transform::RELATIVE_RF);
_Camera-setProjectionMatrix(osg::Matrixd::identity());
_Camera-setViewMatrix(osg::Matrixd::identity());


//set the viewport according to the value texture width and texture height
_Camera-setViewport(0,0,_TextureWidth,_TextureHeight);

//RENDER to texture before the main camera
_Camera-setRenderOrder(osg::Camera::PRE_RENDER);


//USE THE frame buffer object where supported
_Camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

//the camera with  the relative frame renders to the input texture - index 0
//this texture will be input for the process pass
_Camera-attach(osg::Camera::COLOR_BUFFER0,_InputTexture.get());



Re: [osg-users] Render to Texture

2010-12-13 Thread Sajjadul Islam
Hi Delport,

I am sorry that i did not get much from your last reply asking how am i 
changing the texture 
when i switch the branches. Do i have to explicitly specify the texture? Even 
it is i believe that it is done as follows:

stateset-setTextureAttributeAndModes(0,
bp-getOutputTexture().get(),osg::StateAttribute::ON);


bp-getOutputTexture() is retrieving the correct texture based on the value of 
the _ActiveBranch. With key press event i have a function that flips the switch 
node that turns one switch's input to other switch's output. 


If i have to call this function again where should the call go into? It seems 
that the state is dynamic and do i have to implement a state change callback ?

Thank you!

Regards
Sajjadul

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





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


Re: [osg-users] Render to Texture

2010-12-13 Thread Sajjadul Islam
Hi Delport,

I have created a new class inherating the osg::Drawable::UpdateCallback. The 
class structure is as follows:

*'
class BlurCallback : public osg::Drawable::UpdateCallback
{

public:
BlurCallback(BlurPass *bp)
:_bp(bp),
_blurImage(false)
{

}


virtual void update(osg::NodeVisitor *nv, osg::Drawable *drawable)
{
osg::Geometry *geo = dynamic_castosg::Geometry*(drawable);

osg::StateSet *state = geo-getOrCreateStateSet();

state-setTextureAttributeAndModes(0, 
_bp-getOutputTexture().get(),osg::StateAttribute::ON);
}


BlurPass *_bp;

mutable bool _blurImage;
};

**'

.
...


polyGeom-setUpdateCallback(bpCallback);




The program crashes when it reaches the viewer.run(); If the comment the above 
code 
the application runs. I think i need to implement some kind of callbacks 
implement what you have suggested in the last post. Isnt it?




Regards
Sajjadul

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





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


[osg-users] Render to Texture

2010-12-12 Thread Sajjadul Islam
Hello forum,

a scene is rendered to a texture. Is that ok to render to the same texture by 
another camera?


Thank you!


Sajjadul

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





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


[osg-users] texture coordinate specification

2010-12-10 Thread Sajjadul Islam
Hi forum,

I was going through the example osggameoflife and pondered over  the texture 
specification part to visulize  the game.

I used to know that the texture coordinate s,t,q all has to be between 0.0 and 
1.0.

At one part of the example the texture coordinate has been specified as 
foollows:

tcoords-push_back(0,0,0);
tcoords-push_back(width,0,0);
tcoords-push_back(width,0,height);
tcoords-push_back(0,0,height);

The width and height returns values more than 1 , like 128 X 128

Would be nice to have some explanation.


Thank you!

Cheers,
Sajjadul

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





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


[osg-users] instantiate image from texture

2010-12-09 Thread Sajjadul Islam
Hi forum,

The following code compiled but crashes while running.

osg::Image *image = new 
osg::Image(*(_ProcessPass[out_tex]-getOutTexture()-getImage()),osg::CopyOp::DEEP_COPY_ALL);

Any logical wrong doing ?

Thanks

Cheers,
Sajjadul

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





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


[osg-users] uniform value to shader

2010-12-05 Thread Sajjadul Islam
Hi,

In the main application i  need to send texture coordinate offset as a one 
dimensional array 

float tc_off[18];

I initialize  the above array with  the offset value and then  need to pass it 
as uniform variable. How do i accomplish it within osg.


It can be done  in OpenGL as follows:

//get a uniform location for the characer string
uniformLoc = glGetUniformLocation(progObj[shaderNum], tc_offset);

if (uniformLoc != -1)
{
glUniform2fv(uniformLoc, 9, tc_off);
}

So the value inside  tc_off is sent  to  the shader and on the shader side i 
have it as follows:

uniform vec2 tc_offset[9]; 


From the application in OpenGL we are sending 3 parameters , but how do we 
send an array in OSG?


Please correct me if i m wrong in conception


Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] Blur effect on a dynamic scene

2010-12-04 Thread Sajjadul Islam
Hi Kim,

Thanks for the suggestion. I have created the following scene graph to get the 
blur effect. 


   Group1
   |
   |
-
||
||
   Geode Group 2
||
|   
--   
 Geometry1   || 
   |
|   
 || 
 Camera1 
Switch[0]  Switch[1]
|   
 |
|   
 |
  Scene   Group

 |

 |

Camera2

 |

 |
   
Group

 |

 |
   
Geode

 |

 |

Geometry2
 

Now let me describe the graph. Geometry1 is the texture aligned quad that 
visualize the scene with HUD camera.

Group 2 has three children . First the Camera child renders the scene to a 
texture and this texture works as a input texture to be blurred.

The Other 2 children are switch[2] nodes and that are flipped with key press 
event. Initially the first switch is enabled. In  the diagram i have only 
detailed the first switch ,because the second switch is similar in structure.

When  the application loads the scene it renders to  the texture and i can 
visualize it. The output texture from one of the switches are attached to  the 
HUD camera.

Each switch also contains the camra with absolute reference frame and shader 
involved to the quad stateset

But with  the key press event i flipped the texture and then i get a blank 
screen.Any hint where should i look into to debug it?


I have using the gameoflife example to do  the texture flip-flop.

Thanks in advance!

Cheers,
Sajjadul

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





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


[osg-users] Blur effect on a dynamic scene

2010-12-03 Thread Sajjadul Islam
Hello forum,

I want to blur a dynamic scene with key press event. In that case i have to 
create a call back. 

Do i have to create subclass of the osg::Camera::DrawCallback ?

And Do i have to set that subclassed call back class to the camera's final draw 
call back or post draw callback?

These concepts are still blurry. It would be really nice to provide some 
references on these concepts. 

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] OSG and QT

2010-12-01 Thread Sajjadul Islam
Hi,

That is how a typical .pro file should look like if you want to compile osg 
with qt.


/7
TEMPLATE = app
QT += opengl

INCLUDEPATH += .
INCLUDEPATH += /usr/include/osg
INCLUDEPATH += /usr/include/osgAnimation
INCLUDEPATH += /usr/include/osgDB
INCLUDEPATH += /usr/include/osgGA
INCLUDEPATH += /usr/include/osgManipulator
INCLUDEPATH += /usr/include/osgViewer
INCLUDEPATH += /usr/include/osgUtil



LIBS += -L/usr/lib64 -losgViewer -losgDB -losgUtil -losg -losgSim

HEADERS += \
ViewerQT.h \
AdapterWidget.h \
OSGQtMainWindow.h \
Teapot.h \
SnapImage.h \
SnapImageHandler.h

SOURCES += \
AdapterWidget.cpp \
main.cpp \
OSGQtMainWindow.cpp \
ViewerQT.cpp

FORMS += \
OSGQtWindow.ui

RESOURCES +=


7

Hope it helps.

Cheers,
Sajjadul

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





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


[osg-users] save animated scene to an image

2010-11-30 Thread Sajjadul Islam
Hi,

I am trying to save the animated scene to a image file. 
I am using one of the examples named osghud where there are several classes do 
the job to snap the scene to an image file.

But now the animated scene is flickerring when ever i enable the post draw call 
back to save the scene with  a key event, the light and object animation is 
very slow.

Any   reason why it is like that?

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] issues with osgdistortion

2010-11-30 Thread Sajjadul Islam
Hi,

I believe that my previous post was not enough to elaborate the issue. So i am 
attaching some code snippet of the problem i am having after doing minor 
changes inside the osgdistortion.

***'

osg::ref_ptrosg::Node OSGQtMainWindow::createDistortedSubGraph(osg::Node 
*subGraph, osg::Camera *cam)
{
osg::ref_ptrosg::Group distortedNode = new osg::Group;

//get the viewport of the camera
osg::ref_ptrosg::Viewport viewport = cam ? cam-getViewport() : 0;

unsigned int texture_width = int(viewport-width());
unsigned int texture_height = int(viewport-height());


//create a opengl texture state;
osg::ref_ptrosg::Texture2D texture = new osg::Texture2D();
texture-setTextureSize(texture_width,texture_height);
texture-setInternalFormat(GL_RGBA);
texture-setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture-setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);


//get  the clearing color of the set camera
osg::Vec4 clearColor = cam-getClearColor();

//now setup to render to the texture camera
{
osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setClearColor(clearColor);
camera-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



//NOW inherit the main camera view
camera-setReferenceFrame(osg::Transform::RELATIVE_RF);
camera-setProjectionMatrix(osg::Matrixd::identity());
camera-setViewMatrix(osg::Matrixd::identity());


//set the viewport of the camera
camera-setViewport(0,0,texture_width,texture_height);


//set  the camera to render before the main camera
camera-setRenderOrder(osg::Camera::PRE_RENDER);



//tell  the camera to use frame buffer object where supported
camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);


//attach the texture and use it as a color buffer
//means that the rendering will be done onto the texture
camera-attach(osg::Camera::COLOR_BUFFER,texture.get());

//add the subgraph as a child
//of the camera
//to render to the texture
camera-addChild(subGraph);


distortedNode-addChild(camera.get());
}


//set up the hud camera
{
//create a quad to visualize
osg::ref_ptrosg::Geometry polyGeom = new osg::Geometry;

osg::ref_ptrosg::DrawArrays polyGeomDA = new 
osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

osg::ref_ptrosg::Vec3Array vertices  = new osg::Vec3Array;

osg::ref_ptrosg::Vec2Array texcoords = new osg::Vec2Array;

osg::ref_ptrosg::Vec4Array colors = new osg::Vec4Array;
colors-push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));

vertices-push_back(osg::Vec3d(0,0,0));
vertices-push_back(osg::Vec3d(texture_width,0,0));
vertices-push_back(osg::Vec3d(texture_width,0,texture_height));
vertices-push_back(osg::Vec3d(0,0,texture_height));

texcoords-push_back(osg::Vec2(0,0));
texcoords-push_back(osg::Vec2(texture_width,0));
texcoords-push_back(osg::Vec2(texture_width,texture_height));
texcoords-push_back(osg::Vec2(0,texture_height));


polyGeom-setVertexArray(vertices.get());
polyGeom-setTexCoordArray(0,texcoords.get());
polyGeom-addPrimitiveSet(polyGeomDA.get());
polyGeom-setColorArray(colors.get());
polyGeom-setColorBinding(osg::Geometry::BIND_PER_VERTEX);


//get or create the  stateset for this geometry
osg::ref_ptrosg::StateSet stateset = polyGeom-getOrCreateStateSet();

stateset-setTextureAttributeAndModes(0,texture.get(),osg::StateAttribute::ON);
stateset-setMode(GL_LIGHTING, osg::StateAttribute::OFF);



//create a geode
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(polyGeom.get());


//now setup  the camera to render the textured quad
osg::ref_ptrosg::Camera camera = new osg::Camera;

//inherit the main camera view
camera-setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera-setViewMatrix(osg::Matrix::identity());
camera-setProjectionMatrixAsOrtho2D(0,texture_width,0,texture_height);


camera-setRenderOrder(osg::Camera::NESTED_RENDER);


camera-addChild(geode.get());



distortedNode-addChild(camera.get());
}

return distortedNode.get();
}


*'** 

I really need some hint on it.

Thank you!

Cheers,
sajjad

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





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


Re: [osg-users] issues with osgdistortion

2010-11-30 Thread Sajjadul Islam
Hi Tim,

When i take another look at the osgdistortion example i  see that in the 
function createDistortionSubgraph() there is nothing defined as you have 
metioned.  

... 

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] save animated scene to an image

2010-11-30 Thread Sajjadul Islam
Hi Robert,

I am using the finalDrawCallBack() instead of the postDrawCallBack() and now it 
is fine as expected. I think the postDrawCallBack() could have been  the 
reason, not sure though.

Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] issues with osgdistortion

2010-11-30 Thread Sajjadul Islam
Hi Tim,

I can do  the screen capture and save the scene to an image. I want to do  the 
same thing to a texture instead.

I am doing it now through a final draw callback and i beleive that same would 
be possible to render to  the texture. What do you suggest? The render to 
texture will be done through a key press event as it is doing for saving the 
image




Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] Use OSG with QT

2010-11-29 Thread Sajjadul Islam
Hi,

I have already integrated Qt with OSG using the adapter viewer.
The frame rate is slower than  the osgviewer. 
Check  the osgviewerQt example. It provides quite a hint 

Thank you!

Cheers,
Sajjadul

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





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