<div dir="ltr">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.<div><br></div><div>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.</div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 23, 2018 at 11:44 PM Nebi Sarikaya <<a href="mailto:nebsar@gmail.com">nebsar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
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:<br>
<br>
<br>
Code:<br>
<br>
void draw::drawImplementation(osg::RenderInfo& renderInfo) const<br>
{   <br>
<br>
<br>
<br>
                Viewport* viewPort = renderInfo.getCurrentCamera()->getViewport();<br>
<br>
                double width = viewPort->width();<br>
                double height = viewPort->height();<br>
<br>
                double orgX = width / 2;<br>
                double orgY = height / 2;<br>
<br>
                osg::Quat matrix = renderInfo.getCurrentCamera()->getViewMatrix().getRotate();<br>
<br>
                glEnable(GL_LINE_SMOOTH);<br>
                glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);<br>
                glEnable(GL_BLEND);<br>
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);<br>
<br>
                glMatrixMode(GL_PROJECTION);<br>
                glPushMatrix();<br>
                glLoadIdentity();<br>
                glOrtho(0.0, width, 0.0, height, -1, 1);<br>
<br>
                glMatrixMode(GL_MODELVIEW);<br>
                glPushMatrix();<br>
                glLoadIdentity();<br>
<br>
                glTranslated(orgX, orgY, 0);<br>
                glRotated(rotate, 0, 0, 1);<br>
                glTranslated(-orgX, -orgY, 0);<br>
<br>
<br>
                glLineWidth(2.0f);<br>
                glColor4d(0, 255, 0, 255);<br>
                glBegin(GL_LINES);<br>
                if (orgY < height && orgY > 0) {<br>
                        glVertex2d(orgX + 25, orgY);<br>
                        glVertex2d(orgX + 260, orgY);<br>
                        glVertex2d(orgX - 25, orgY);<br>
                        glVertex2d(orgX - 260, orgY);<br>
                }<br>
<br>
                glEnd();<br>
<br>
                glLineWidth(5.0f);<br>
                glColor4d(0, 0, 0, 255);<br>
                glBegin(GL_LINES);<br>
                if (orgY < height && orgY > 0) {<br>
                        glVertex2d(orgX + 23, orgY);<br>
                        glVertex2d(orgX + 262, orgY);<br>
                        glVertex2d(orgX - 23, orgY);<br>
                        glVertex2d(orgX - 262, orgY);<br>
                }<br>
                glEnd();<br>
<br>
<br>
                glLineWidth(2.0f);<br>
                glColor4d(0, 255, 0, 255);<br>
                glBegin(GL_LINES);<br>
<br>
                int yLoc = orgY + 250;<br>
                for (int i = 0; i < 17; i++) {<br>
                        if (yLoc < height && yLoc > 0) {<br>
                                glVertex2d(orgX + 25, yLoc);<br>
                                glVertex2d(orgX + 165, yLoc);<br>
                                glVertex2d(orgX - 25, yLoc);<br>
                                glVertex2d(orgX - 165, yLoc);<br>
<br>
                                glVertex2d(orgX - 165, yLoc);<br>
                                glVertex2d(orgX - 165, yLoc - 20);<br>
                                glVertex2d(orgX + 165, yLoc);<br>
                                glVertex2d(orgX + 165, yLoc - 20);<br>
<br>
                        }<br>
                        yLoc = yLoc + 250;<br>
                }<br>
<br>
                glEnd();<br>
<br>
                glLineWidth(5.0f);<br>
                glColor4d(0, 0, 0, 255);<br>
                glBegin(GL_LINES);<br>
<br>
                yLoc = (int)orgY + 250;<br>
                for (int i = 0; i < 17; i++) {<br>
                        if (yLoc < height && yLoc > 0) {<br>
                                glVertex2d(orgX + 23, yLoc);<br>
                                glVertex2d(orgX + 165, yLoc);<br>
                                glVertex2d(orgX - 23, yLoc);<br>
                                glVertex2d(orgX - 165, yLoc);<br>
<br>
                                glVertex2d(orgX - 165, yLoc);<br>
                                glVertex2d(orgX - 165, yLoc - 22);<br>
                                glVertex2d(orgX + 165, yLoc);<br>
                                glVertex2d(orgX + 165, yLoc - 22);<br>
<br>
                        }<br>
<br>
                        yLoc = yLoc + 250;<br>
                }<br>
                glEnd();<br>
<br>
<br>
}<br>
<br>
<br>
<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Nebi[/code]<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=75339#75339" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=75339#75339</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div style="text-align:center">Chris 'Xenon' Hanson, omo sanza lettere. Xenon@AlphaPixel.com <a href="http://www.alphapixel.com/" target="_blank">http://www.alphapixel.com/</a></div><div style="text-align:center">Training • Consulting • Contracting</div><div style="text-align:center">3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL</div><div style="text-align:center"><span style="font-size:12.8px">Legal/IP •</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">Forensics •</span><span style="font-size:12.8px"> </span>Imaging <span style="font-size:12.8px">•</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">UAVs </span><span style="font-size:12.8px">• GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android</span></div><div style="text-align:center"><a href="https://twitter.com/alphapixel" target="_blank">@alphapixel</a> <a href="http://facebook.com/alphapixel" target="_blank">facebook.com/alphapixel</a> (775) 623-PIXL [7495]<br></div></div></div></div></div></div>