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 

GLBeginEndAdapter


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


Joined: 28 Nov 2010
Posts: 29

PostPosted: Thu Jul 20, 2017 8:11 pm    Post subject:
GLBeginEndAdapter
Reply with quote

Hi,

I am compiling some code with the current git repository version of OSG and found that State's "getGLBeginEndAdapter" has been removed. Looking through the history, I see this happened at: commit e11e45a2e36de91bbe956223c43e8c5a50f9b72b.

The comment is only "Removed GLBeginEndAdapter as it is no longer needed". Well, my code seems to need it. What do I need to do to update my code to not need it? (I realize this is fixed pipeline code, but it's old code and it works. So a complete re-write is not desirable.)

Code:
osg::GLBeginEndAdapter& gl = (state.getGLBeginEndAdapter());

gl.Color4fv(_surfaceColor.ptr());

bool drawBackSide = true;
bool drawFrontSide = true;

// draw back side.
if(drawBackSide)
{
  for(int i = 0; i + 1 <= _density; i++)
  {
    const auto az1 = _azMin + (i*azIncr);
    const auto az2 = _azMin + ((i + 1)*azIncr);

    gl.Begin(GL_QUAD_STRIP);
    for(int j = 0; j <= _density; j++)
    {
      ...


Thank you!

Cheers,
John
Code:
Back to top
View user's profile Send private message Visit poster's website
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 767

PostPosted: Fri Jul 21, 2017 7:25 am    Post subject:
GLBeginEndAdapter
Reply with quote

Hi John,


Quote:
Hi,

I am compiling some code with the current git repository version of OSG and found that State's "getGLBeginEndAdapter" has been removed. Looking through the history, I see this happened at: commit e11e45a2e36de91bbe956223c43e8c5a50f9b72b.

The comment is only "Removed GLBeginEndAdapter as it is no longer needed". Well, my code seems to need it. What do I need to do to update my code to not need it? (I realize this is fixed pipeline code, but it's old code and it works. So a complete re-write is not desirable.)
The glBegin/End stuff is deprecated since OpenGL 2.0, which was released
almost 13 Years ago, so it is long due.

The modern way is to use drawarrays. In your case it might be as simple
as putting all the vertices into a vertex buffer and render it via a
PimitiveSet using QUAD.

Take a look at the osggeometry-example. It covers all you need.
If you have detailed questions, feel free to consult the
forum/mailing-list again.


Cheers
Sebastian

Quote:


Code:
osg::GLBeginEndAdapter& gl = (state.getGLBeginEndAdapter());

gl.Color4fv(_surfaceColor.ptr());

bool drawBackSide = true;
bool drawFrontSide = true;

// draw back side.
if(drawBackSide)
{
for(int i = 0; i + 1 <= _density; i++)
{
const auto az1 = _azMin + (i*azIncr);
const auto az2 = _azMin + ((i + 1)*azIncr);

gl.Begin(GL_QUAD_STRIP);
for(int j = 0; j <= _density; j++)
{
...



Thank you!

Cheers,
John
Code:




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









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11021

PostPosted: Fri Jul 21, 2017 8:17 am    Post subject:
GLBeginEndAdapter
Reply with quote

Hi John,


The GLBeginEndAdapter was an interim solution while older parts of the OSG were migrated over to using vertex arrays and DrawArrays/DrawElements, once this migration work was completed the core OSG no longer required it, so I removed it to avoid bloat.  This migration work was required as OpenGL ES and recent versions of OpenGL either don't support or deprecate glBegin/glEnd, Further pressure to migrate was due to the need to support Vertex Array Objects under recent versions of OpenGL and due to peculiarities of OpenGL support under OSX.


For yourself migrating to use osg::Geometry may well be the easiest.  Sometimes this is straight forward, other times it can be a bit awkward as not all glBegin/glEnd(() style usage easily maps to using vertex arrays.  It's worth the effort though as vertex arrays is how all modern graphics hardware work, the GLBeginEndAdapter hides lots of hacky dynamic setting up of vertex arrays internal to hide the difference between the old style and how modern hardware manage things. 

By moving away from GLBeginEndAdapter you have to confront just how best to represent your data with modern vertex arrays but it'll be worth it - your application should be faster for the improvement.


Robert.






On 20 July 2017 at 21:11, John Farrier < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

I am compiling some code with the current git repository version of OSG and found that State's "getGLBeginEndAdapter" has been removed.  Looking through the history, I see this happened at: commit e11e45a2e36de91bbe956223c43e8c5a50f9b72b.

The comment is only "Removed GLBeginEndAdapter as it is no longer needed".  Well, my code seems to need it.  What do I need to do to update my code to not need it?  (I realize this is fixed pipeline code, but it's old code and it works.  So a complete re-write is not desirable.)


Code:
osg::GLBeginEndAdapter& gl = (state.getGLBeginEndAdapter());

gl.Color4fv(_surfaceColor.ptr());

bool drawBackSide = true;
bool drawFrontSide = true;

// draw back side.
if(drawBackSide)
{
  for(int i = 0; i + 1 <= _density; i++)
  {
    const auto az1 = _azMin + (i*azIncr);
    const auto az2 = _azMin + ((i + 1)*azIncr);

    gl.Begin(GL_QUAD_STRIP);
    for(int j = 0; j <= _density; j++)
    {
      ...



Thank you!

Cheers,
John
Code:




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





_______________________________________________
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
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 Texturing with GLBeginEndAdapter Aaron Andersen General 5 Wed Dec 28, 2016 11:32 pm View latest post
No new posts GLBeginEndAdapter normals multiplicat... René Molenaar Submission 2 Fri Feb 05, 2010 10:06 pm View latest post
No new posts compile fix for OS X and GLBeginEndAd... sth Submission 11 Thu Oct 22, 2009 7:52 am 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