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 

Force OSG for GLES 2.0 to reenable vertex attributes before drawing geometry


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
plamen_t
Newbie


Joined: 11 Jun 2019
Posts: 4

PostPosted: Tue Jun 11, 2019 11:57 am    Post subject:
Force OSG for GLES 2.0 to reenable vertex attributes before drawing geometry
Reply with quote

Hi,

I've built OSG for Android with GLES 2.0 support. I've created very simple scene where I render a sphere using ShapeDrawable.

In the first frame I can see that OSG calls glEnableVertexAttribArray() and sets the data using glVertexAttribPointer(). After that it calls glDrawElements() and the sphere renders fine.

However at the end of the frame the app calls glDisableVertexAttribArray() (I am using Qt for OSG integration and Qt changes the vertex arrays). That's why the next frame no geometry draws because OSG does not call again glEnableVertexAttribArray() and glVertexAttribPointer() but only glDrawElements().

I'd like to force OSG to call on each frame glEnableVertexAttribArray() and glVertexAttribPointer() before calling glDrawElements() because the vertex arrays state has changed between the frames and needs to provide again the correct data.

How I can do this?


Thank you!

Cheers,
Plamen
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12324

PostPosted: Fri Jun 14, 2019 7:55 am    Post subject:
Force OSG for GLES 2.0 to reenable vertex attributes before drawing geometry
Reply with quote

Hi Plamen,

There is no explicit mechanism for forcing extra
glEnableVertexAttribArray calls as they shouldn't be required. What
you describe sounds like a bug in the driver or the OSG.

Which version of the OSG are you using? What hardware target are you using?

What happens when you don't use osg::ShapeDrawable? For instance just
use a normal osg::Geometry. FYI, osg::ShapeDrawable was never meant
for widespread usage back when it was originally written, it's was
simply written to provide a quick a dirty means of visualizing
primitive shapes for debug purposes - this is going back to 2002 :-)

Robert.

On Fri, 14 Jun 2019 at 05:57, Plamen Terziev <> wrote:
Quote:

Hi,

I've built OSG for Android with GLES 2.0 support. I've created very simple scene where I render a sphere using ShapeDrawable.

In the first frame I can see that OSG calls glEnableVertexAttribArray() and sets the data using glVertexAttribPointer(). After that it calls glDrawElements() and the sphere renders fine.

However at the end of the frame the app calls glDisableVertexAttribArray() (I am using Qt for OSG integration and Qt changes the vertex arrays). That's why the next frame no geometry draws because OSG does not call again glEnableVertexAttribArray() and glVertexAttribPointer() but only glDrawElements().

I'd like to force OSG to call on each frame glEnableVertexAttribArray() and glVertexAttribPointer() before calling glDrawElements() because the vertex arrays state has changed between the frames and needs to provide again the correct data.

How I can do this?


Thank you!

Cheers,
Plamen

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








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
plamen_t
Newbie


Joined: 11 Jun 2019
Posts: 4

PostPosted: Mon Jun 24, 2019 10:39 am    Post subject:
Reply with quote

Hi Robert,

Sorry for the late reply and thank your for your answer.

I've checked the OSG source and I saw that OSG manages the OpenGL state itself and that's why if someone (in my case Qt) changes the state then OSG does not know that the state has changed.

This seems to not be a bug in OSG at all.

What I am doing is to call at the end of each frame the following:

Code:

auto state = m_osg->getCamera()->getGraphicsContext()->getState();
state->lazyDisablingOfVertexAttributes();
state->applyDisablingOfVertexAttributes();


So the next frame OSG enables and binds the vertex attributes which fixes the issue.

I am not sure my code for invalidating the state is correct. Is there any better way to do this?

My end goal is to tell OSG that what the OpenGL state is different and to invalidate its state.

Also I've added Mapbox as a OSG drawable node and after Mapbox node renders then the next nodes do not render anymore. Seems that Mapbox is also changing some OpenGL state and OSG is not aware of this.

Is there a way to tell OSG to invalidate the state between 2 nodes rendering? I am aware for the performance hit here by calling extra gl calls but this will fix my issues.

Also is it possible to opt out the entire OSG state management so each frame to really make the OpenGL calls?
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12324

PostPosted: Mon Jun 24, 2019 1:08 pm    Post subject:
Force OSG for GLES 2.0 to reenable vertex attributes before drawing geometry
Reply with quote

Hi Plamen,


It sounds like Qt's bad habit of changing OpenGL state for it's own purposes and not resetting that afterwards is the cause your problems.  Unless you specifcally need Qt to create your graphics widow and UI I would recommend not  using it, the built in windowing support that the OSG provides will be better suited for the purpose. 



If you have to use Qt then you'll need to tell the OSG what state can't be trusted and needs to be reapplied. I would suggest putting the state dirty calls into the code prior to calling the OSG's frame,  Where best to place this will depend upon how you've integrate the OSG.  Your own workaround will be doing a form of dirty and probably why it works.  There are other methods for dirtying state in osg::State, just search for dirty in the State header.



Robert.



On Mon, 24 Jun 2019 at 11:39, Plamen Terziev < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Robert,

Sorry for the late reply and thank your for your answer.

I've checked the OSG source and I saw that OSG manages the OpenGL state itself and that's why if someone (in my case Qt) changes the state then OSG does not know that the state has changed.

This seems to not be a bug in OSG at all.

What I am doing is to call at the end of each frame the following:


Code:

auto state = m_osg->getCamera()->getGraphicsContext()->getState();
state->lazyDisablingOfVertexAttributes();
state->applyDisablingOfVertexAttributes();




So the next frame OSG enables and binds the vertex attributes which fixes the issue.

I am not sure my code for invalidating the state is correct. Is there any better way to do this?

My end goal is to tell OSG that what the OpenGL state is different and to invalidate its state.

Also I've added Mapbox as a OSG drawable node and after Mapbox node renders then the next nodes do not render anymore. Seems that Mapbox is also changing some OpenGL state and OSG is not aware of this.

Is there a way to tell OSG to invalidate the state between 2 nodes rendering? I am aware for the performance hit here by calling extra gl calls but this will fix my issues.

Also is it possible to opt out the entire OSG state management so each frame to really make the OpenGL calls?

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
plamen_t
Newbie


Joined: 11 Jun 2019
Posts: 4

PostPosted: Mon Jun 24, 2019 6:33 pm    Post subject:
Reply with quote

Yes, Qt changes the state and does not restore it.

The fix I have seems to work so will keep using it for now.

Thank you for the help!
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 Ability to apply StateAttributeAndMod... Blanky General [forum] 0 Wed Aug 07, 2019 3:08 pm View latest post
No new posts Layered rendering with a geometry shader AnyOldName3 General 8 Tue May 14, 2019 11:25 pm View latest post
No new posts Retrieve the triangles indices array ... Paradox General 1 Mon May 13, 2019 11:16 am View latest post
No new posts hidden geometry in embedded osg Meldryt General 1 Thu Feb 21, 2019 7:17 am View latest post
No new posts osg::Drawable vs osg::Geometry NoeMurr General 2 Sun Oct 21, 2018 2:45 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