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 

openGL error 'stack overflow' at after RenderBin::draw(..)


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


Joined: 15 Dec 2018
Posts: 6

PostPosted: Sun Dec 23, 2018 6:05 am    Post subject:
openGL error 'stack overflow' at after RenderBin::draw(..)
Reply with quote

Hi,

I am trying to draw lines on the screen. And I am trying to use pure openGL to draw lines.The lines can be drawn on the screen. But I get openGL error 'stack overflow' at after RenderBin::draw(..) message. My code is below:

Code:

void draw::drawImplementation(osg::RenderInfo& renderInfo) const
{   
   

      
      Viewport* viewPort = renderInfo.getCurrentCamera()->getViewport();

      double width = viewPort->width();
      double height = viewPort->height();

      double orgX = width / 2;
      double orgY = height / 2;

      osg::Quat matrix = renderInfo.getCurrentCamera()->getViewMatrix().getRotate();

      glEnable(GL_LINE_SMOOTH);
      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      glOrtho(0.0, width, 0.0, height, -1, 1);

      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glLoadIdentity();

      glTranslated(orgX, orgY, 0);
      glRotated(rotate, 0, 0, 1);
      glTranslated(-orgX, -orgY, 0);
      

      glLineWidth(2.0f);
      glColor4d(0, 255, 0, 255);
      glBegin(GL_LINES);
      if (orgY < height && orgY > 0) {
         glVertex2d(orgX + 25, orgY);
         glVertex2d(orgX + 260, orgY);
         glVertex2d(orgX - 25, orgY);
         glVertex2d(orgX - 260, orgY);
      }

      glEnd();

      glLineWidth(5.0f);
      glColor4d(0, 0, 0, 255);
      glBegin(GL_LINES);
      if (orgY < height && orgY > 0) {
         glVertex2d(orgX + 23, orgY);
         glVertex2d(orgX + 262, orgY);
         glVertex2d(orgX - 23, orgY);
         glVertex2d(orgX - 262, orgY);
      }
      glEnd();
      

      glLineWidth(2.0f);
      glColor4d(0, 255, 0, 255);
      glBegin(GL_LINES);

      int yLoc = orgY + 250;
      for (int i = 0; i < 17; i++) {
         if (yLoc < height && yLoc > 0) {
            glVertex2d(orgX + 25, yLoc);
            glVertex2d(orgX + 165, yLoc);
            glVertex2d(orgX - 25, yLoc);
            glVertex2d(orgX - 165, yLoc);

            glVertex2d(orgX - 165, yLoc);
            glVertex2d(orgX - 165, yLoc - 20);
            glVertex2d(orgX + 165, yLoc);
            glVertex2d(orgX + 165, yLoc - 20);

         }
         yLoc = yLoc + 250;
      }

      glEnd();

      glLineWidth(5.0f);
      glColor4d(0, 0, 0, 255);
      glBegin(GL_LINES);

      yLoc = (int)orgY + 250;
      for (int i = 0; i < 17; i++) {
         if (yLoc < height && yLoc > 0) {
            glVertex2d(orgX + 23, yLoc);
            glVertex2d(orgX + 165, yLoc);
            glVertex2d(orgX - 23, yLoc);
            glVertex2d(orgX - 165, yLoc);

            glVertex2d(orgX - 165, yLoc);
            glVertex2d(orgX - 165, yLoc - 22);
            glVertex2d(orgX + 165, yLoc);
            glVertex2d(orgX + 165, yLoc - 22);

         }

         yLoc = yLoc + 250;
      }
      glEnd();

   
}


Thank you!

Cheers,
Nebi[/code]
Back to top
View user's profile Send private message
nebsar
Newbie


Joined: 15 Dec 2018
Posts: 6

PostPosted: Mon Dec 24, 2018 6:09 am    Post subject:
Reply with quote

After working on this for couple of hours, I noticed that when I use below code block, i get the error.

Code:

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1, 1);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();


I solved the problem. So instead of using the code block below I used :

Code:


renderInfo.getCurrentCamera()->setProjectionMatrix(osg::Matrix::ortho2D(0, width, 0, height));



You may see the screen shot attached.

Thanks.

Cheers,
Nebi[/code]
Back to top
View user's profile Send private message
Chris Hanson
Guest





PostPosted: Mon Dec 24, 2018 11:53 am    Post subject:
openGL error 'stack overflow' at after RenderBin::draw(..)
Reply with quote

