SDL_GL_GetAttribute requires a valid context

Calling SDL_GL_GetAttribute when context construction has failed leads
to erroneous behavior. This call should only be made when a context has
been constructed correctly.
This commit is contained in:
Stefanos A 2013-11-08 17:31:54 +01:00
parent 5b5a395bbd
commit f77a6b11c3

View file

@ -65,16 +65,17 @@ namespace OpenTK.Platform.SDL2
{
SetGLAttributes(mode, shareContext, major, minor, flags);
SdlContext = new ContextHandle(SDL.GL.CreateContext(Window.Handle));
if (SdlContext == ContextHandle.Zero)
{
var error = SDL.GetError();
Debug.Print("SDL2 failed to create OpenGL context: {0}", error);
throw new GraphicsContextException(error);
}
Mode = GetGLAttributes(SdlContext, out flags);
Debug.Print("SDL2 created GraphicsContext (mode: {0}) (flags: {1}",
Debug.Print("SDL2 created GraphicsContext (mode: {0}) (flags: {1})",
Mode, flags);
}
if (SdlContext == ContextHandle.Zero)
{
var error = SDL.GetError();
Debug.Print("SDL2 failed to create OpenGL context: {0}", error);
throw new GraphicsContextException(error);
}
Handle = GraphicsContext.GetCurrentContext();
}