OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgQt doesn't set a context ID


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
AnyOldName3 (Chris Djali)
User


Joined: 08 Sep 2017
Posts: 69

PostPosted: Tue Mar 12, 2019 6:35 pm    Post subject:
osgQt doesn't set a context ID
Reply with quote

Hi,

For context, this discussion is about the OpenMW CS tool, the source of which is available here: https://gitlab.com/OpenMW/openmw/tree/master/apps/opencs. I've kind of inherited maintenance responsibilities for the graphical parts of this without necessarily knowing much of how it works. It might well do dumb things, but in cases where it's significantly more work to remove the dumb things than work around them, a workaround is preferable. Anyhow...

The OpenMW CS uses osgQt to render an OSG scene onto a QWidget. The widget can be closed and reopened without closing the whole application, and when this happens, the widget and its OpenGL context both are destroyed. When something else needs rendering, a new widget and new OpenGL context are created, but the same OSG scene graph is reused. For the most part, everything's fine with this. However, as I've mentioned in this GitHub issue (https://github.com/openscenegraph/osgQt/issues/24) osgQt isn't ever setting up a context ID, so things like per-context programs think it's the same OpenGL context and this causes OpenGL errors as they try to use objects that don't exist in the new context.

To quote the important part of what I said in the issue report:

Quote:
When an OpenGL context is created with regular OSG, the window implementation calls osg::GraphicsContext::createNewContextID() to generate a unique ID for that context and passes it to osg::State::setContextID(), allowing things like per-context programs and vertex buffers to work. When a new context is created with osgQt, however, the state's context ID is never set, so if an application uses multiple contexts with the same OSG objects, things break.


I can avoid the symptoms by setting the context ID from within my application, but this seems to me like something osgQt should be handling itself.

I could take a stab at working out where exactly a new context is created in osgQt and in which cases it actually shares objects with an existing one to try and resolve this myself, but hopefully, someone with better knowledge of the codebase is around and can do a better job. The issue report I made doesn't seem to have garnered any attention, so I'm hoping that a forum post gets more visibility.

Many thanks,

Chris

Edited because an unpaired closing quote tag was appended to the post even though it wasn't in the post text when I posted it.
Back to top
View user's profile Send private message
AnyOldName3 (Chris Djali)
User


Joined: 08 Sep 2017
Posts: 69

PostPosted: Tue Mar 19, 2019 4:24 pm    Post subject:
osgQt does set a context ID after all, but something else is broken
Reply with quote

I've been informed that I was wrong about this. While I am seeing issues with my application, the context ID is actually being set, just it's being set to the same value as the previous context as OSG reuses IDs for dead contexts.

What I know about the issue so far is that the per-context program isn't being deleted properly. It looks like the OSG object is never actually cleared when releaseGLObjects is called, but it's hard to pin down exactly what's going on when debugging an optimised build, so I'm trying to replicate the issue on an unoptimised one instead, but have stumbled across other problems while doing so.

I'll be back once I know more, as I don't know enough to determine if this is an OSG problem or user error right now.

Cheers,
Chris
Back to top
View user's profile Send private message
AnyOldName3 (Chris Djali)
User


Joined: 08 Sep 2017
Posts: 69

PostPosted: Wed Mar 20, 2019 12:04 am    Post subject:
Reply with quote

The problem was definitely user error - parts of the scene graph were being removed before OSG had had a chance to clean up.

Cheers,
Chris
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Integrate Qt into OSG - not OSG into ... Trajce Nikolov NICK General 2 Wed Oct 02, 2019 1:25 pm View latest post
No new posts Render to Texture and osgQt (osgQOpenGL) wroos General 3 Mon Sep 16, 2019 5:47 pm View latest post
No new posts osgQt Material issue wroos General 1 Mon Sep 09, 2019 10:39 am View latest post
No new posts compile osgQt by osg3.6.3 fail sx341125 General [forum] 2 Sun Jul 28, 2019 2:01 pm View latest post
No new posts Android: Survive Context Loss without... Martin Siggel General 9 Mon Jul 22, 2019 12:17 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP