[osg-users] openGL error 'stack overflow' at after RenderBin::draw(..)

Chris Hanson xenon at alphapixel.com
Mon Dec 24 03:52:56 PST 2018


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 <nebsar at gmail.com> wrote:

> 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
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. Xenon at AlphaPixel.com
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 <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20181224/37fce7db/attachment.html>


More information about the osg-users mailing list