I subclassed Texture2D and implemented apply(), and it now works very well,
without duplicating code. I'm not sure if there's a better solution but I'm
happy with this one.

Eric

On Fri, Mar 6, 2015 at 3:52 PM, Eric Sokolowsky <e...@byu.net> wrote:

> Hi Robert,
>
> I am using that function to get the image from the texture in my custom
> subload callback. The problem is how or when do I call that? It must be in
> the draw thread, so that's why I was using a subload callback, but I no
> longer want to override the default processing found in Texture2D::apply(),
> so I don't want to use a subload callback any more.
>
> Eric
>
> On Fri, Mar 6, 2015 at 3:45 PM, Robert Osfield <robert.osfi...@gmail.com>
> wrote:
>
>> Hi Eric,
>>
>> It's a long time since I looked at the subload callback.  Having the load
>> and subload methods available in osg::Texture2D seems like a sensible
>> option.
>>
>> However, it might be that you don't need the callback at all.  Have you
>> looked at the osg::Image::Image::readImageFromCurrentTexture(..) method?
>>
>> Robert.
>>
>>
>> On 6 March 2015 at 19:50, Eric Sokolowsky <e...@byu.net> wrote:
>>
>>> I have need for some custom code to run after the
>>> Texture2D::applyTexImage2D_subload function is called. (I am reading back
>>> the image from OpenGL, which might have been compressed by the graphics
>>> card, and saving it to disk.) So I have been using a subloadCallback to put
>>> the custom code in place. This works, but I don't require any custom code
>>> for the Texture2D::applyTexImage2D_load function. But since the
>>> subloadCallback requires me to implement both the load and the subload I
>>> must do both. But I can't replicate the code in Texture2D::apply in my
>>> subloadCallback because there are lots of mutable members in Texture2D and
>>> getting them from the subloadCallback doesn't make them mutable for me, so
>>> I get lots of errors of losing constness and qualifiers if I try this path.
>>>
>>> So I am wondering how best to proceed from here. Should I derive a class
>>> from Texture2D so I can intercept calls to apply(), then call the base
>>> class version and do my custom processing from there, or can we add a hook
>>> to call a custom callback after the Texture2D::applyTexImage2D_load and/or
>>> the Texture2D::applyTexImage2D_subload functions?
>>>
>>> Or is there a better way to read the texture back from the graphics card
>>> that is independent of the Texture2D::apply function? Of course this will
>>> need to be done in the draw thread.
>>>
>>> Any help will be appreciated..
>>>
>>> Eric
>>>
>>> _______________________________________________
>>> osg-users mailing list
>>> osg-users@lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to