Jump to content
  • Advertisement
Sign in to follow this  
Lithic

OpenGL glDeleteContexts error?

This topic is 5083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am running OpenGL for a graphics-heavy part of a business application. Originally I was using the Tao SimpleOpenGLControl and not having any problems. However, our team's lead programmer (and only him) has a problem every time he exits the window with the OpenGL frame. The exception is a NullReferenceException: "Object Reference Not Set to an Instance of an Object". Using the stack trace I traced it back to SimpleOpenGLControl.DestroyContexts(), and I then used .NET reflector to create a class with the exact same code. The error line is commented on the code below:
public void DestroyContexts()
{
      if (this.renderingContext != IntPtr.Zero)
      {
            Wgl.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero);
//
//
// *** Error on the following line ***
            Wgl.wglDeleteContext(this.renderingContext); 
            this.renderingContext = IntPtr.Zero;
      }
      if (this.deviceContext == IntPtr.Zero)
      {
            return;
      }
      if (this.windowHandle != IntPtr.Zero)
      {
            User.ReleaseDC(this.windowHandle, this.deviceContext);
      }
      this.deviceContext = IntPtr.Zero;
}
Wgl is a class, and wglDeleteContext is a public external static method defined to that class as follows:
[SuppressUnmanagedCodeSecurity, DllImport("opengl32.dll", SetLastError=true)]
public static extern bool wglDeleteContext(IntPtr renderingContext);
I can see no reason why he would be getting a NullReferenceException save that the fucntion could not be found in opengl32.dll. I originally surmised that he had an earlier version of the DLL than I had, so we both searched our PCs and found that he has the same version. We both are running substandard PCs on generic graphics cards, but the application uses NO hardware acceleration so this shouldn't be a problem. As a temporary solution I tried putting the statement in a try block where it logged the exception on the server if it caught it. However, this did not work since the next time he tried to open the form with the opengl frame the program idled for about 5 minutes then threw an exception. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!