Re: [osg-users] isCurrent() doesn't really work.

2010-09-24 Thread David Guthrie
I was just thinking of making isCurrent() virtual and implementing it for each 
of the windowing implementations.

Then in releaseContext, it could check to see if the context being released is 
actually the current context.  

It may be nice to get the current GraphicsContext, but the cost of that is 
someone could change the context using a direct api call and the osg calls 
would be broken again.  Using the native api call internally would prevent that.

Having a GetCurrentContext static call like you said could still be 
implemented, and it could be made more robust by verifying it using the 
isCurrent() call that works with the system level api.  The best it could do, 
however, if isCurrent() returns false on the suspected current context would be 
to return NULL.  Either way, the GetCurrentContext() call would be an 
additional feature to fixing isCurrent().

Cheers,
David

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





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


Re: [osg-users] isCurrent() doesn't really work.

2010-09-24 Thread Robert Osfield
Hi David,

Interesting observation, this is certainly a bug
GraphicsContext::isCurrent().  Your suggestion of a method to get the
current context sounds like a good means for a new implementation.

My suggestion would be to have a static
GraphicsContext::getCurrentContext() method, and then have it check
the Thread::CurrentThread() against a thread safe map of the contexts
that have been made current on each thread.  The
GraphicContext:makeCurrent() and GraphicsContext::releaseContext()
methods would also need to manipulate this map to keep it updated.

If you want to dive in a have a bash at implementing this then it'd be
appreciated ;-)

Cheers,
Robert.


On Thu, Sep 23, 2010 at 10:18 PM, David Guthrie
 wrote:
> I was looking at the isCurrent call and way contexts and made current and 
> released.
>
> isCurrent is not virtual, and simply checks to see if the thread on which the 
> context was made current matches the current thread.
>
> Every OpenGL api I've looked at provides a way to get a handle to the active 
> context, which could be compared to the handle of the context in the 
> GraphicsContext implementation.  That would mean the isContext would always 
> work.
>
> Currently something like
>
> A->makeCurrent();
> B->makeCurrent();
> A->isCurrent();
>
> won't work, but it could be fixed pretty easily.
>
> At the same time, releaseContext() could check to see if the context is 
> actually the active context and do nothing if it isn't.
>
> In wgl, glx, agl, and cgl you can call GetCurrentContext with the respective 
> prefix to accomplish this.  Even Qt has QGLContext::currentContext().
>
> I'll be happy to implement it in some cases, although I am still working with 
> 2.8.3 and the changes will have to be ported to the trunk.
>
> Thanks,
> David Guthrie
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=31999#31999
>
>
>
>
>
> ___
> 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] isCurrent() doesn't really work.

2010-09-23 Thread David Guthrie
I was looking at the isCurrent call and way contexts and made current and 
released.

isCurrent is not virtual, and simply checks to see if the thread on which the 
context was made current matches the current thread.

Every OpenGL api I've looked at provides a way to get a handle to the active 
context, which could be compared to the handle of the context in the 
GraphicsContext implementation.  That would mean the isContext would always 
work.

Currently something like 

A->makeCurrent();
B->makeCurrent();
A->isCurrent();

won't work, but it could be fixed pretty easily.

At the same time, releaseContext() could check to see if the context is 
actually the active context and do nothing if it isn't.

In wgl, glx, agl, and cgl you can call GetCurrentContext with the respective 
prefix to accomplish this.  Even Qt has QGLContext::currentContext().

I'll be happy to implement it in some cases, although I am still working with 
2.8.3 and the changes will have to be ported to the trunk.

Thanks,
David Guthrie

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





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