我的体素引擎启动时出现一个奇怪的错误。:尝试读取或写入受保护的内存。这通常表明其他内存已损坏
在里面:
public void initGL()
{
GL.Enable(EnableCap.CullFace); {<- Error}
GL.Enable(EnableCap.Blend); {<- Error}
GL.BlendFunc(BlendingFactorSrc.Src1Alpha, BlendingFactorDest.OneMinusSrc1Alpha); {<- Error}
}
代:
public void genBlocks(float _px, float _py, float _pz, float _diameter, Universe _universe){
this._planetPointer = GL.GenLists(1); {<- Error}
GL.NewList(this._planetPointer, ListMode.Compile); {<- Error}
GL.CullFace(CullFaceMode.Back); {<- Error}
GL.PushMatrix();
{
for (int _y = 0; _y < _diameter; _y++)
{
for (int _x = 0; _x < _diameter; _x++)
{
for (int _z = 0; _z < _diameter; _z++)
{
float _alt = (_x ^ 2) + (_y ^ 2) + (_z ^ 2);
if (_universe.getBlockB(_x, _y, _z, this) == 1 && (_universe.getBlockB(_x + 1, _y, _z, this) == 0 || _universe.getBlockB(_x, _y + 1, _z, this) == 0 || _universe.getBlockB(_x, _y, _z + 1, this) == 0 || _universe.getBlockB(_x - 1, _y, _z, this) == 0 || _universe.getBlockB(_x, _y - 1, _z, this) == 0 || _universe.getBlockB(_x, _y, _z - 1, this) == 0))
{
if (_alt > _diameter)
{
RenderBlock.renderBlock(_x, _y, _z, Block.stone, _universe, this.getBody());
Console.WriteLine("TESTEST");
}
else
{
}
}
}
}
}
}
GL.PopMatrix();
GL.EndList();
}
此错误表明您在没有有效的OpenGL上下文的情况下调用OpenGL函数。如果使用OpenTK.dll的调试版本进行构建和运行,则会得到一个GraphicsContextMissingException
替代。
查看您的窗口构造代码,确保在构造上下文/窗口之前不进行OpenGL调用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句