You are doing two PushMatrix operations per draw call, but you never PopMatrix, so the OpenGL matrix stack gets more and more full and eventually overflows.

At this point, functionally, you can either add two PopMatrix calls somewhere at the end of the draw function, or if you don't need the matrix stack (your current code isn't using the data you pushed, so it won't change functionality) just remove the two pushmatrix calls.


On Sun, Dec 23, 2018 at 11:44 PM Nebi Sarikaya < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi,

I am trying to draw lines on the screen. And I am trying to use pure openGL to draw lines.The lines can be drawn on the screen. But I get openGL error 'stack overflow' at after RenderBin::draw(..) message. My code is below:


Code:

void draw::drawImplementation(osg::RenderInfo& renderInfo) const
{   



                Viewport* viewPort = renderInfo.getCurrentCamera()->getViewport();

                double width = viewPort->width();
                double height = viewPort->height();

                double orgX = width / 2;
                double orgY = height / 2;

                osg::Quat matrix = renderInfo.getCurrentCamera()->getViewMatrix().getRotate();

                glEnable(GL_LINE_SMOOTH);
                glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
                glEnable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

                glMatrixMode(GL_PROJECTION);
                glPushMatrix();
                glLoadIdentity();
                glOrtho(0.0, width, 0.0, height, -1, 1);

                glMatrixMode(GL_MODELVIEW);
                glPushMatrix();
                glLoadIdentity();

                glTranslated(orgX, orgY, 0);
                glRotated(rotate, 0, 0, 1);
                glTranslated(-orgX, -orgY, 0);


                glLineWidth(2.0f);
                glColor4d(0, 255, 0, 255);
                glBegin(GL_LINES);
                if (orgY < height && orgY > 0) {
                        glVertex2d(orgX + 25, orgY);
                        glVertex2d(orgX + 260, orgY);
                        glVertex2d(orgX - 25, orgY);
                        glVertex2d(orgX - 260, orgY);
                }

                glEnd();

                glLineWidth(5.0f);
                glColor4d(0, 0, 0, 255);
                glBegin(GL_LINES);
                if (orgY < height && orgY > 0) {
                        glVertex2d(orgX + 23, orgY);
                        glVertex2d(orgX + 262, orgY);
                        glVertex2d(orgX - 23, orgY);
                        glVertex2d(orgX - 262, orgY);
                }
                glEnd();


                glLineWidth(2.0f);
                glColor4d(0, 255, 0, 255);
                glBegin(GL_LINES);

                int yLoc = orgY + 250;
                for (int i = 0; i < 17; i++) {
                        if (yLoc < height && yLoc > 0) {
                                glVertex2d(orgX + 25, yLoc);
                                glVertex2d(orgX + 165, yLoc);
                                glVertex2d(orgX - 25, yLoc);
                                glVertex2d(orgX - 165, yLoc);

                                glVertex2d(orgX - 165, yLoc);
                                glVertex2d(orgX - 165, yLoc - 20);
                                glVertex2d(orgX + 165, yLoc);
                                glVertex2d(orgX + 165, yLoc - 20);

                        }
                        yLoc = yLoc + 250;
                }

                glEnd();

                glLineWidth(5.0f);
                glColor4d(0, 0, 0, 255);
                glBegin(GL_LINES);

                yLoc = (int)orgY + 250;
                for (int i = 0; i < 17; i++) {
                        if (yLoc < height && yLoc > 0) {
                                glVertex2d(orgX + 23, yLoc);
                                glVertex2d(orgX + 165, yLoc);
                                glVertex2d(orgX - 23, yLoc);
                                glVertex2d(orgX - 165, yLoc);

                                glVertex2d(orgX - 165, yLoc);
                                glVertex2d(orgX - 165, yLoc - 22);
                                glVertex2d(orgX + 165, yLoc);
                                glVertex2d(orgX + 165, yLoc - 22);

                        }

                        yLoc = yLoc + 250;
                }
                glEnd();


}




Thank you!

Cheers,
Nebi[/code]

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





_______________________________________________
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



--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
nebsar
Newbie


Joined: 15 Dec 2018
Posts: 6

PostPosted: Mon Dec 24, 2018 2:49 pm    Post subject:
Reply with quote

Chris,

Thank you for your interest and answer. I need glPushMatrix and glPopMatrix since as you may see on the screenshot some of the drawings are static on the other hand positions of some of the drawings dinamically change.

