OpenGL runtime returned 1283 (stack overflow) error

During the test, it was found that some models would cause OpengL to report 1283 error. The code is as follows:

// check for errors
	m_glErrorCode=glGetError();
	if(m_glErrorCode != GL_NO_ERROR)
	{
		const GLubyte *estring;
		CString mexstr;
// get the error descritption from OGL
		estring = gluErrorString(m_glErrorCode);
// prepare and show a message box
		mexstr.Format(L"GLEnabledView:\n\tAn OpenGL error occurred: %s\n", estring);
		AfxMessageBox(mexstr,MB_OK | MB_ICONEXCLAMATION);
	}

The value of m_glErrorCode for debugging is 1283 and eString is a stack overflow
After talking to friends and Googling, I came to the following conclusion:
The push and POP classes in OpengL don’t match.
The reason for the problem is that after a push, an opengL function made an error running, and then the return dropped, causing the subsequent POP not to run, reporting the error.

After the problem is solved, I find that the previous code will make a judgment on the return value of some OpengL functions. Let’s learn. This will help you find out quickly what the problem is.

	if(!gluUnProject(winx,winy,winz,modelMatrix,projMatrix,viewport,&objx1,&objy1,&objz1))
		return FALSE;

If you want to discuss it, please email me.

Read More: