程序异常,堆栈溢出??
用第三方软件CsGL画一个螺旋线,编译没有错误,但是提示堆栈溢出,求高手帮我看看是怎么回事?
-----------------------------------
类的源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsGL.OpenGL;
namespace OpenGL_nn1
{
class Shili
{
private const double PI = 3.1415926;
private float x, y, angle;
private float xRot = 0.0f;
private float yRot = 0.0f;
public Shili() { }
public void Render3DShow()//显示螺旋线
{
GL.glClear(GL.GL_COLOR_BUFFER_BIT);
GL.glPushMatrix();
GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
GL.glRotatef(yRot, 0.0f, 1.0f, 0.0f);
GL.glBegin(GL.GL_POINTS);
float z =-50.0f;
for (angle = 0.0f; angle <= (2.0f * Math.PI) * 3.0f; angle += 0.1f)
{
x = 50.0f* (float)Math.Sin(angle);
y = 50.0f* (float)Math.Cos(angle);
GL.glVertex3f(x, y, z);
z +=0.5f;
}
GL.glEnd();
GL.glPopMatrix();
GL.glFlush();
GL.glVertex3f(x, y, z);
}
}
}
------解决方案--------------------
看代码没有递归,应该是GL类库内部的错误导致的,可以去找类库的新版本,或者看看说明书,也可能是你传参数不适当导致类库出错,