Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hi, Martin iirc i've used full gl style as i cant make it work with just osg default drawimplementation + state management (like program and modes) atm (i mean i tried for a week or two and it just wasnt working, and this stuff really hard to debug when it draws crap or crashes in driver, i dont remember details as it was like two years ago or so) You can try, may be you got some luck. I think it is possible to do this with osg program and buffer objects management, then things get a lot simplier as you dont need to initialize all stuff yourself. and this was just first more or less working sample (still no multiple context safe, and may be have some other bugs), things changed quite a bit since then also with gl 4.2 you can drop queries, as you have drawTransformFeedback, but then you cant use osg draw implementation As for guides for embedding gl into osg... i dont saw any. You can dig into osg::Geometry\StateAttributes\osg::State sources to see how it done in osg itself. From my experience i can say that if you make gl state changes via gl functions yourself you should let osg know about them(check osg::State reference). If something not working try to revert all state changes you've done after your drawing (unbind buffers\arrays, revert fbo bindings, active texture units, vertex attrib arrays, programs, etc...) 01.03.2012, 20:46, "Martin Groer" : > Hello Sergey, > > thank you, it is good to know. I am a little bit frustrated. I read about > OpenGL 4.2 and transform feedback and was so happy about this. That sounds so > easy to use. By now it is hard to implement a simple first example. :-( > > I found this thread: > http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg46962.html > > You made this example, right? So far, I don't understand all the stuff. Is > this all necessary for transform feedback? > > I only need the follow functions, don't I? > > 1. glTransformFeedbackVaryings > 2. glBindBufferBase > 3. glBeginTransformFeedback > 4. glEndTransformFeedback > > For example, is a loadShaderFromFile function necessary? Is this only > necessary, because the glTransformFeedbackVaryings have to be between the > compiling and linking of the shader? > > I think my first problem is I don't have any experience with OpenGL code > embedded into osg code. Are there any examples, tutorials or articles about > this? > > I will keep on trying! > > Cheers, > Martin > > Original-Nachricht ---- > >> Datum: Thu, 01 Mar 2012 19:34:42 +0400 >> Von: Sergey Polischuk >> An: OpenSceneGraph Users >> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG >> Generally you should use interfaces provided by osg to get to opengl >> functions, as they can have different pointers in different graphics >> contexts. >> >> so it goes like >> >> typedef void (APIENTRY * TransformFeedbackVaryings)(GLuint, GLsizei, const >> GLchar **, GLenum); >> TransformFeedbackVaryings _glTransformFeedbackVaryingsPtr; >> if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, >> "glTransformFeedbackVaryings" )) >> if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, >> "glTransformFeedbackVaryingsEXT" )) >> //not supported :( >> // so now you can use this pointer in this gc >> >> also if you need some opengl functions, first check osg::GL2Extensions, it >> may be already wrapped and initialized there. >> All of this should be called with active graphics context >> >> Cheers >> >> 29.02.2012, 18:22, "Martin Groer" : >>> Hello, >>> >>> I tried this in my camera draw callback: >>> >>> virtual void operator()(const osg::Camera& camera) const >>> { >>> // GL-Context-ID >>> GLuint gcID = _gc->getState()->getContextID(); >>> >>> // GL-Program-Handle >>> osg::Program::PerContextProgram* pcp = _program->getPCP(gcID); >>> GLuint prID=pcp->getHandle(); >>> >>> const char* varyings[1] = { "vPosition" }; >>> glTransformFeedbackVaryings(prID, 1, varyings, GL_SEPARATE_ATTRIBS); >>> } >>> >>> But when I want to compile this, I get the error >> "glTransformFeedbackVaryings isn't defined". I searched in my includes and >> it is in the glext.h >> and glew.h defined. What is wrong? >>> Cheers, >>> Martin >>> >>> Original-Nachricht >>>> Datum: Tue, 28 Feb 2012 10:45:16 -0700 >>>> Von: Paul Martz >&
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hello Sergey, thank you, it is good to know. I am a little bit frustrated. I read about OpenGL 4.2 and transform feedback and was so happy about this. That sounds so easy to use. By now it is hard to implement a simple first example. :-( I found this thread: http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg46962.html You made this example, right? So far, I don't understand all the stuff. Is this all necessary for transform feedback? I only need the follow functions, don't I? 1. glTransformFeedbackVaryings 2. glBindBufferBase 3. glBeginTransformFeedback 4. glEndTransformFeedback For example, is a loadShaderFromFile function necessary? Is this only necessary, because the glTransformFeedbackVaryings have to be between the compiling and linking of the shader? I think my first problem is I don't have any experience with OpenGL code embedded into osg code. Are there any examples, tutorials or articles about this? I will keep on trying! Cheers, Martin Original-Nachricht > Datum: Thu, 01 Mar 2012 19:34:42 +0400 > Von: Sergey Polischuk > An: OpenSceneGraph Users > Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > Generally you should use interfaces provided by osg to get to opengl > functions, as they can have different pointers in different graphics contexts. > > so it goes like > > typedef void (APIENTRY * TransformFeedbackVaryings)(GLuint, GLsizei, const > GLchar **, GLenum); > TransformFeedbackVaryings _glTransformFeedbackVaryingsPtr; > if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, > "glTransformFeedbackVaryings" )) > if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, > "glTransformFeedbackVaryingsEXT" )) > //not supported :( > // so now you can use this pointer in this gc > > > also if you need some opengl functions, first check osg::GL2Extensions, it > may be already wrapped and initialized there. > All of this should be called with active graphics context > > > Cheers > > > 29.02.2012, 18:22, "Martin Groer" : > > Hello, > > > > I tried this in my camera draw callback: > > > > virtual void operator()(const osg::Camera& camera) const > > { > > // GL-Context-ID > > GLuint gcID = _gc->getState()->getContextID(); > > > > // GL-Program-Handle > > osg::Program::PerContextProgram* pcp = _program->getPCP(gcID); > > GLuint prID=pcp->getHandle(); > > > > const char* varyings[1] = { "vPosition" }; > > glTransformFeedbackVaryings(prID, 1, varyings, GL_SEPARATE_ATTRIBS); > > } > > > > But when I want to compile this, I get the error > "glTransformFeedbackVaryings isn't defined". I searched in my includes and it > is in the glext.h > and glew.h defined. What is wrong? > > > > Cheers, > > Martin > > > > Original-Nachricht > > > >> Datum: Tue, 28 Feb 2012 10:45:16 -0700 > >> Von: Paul Martz > >> An: OpenSceneGraph Users > >> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > >> On 2/28/2012 9:10 AM, "Martin Großer" wrote: > >>> Hello Paul, > >>> > >>> In OpenGL I have to define the varying variables for the transform > >> feedback between the compiling and linking of the shader program. > >>> glTransformFeedbackVaryings(programHandle, 1, varyings, > >> GL_SEPARATE_ATTRIBS); > >>> How can I do this in OSG? > >> The same way. You can issue an OpenGL call any time you have a > current > >> context > >> (Camera pre draw callback, Drawable draw callback, etc). > >> > >> A quick glance at the Program header file reveals that you can get > the > >> program > >> ID with a call to: > >> osg::Program::getPCP(contextID)->getHandle(); > >>> Additinally I use osg 2.8.4 from the Fedora repository. > >>> > >>> Cheers, > >>> Martin > >>> > >>> Original-Nachricht > >>>> Datum: Mon, 27 Feb 2012 09:51:15 -0700 > >>>> Von: Paul Martz > >>>> An: OpenSceneGraph Users > >>>> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > >>>> Yes, it's possible, but there are no examples that I know of. You > might > >>>> try > >>>> binding a buffer object in a Camera pre-draw callback, for an > example > >> of > >>>> one > >>>> strategy. > >>>> -Pa
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Generally you should use interfaces provided by osg to get to opengl functions, as they can have different pointers in different graphics contexts. so it goes like typedef void (APIENTRY * TransformFeedbackVaryings)(GLuint, GLsizei, const GLchar **, GLenum); TransformFeedbackVaryings _glTransformFeedbackVaryingsPtr; if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, "glTransformFeedbackVaryings" )) if (!osg::setGLExtensionFuncPtr(_glTransformFeedbackVaryingsPtr, "glTransformFeedbackVaryingsEXT" )) //not supported :( // so now you can use this pointer in this gc also if you need some opengl functions, first check osg::GL2Extensions, it may be already wrapped and initialized there. All of this should be called with active graphics context Cheers 29.02.2012, 18:22, "Martin Groer" : > Hello, > > I tried this in my camera draw callback: > > virtual void operator()(const osg::Camera& camera) const > { > // GL-Context-ID > GLuint gcID = _gc->getState()->getContextID(); > > // GL-Program-Handle > osg::Program::PerContextProgram* pcp = _program->getPCP(gcID); > GLuint prID=pcp->getHandle(); > > const char* varyings[1] = { "vPosition" }; > glTransformFeedbackVaryings(prID, 1, varyings, GL_SEPARATE_ATTRIBS); > } > > But when I want to compile this, I get the error "glTransformFeedbackVaryings > isn't defined". I searched in my includes and it is in the glext.h and glew.h > defined. What is wrong? > > Cheers, > Martin > > ---- Original-Nachricht > >> Datum: Tue, 28 Feb 2012 10:45:16 -0700 >> Von: Paul Martz >> An: OpenSceneGraph Users >> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG >> On 2/28/2012 9:10 AM, "Martin Großer" wrote: >>> Hello Paul, >>> >>> In OpenGL I have to define the varying variables for the transform >> feedback between the compiling and linking of the shader program. >>> glTransformFeedbackVaryings(programHandle, 1, varyings, >> GL_SEPARATE_ATTRIBS); >>> How can I do this in OSG? >> The same way. You can issue an OpenGL call any time you have a current >> context >> (Camera pre draw callback, Drawable draw callback, etc). >> >> A quick glance at the Program header file reveals that you can get the >> program >> ID with a call to: >> osg::Program::getPCP(contextID)->getHandle(); >>> Additinally I use osg 2.8.4 from the Fedora repository. >>> >>> Cheers, >>> Martin >>> >>> Original-Nachricht >>>> Datum: Mon, 27 Feb 2012 09:51:15 -0700 >>>> Von: Paul Martz >>>> An: OpenSceneGraph Users >>>> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG >>>> Yes, it's possible, but there are no examples that I know of. You might >>>> try >>>> binding a buffer object in a Camera pre-draw callback, for an example >> of >>>> one >>>> strategy. >>>> -Paul >>>> >>>> On 2/27/2012 8:21 AM, "Martin Großer" wrote: >>>>> Hello, >>>>> >>>>> Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in >> osg? >>>> I would like write back my vertex position data into a new Vertex >> Buffer >>>> Object. Is there any example about this? >>>>> Cheers >>>>> >>>>> Martin >>>> ___ >>>> osg-users mailing list >>>> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> ___ >> osg-users mailing list >> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- > NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! > Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
On 02/29/2012 09:22 AM, "Martin Großer" wrote: Hello, I tried this in my camera draw callback: virtual void operator()(const osg::Camera& camera) const { // GL-Context-ID GLuint gcID = _gc->getState()->getContextID(); // GL-Program-Handle osg::Program::PerContextProgram* pcp = _program->getPCP(gcID); GLuint prID=pcp->getHandle(); const char* varyings[1] = { "vPosition" }; glTransformFeedbackVaryings(prID, 1, varyings, GL_SEPARATE_ATTRIBS); } But when I want to compile this, I get the error "glTransformFeedbackVaryings isn't defined". I searched in my includes and it is in the glext.h and glew.h defined. What is wrong? On Linux, you might need to #define GL_GLEXT_PROTOTYPES On Windows, you have to look up the function with wglGetProcAddress In both cases, it's generally a good idea to test for the extension first (OSG normally does for you in osg::GLExtensions). --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hello, I tried this in my camera draw callback: virtual void operator()(const osg::Camera& camera) const { // GL-Context-ID GLuint gcID = _gc->getState()->getContextID(); // GL-Program-Handle osg::Program::PerContextProgram* pcp = _program->getPCP(gcID); GLuint prID=pcp->getHandle(); const char* varyings[1] = { "vPosition" }; glTransformFeedbackVaryings(prID, 1, varyings, GL_SEPARATE_ATTRIBS); } But when I want to compile this, I get the error "glTransformFeedbackVaryings isn't defined". I searched in my includes and it is in the glext.h and glew.h defined. What is wrong? Cheers, Martin Original-Nachricht > Datum: Tue, 28 Feb 2012 10:45:16 -0700 > Von: Paul Martz > An: OpenSceneGraph Users > Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > On 2/28/2012 9:10 AM, "Martin Großer" wrote: > > Hello Paul, > > > > In OpenGL I have to define the varying variables for the transform > feedback between the compiling and linking of the shader program. > > > > glTransformFeedbackVaryings(programHandle, 1, varyings, > GL_SEPARATE_ATTRIBS); > > > > How can I do this in OSG? > > The same way. You can issue an OpenGL call any time you have a current > context > (Camera pre draw callback, Drawable draw callback, etc). > > A quick glance at the Program header file reveals that you can get the > program > ID with a call to: >osg::Program::getPCP(contextID)->getHandle(); > > > Additinally I use osg 2.8.4 from the Fedora repository. > > > > Cheers, > > Martin > > > > Original-Nachricht > >> Datum: Mon, 27 Feb 2012 09:51:15 -0700 > >> Von: Paul Martz > >> An: OpenSceneGraph Users > >> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > > > >> Yes, it's possible, but there are no examples that I know of. You might > >> try > >> binding a buffer object in a Camera pre-draw callback, for an example > of > >> one > >> strategy. > >> -Paul > >> > >> > >> On 2/27/2012 8:21 AM, "Martin Großer" wrote: > >>> Hello, > >>> > >>> Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in > osg? > >> I would like write back my vertex position data into a new Vertex > Buffer > >> Object. Is there any example about this? > >>> > >>> Cheers > >>> > >>> Martin > >> ___ > >> osg-users mailing list > >> osg-users@lists.openscenegraph.org > >> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
On 2/28/2012 9:10 AM, "Martin Großer" wrote: Hello Paul, In OpenGL I have to define the varying variables for the transform feedback between the compiling and linking of the shader program. glTransformFeedbackVaryings(programHandle, 1, varyings, GL_SEPARATE_ATTRIBS); How can I do this in OSG? The same way. You can issue an OpenGL call any time you have a current context (Camera pre draw callback, Drawable draw callback, etc). A quick glance at the Program header file reveals that you can get the program ID with a call to: osg::Program::getPCP(contextID)->getHandle(); Additinally I use osg 2.8.4 from the Fedora repository. Cheers, Martin Original-Nachricht Datum: Mon, 27 Feb 2012 09:51:15 -0700 Von: Paul Martz An: OpenSceneGraph Users Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG Yes, it's possible, but there are no examples that I know of. You might try binding a buffer object in a Camera pre-draw callback, for an example of one strategy. -Paul On 2/27/2012 8:21 AM, "Martin Großer" wrote: Hello, Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in osg? I would like write back my vertex position data into a new Vertex Buffer Object. Is there any example about this? Cheers Martin ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hi, Martin afaik, there is no way, you should use opengl calls to get it working 28.02.2012, 20:10, "Martin Groer" : > Hello Paul, > > In OpenGL I have to define the varying variables for the transform feedback > between the compiling and linking of the shader program. > > glTransformFeedbackVaryings(programHandle, 1, varyings, GL_SEPARATE_ATTRIBS); > > How can I do this in OSG? > > Additinally I use osg 2.8.4 from the Fedora repository. > > Cheers, > Martin > > Original-Nachricht > >> Datum: Mon, 27 Feb 2012 09:51:15 -0700 >> Von: Paul Martz >> An: OpenSceneGraph Users >> Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG >> Yes, it's possible, but there are no examples that I know of. You might >> try >> binding a buffer object in a Camera pre-draw callback, for an example of >> one >> strategy. >> -Paul >> >> On 2/27/2012 8:21 AM, "Martin Großer" wrote: >>> Hello, >>> >>> Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in osg? >> I would like write back my vertex position data into a new Vertex Buffer >> Object. Is there any example about this? >>> Cheers >>> >>> Martin >> ___ >> osg-users mailing list >> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hello Paul, In OpenGL I have to define the varying variables for the transform feedback between the compiling and linking of the shader program. glTransformFeedbackVaryings(programHandle, 1, varyings, GL_SEPARATE_ATTRIBS); How can I do this in OSG? Additinally I use osg 2.8.4 from the Fedora repository. Cheers, Martin Original-Nachricht > Datum: Mon, 27 Feb 2012 09:51:15 -0700 > Von: Paul Martz > An: OpenSceneGraph Users > Betreff: Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG > Yes, it's possible, but there are no examples that I know of. You might > try > binding a buffer object in a Camera pre-draw callback, for an example of > one > strategy. > -Paul > > > On 2/27/2012 8:21 AM, "Martin Großer" wrote: > > Hello, > > > > Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in osg? > I would like write back my vertex position data into a new Vertex Buffer > Object. Is there any example about this? > > > > Cheers > > > > Martin > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Yes, it's possible, but there are no examples that I know of. You might try binding a buffer object in a Camera pre-draw callback, for an example of one strategy. -Paul On 2/27/2012 8:21 AM, "Martin Großer" wrote: Hello, Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in osg? I would like write back my vertex position data into a new Vertex Buffer Object. Is there any example about this? Cheers Martin ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] GL_TRANSFORM_FEEDBACK_BUFFER_NV in OSG
Hello, Is it possible to use GL_TRANSFORM_FEEDBACK_BUFFER_NV extension in osg? I would like write back my vertex position data into a new Vertex Buffer Object. Is there any example about this? Cheers Martin -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org