Check that OpenGL resources have really been allocated, before deleting them in Unload().

This commit is contained in:
the_fiddler 2009-02-22 16:01:29 +00:00
parent 6e5eaf4653
commit 37755cb398
2 changed files with 13 additions and 7 deletions

View file

@ -206,11 +206,14 @@ namespace Examples.Tutorial
public override void OnUnload(EventArgs e) public override void OnUnload(EventArgs e)
{ {
// Clean up what we allocated before exiting // Clean up what we allocated before exiting
if (ColorTexture != 0)
GL.DeleteTextures(1, ref ColorTexture); GL.DeleteTextures(1, ref ColorTexture);
GL.DeleteTextures(1, ref DepthTexture);
GL.Ext.DeleteFramebuffers(1, ref FBOHandle);
base.OnUnload(e); if (DepthTexture != 0)
GL.DeleteTextures(1, ref DepthTexture);
if (FBOHandle != 0)
GL.Ext.DeleteFramebuffers(1, ref FBOHandle);
} }
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e) protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)

View file

@ -191,11 +191,14 @@ namespace Examples.Tutorial
#endregion #endregion
#region OnUnLoad #region OnUnload
public override void OnUnload(EventArgs e) public override void OnUnload(EventArgs e)
{ {
if (TextureObject != 0)
GL.DeleteTextures(1, ref TextureObject); GL.DeleteTextures(1, ref TextureObject);
if (ProgramObject != 0)
GL.DeleteProgram(ProgramObject); // implies deleting the previously flagged ShaderObjects GL.DeleteProgram(ProgramObject); // implies deleting the previously flagged ShaderObjects
} }