Hi Can,

The osgViewer::Viewer by default now releases the context after
frame() even in single threaded - this is required to handle users
calling multiple viewers from one frame loop.   In
include/osgViewer/ViewerBase you'll find the method:

        /** Hint to tell the renderingTraversals() method whether to
call relaseContext() on the last
          * context that was made current by the thread calling
renderingTraverals().  Note, when
          * running multi-threaded viewer no threads will be made
current or release current.
          * Setting this hint to false can enable the frame loop to be
lazy about calling makeCurrent
          * and releaseContext on each new frame, helping performance.
 However, if you frame loop
          * is managing multiple graphics context all from the main
frame thread then this hint must
          * be left on, otherwise the wrong context could be left
active, introducing errors in rendering.*/
        void setReleaseContextAtEndOfFrameHint(bool hint) {
_releaseContextAtEndOfFrameHint = hint; }

So you can call :

  viewer.setReleaseContextAtEndOfFrameHint(false);

And you'll be able to call OpenGL op's after frame(), but... your code
will be working on a wing and prayer - as later you might want to go
multi-threaded, or use multiple graphics context in which case the
main thread once more won't have the graphics context current.

The way to fix this robustly is do add the ops via a Camera Pre or
PostDrawCallback as no matter what the threading model it'll work.

Robert.

On Mon, Oct 27, 2008 at 1:29 PM, Can T. Oguz <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm running OSG in single threaded mode and making the calls right after the
> context setup code, but if you think that the scaling operation needs to be
> done within the OSG's inner threads; then there's no chance that I could use
> this function. If you suggest an alternative, I'll follow.
>
> Regards,
>
> Can
>
> 2008/10/27 Robert Osfield <[EMAIL PROTECTED]>
>>
>> Hi Can,
>>
>> You make no mention where about your call the scaleImage from, there
>> is chance that you think you are calling it from a thread with the
>> graphics context but don't.  Without more info about your usage there
>> isn't anyone else can say.  Please remember the OSG is multi-threaded,
>> and by default with put the graphics in its own thread per context so
>> then main thread won't have the context current.
>>
>> Robert.
>>
>> On Mon, Oct 27, 2008 at 1:06 PM, Can T. Oguz <[EMAIL PROTECTED]> wrote:
>> > Hi,
>> >
>> > Yes, I've read the previous posts and I have a valid context. I have
>> > even
>> > made the calls after the first frame() is executed (to ensure the
>> > context)
>> >
>> > Source image is 512x217
>> > Dest image is 50x20
>> > OS : Win XP
>> > Image iss JPG,  GL_RGB
>> > Card : NVidia 8800 GT
>> > OSG : 2.6.1
>> >
>> > and the code is :
>> >
>> >
>> > for (UINT i = 0; i < 3; i++)
>> >
>> > {
>> >
>> > Image
>> >
>> > * image = readImageFile(string(path) + textureFiles[i] + ".jpg");
>> >
>> > m_textures
>> >
>> > [i] = new Texture2D(image);
>> >
>> > m_thumbnails
>> >
>> > [i] = new Image(*image, CopyOp::DEEP_COPY_IMAGES);
>> >
>> > m_thumbnails
>> >
>> > [i]->scaleImage(50, 20, 1);
>> >
>> > }
>> >
>> > I've also tried a non-copied fresh image and I've got the same error.
>> >
>> > Thanks for reading,
>> >
>> > Can
>> >
>> >
>> >
>> > 2008/10/27 Tomlinson, Gordon <[EMAIL PROTECTED]>
>> >>
>> >> First guess 'Are you doing this in process with a valid graphics
>> >> context'
>> >>
>> >>
>> >> Might help if you provided some basic info such as"
>> >>
>> >>
>> >> How are you scaling the image (code)
>> >> What version of osg
>> >> What OS
>> >> how big is the image
>> >> What type of image is it
>> >> Graphics card
>> >> etc.
>> >>
>> >> have you tried debug  the issue? , stepped into the code etc to see
>> >> what
>> >> might be amiss
>> >>
>> >>
>> >>
>> >> Gordon
>> >>
>> >> __________________________________________________________
>> >> Gordon Tomlinson
>> >>
>> >> Product Manager 3D
>> >> Email  : gtomlinson @ overwatch.textron.com
>> >> __________________________________________________________
>> >> (C): (+1) 571-265-2612
>> >> (W): (+1) 703-437-7651
>> >>
>> >> "Self defence is not a function of learning tricks
>> >> but is a function of how quickly and intensely one
>> >> can arouse one's instinct for survival"
>> >> - Master Tambo Tetsura
>> >>
>> >>
>> >>
>> >> ________________________________
>> >> From: [EMAIL PROTECTED]
>> >> [mailto:[EMAIL PROTECTED] On Behalf Of Can T.
>> >> Oguz
>> >> Sent: Monday, October 27, 2008 8:45 AM
>> >> To: OpenSceneGraph Users
>> >> Subject: [osg-users] gluScaleImage() returns "out of memory"
>> >>
>> >> Hi,
>> >>
>> >> I'm receiving an out of memory error while trying to scale an image.
>> >>
>> >> File : Image.cpp
>> >> Line : 839 (2.6.1)
>> >>
>> >> In Image::scaleImage(), gluScaleImage() returns 1285 : out of memory.
>> >>
>> >> Any ideas?
>> >>
>> >> Can
>> >> _______________________________________________
>> >> 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
>
>
> _______________________________________________
> 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