HI Mathias, Thanks for the file and explanation.
I have tried out your change but it breaks osgconv's usage of Image::readImageFromCurrentTexture(), with you proposed changes this application now exits the function early as no texture mode is detected by the GL_TEXTURE_* methods. The osgconv usage just does a texture->apply() then an image->readImageFromCurrentTexture() without explicitly enabling a texturing. This leaves an interesting situation, the original code is broken for your usage but your new code that fixes breaks existing usage in osgconv and perhaps other places. The problem stems for implicit detection of the texture target, this just isn't robust as we've found out. We either have to come up with a robust implicit texture target detection or make the user specify on calling when the target target is. Thoughts? Robert. On 24 May 2013 14:50, Mathias Garbe <[email protected]> wrote: > Hi Robert, > > I attached the whole modified file, its based of the current svn trunk. I am > using Windows 7 with an Geforce GT 525M (320.18 WHQL driver) > > The issue I experienced with the code is: > Calling readImageFromCurrentTexture read the wrong texture (a 1D texture > instead of the expected 2D texture). After investigating I found that > binding1D, binding2D and binding3D are set to 'true', even tho the OpenGL > state (verified with gldebugger) only had GL_TEXTURE_2D set to 'true' and > GL_TEXTURE_BINDING_2D set to my texture. This happend in a cameras > finalDrawCallback which tries to store the current bound fbo texture in an > osg::Image. > > GL_TEXTURE_BINDING_* is an integer containing the name of the current > texture. Calling glGetBooleanv() on it results in 'true' if (and only if) > the ID is >0.0. As I see the purpose of the original code is to check what > kind of texture is "current", but this will only work if only one texture is > bound and the texture id is >0. My patch will check against GL_TEXURE_*. A > colleague of mine verified the original problem any my fix on different > hardware. > > I hope this clears things up a bit, I am trying to get a small example > running that reproduces the issue. > > Mathias > > > > On 23.05.2013 12:49, Robert Osfield wrote: >> >> Hi Mathias, >> >> Thanks for the patch. Could you send the whole modified file. >> >> Also could you detail what platform/hardware/drivers that you found >> the problem and how I could reproduce the problem. I ask this as >> others, including myself, have used the same Image function without >> problems. >> >> Cheers, >> Robert. >> >> On 23 May 2013 11:27, Mathias Garbe <[email protected]> wrote: >>> >>> Hey there. >>> >>> I just fixed a bug in osg::Image::readImageFromCurrentTexture. The >>> problem >>> is that glGetBooleanvis called on GL_TEXTURE_BINDING_* (which is an int >>> and >>> will get converted to bool) instead of GL_TEXTURE_*. >>> >>> Here is the patch: >>> >>> >>> --- src/osg/Image.cpp Thu May 23 10:09:06 2013 >>> +++ src/osg/Image.cpp Thu May 23 10:10:21 2013 >>> @@ -968,14 +968,14 @@ >>> >>> GLboolean binding1D = GL_FALSE, binding2D = GL_FALSE, binding3D = >>> GL_FALSE, binding2DArray = GL_FALSE, bindingCubeMap = GL_FALSE; >>> >>> - glGetBooleanv(GL_TEXTURE_BINDING_1D, &binding1D); >>> - glGetBooleanv(GL_TEXTURE_BINDING_2D, &binding2D); >>> - glGetBooleanv(GL_TEXTURE_BINDING_3D, &binding3D); >>> - glGetBooleanv(GL_TEXTURE_BINDING_CUBE_MAP, &bindingCubeMap); >>> + glGetBooleanv(GL_TEXTURE_1D, &binding1D); >>> + glGetBooleanv(GL_TEXTURE_2D, &binding2D); >>> + glGetBooleanv(GL_TEXTURE_3D, &binding3D); >>> + glGetBooleanv(GL_TEXTURE_CUBE_MAP, &bindingCubeMap); >>> >>> if (extensions2DArray->isTexture2DArraySupported()) >>> { >>> - glGetBooleanv(GL_TEXTURE_BINDING_2D_ARRAY_EXT, &binding2DArray); >>> + glGetBooleanv(GL_TEXTURE_2D_ARRAY_EXT, &binding2DArray); >>> } >>> >>> GLenum textureMode = binding1D ? GL_TEXTURE_1D : binding2D ? >>> GL_TEXTURE_2D : binding3D ? GL_TEXTURE_3D : binding2DArray ? >>> GL_TEXTURE_2D_ARRAY_EXT : 0; >>> >>> >>> This is my first patch for osg, let me know if I did anything wrong. >>> >>> -- Mathias >>> _______________________________________________ >>> osg-submissions mailing list >>> [email protected] >>> >>> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org >> >> _______________________________________________ >> osg-submissions mailing list >> [email protected] >> >> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > > > > _______________________________________________ > osg-submissions mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org > _______________________________________________ osg-submissions mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
