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

Nebi Sarikaya nebsar at gmail.com
Sat Dec 22 22:05:33 PST 2018


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







More information about the osg-users mailing list