Now I need to put text inside the boxes and next to the pitch lines. I know that osg::Text can work for me for the static ones. Bu what should I do for the dynamic ones? Is there any way to rotate osg::Text just like we rotate in openGL. What I mean is, I need to rotate text just beside the pitch lines and aligned next to them. These texts will show the pitch degrees.

Thank you!

Cheers,
Nebi
Back to top
View user's profile Send private message
nebsar
Newbie


Joined: 15 Dec 2018
Posts: 6

PostPosted: Sat Dec 29, 2018 9:08 am    Post subject:
Reply with quote

At last I managed to do somethings using osgText::Text, but I had to create a new class called "TextMod" means modified text derived from osgText::Text class, and I created a function setting offset to TextMod class. By setting different offset values to each text I could set all the positions of the texts at the center origin point. So when I rotate the pitch ladders all text labels rotate aligned with the pitch ladders.

Actually I did a similar HUD using NASA World Wind Java. There is a TextRenderer class in WWJ API and by that way a text can be rendered on GLCanvas. So when the matrix is rotated all drawings and texts rotates. That was actually more easy to implement.

If anyone knows an easier way please let me know.

Thank you!

Cheers,
Nebi
Back to top
View user's profile Send private message
Chris Hanson
Guest





PostPosted: Sun Dec 30, 2018 2:30 pm    Post subject:
openGL error 'stack overflow' at after RenderBin::draw(..)
Reply with quote

I'm not totally clear on how you're doing things, but I think it's probably more cumbersome than it should be.

I usually put all of the text and HUD elements into a group and position them relative to the group and then rotate and shift that group. All the sub-children will rotate properly.


On Sun, Dec 30, 2018 at 9:49 AM Nebi Sarikaya < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
At last I managed to do somethings using osgText::Text, but I had to create a new class called "TextMod" means modified text derived from osgText::Text class, and I created a function setting offset to TextMod class. By setting different offset values to each text I could set all the positions of the texts at the center origin point. So when I rotate the pitch ladders all text labels rotate aligned with the pitch ladders.

Actually I did a similar HUD using NASA World Wind Java. There is a TextRenderer class in WWJ API and by that way a text can be rendered on GLCanvas. So when the matrix is rotated all drawings and texts rotates. That was actually more easy to implement.

If anyone knows an easier way please let me know.

Thank you!

Cheers,
Nebi

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



_______________________________________________
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



--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
nebsar
Newbie


Joined: 15 Dec 2018
Posts: 6

PostPosted: Mon Jan 07, 2019 7:40 am    Post subject:
Reply with quote

Hi Chris;

Can you be more specific on "I usually put all of the text and HUD elements into a group and position them relative to the group and then rotate and shift that group. All the sub-children will rotate properly. " ?

Thank you!

Cheers,
Nebi
Back to top
View user's profile Send private message
Chris Hanson
Guest





PostPosted: Mon Jan 07, 2019 10:20 am    Post subject:
openGL error 'stack overflow' at after RenderBin::draw(..)
Reply with quote

Well, it's hard to say because I don't really know how you are doing it now, but it seems to me like you're spending a lot of effort rotating and positioning each text element individually. Normally, I don't go through that process.

Normally, I make a hierarchy of a few groups, each with various children individually positioned. Then, I can adjust the overall position and rotation of the whole set by applying position and rotation transforms to the Group node, not to each text or other sub-element.


From your description (maybe I misinterpreted what you were saying) it didn't sound like you were doing it this way, and I worried that you were making unnecessary work for yourself as a result.






On Mon, Jan 7, 2019 at 8:40 AM Nebi Sarikaya < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Chris;

Can you be more specific on "I usually put all of the text and HUD elements into a group and position them relative to the group and then rotate and shift that group. All the sub-children will rotate properly. " ?

Thank you!

Cheers,
Nebi

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





_______________________________________________
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



--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
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 use vs2013 to build osg3.6.3, some er... FreeSouth General 0 Sat Dec 08, 2018 3:26 pm View latest post
No new posts OpenGL viewport error (with Oculus) Riccardo Corsi General 6 Wed Oct 17, 2018 10:44 am View latest post
No new posts [Crash issue] no error info even set ... pwang General 1 Sun Jul 29, 2018 1:20 pm View latest post
No new posts Extra draw calls in osgText? gwaldron General 1 Thu Jul 19, 2018 8:48 pm View latest post
No new posts Build error under Windows? Need feedb... robertosfield General 3 Wed Jun 27, 2018 11:11 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