using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SDL2; using testdrid.SdlWrapper; namespace SDL2Demo.SdlWrapper { internal class GlContext : IDisposable { private GlContext() {} public static GlContext Create(Window window) { GlContext child = new GlContext(); child.Pointer = SDL2.SDL.SDL_GL_CreateContext(window.Pointer); if (child.Pointer == IntPtr.Zero) throw SdlException.GenerateException(); SDL.SDL_GL_MakeCurrent(window.Pointer, child.Pointer); SDL.SDL_GL_SetSwapInterval(1); SDL.SDL_GL_SwapWindow(window.Pointer); return child; } public IntPtr Pointer { get; private set; } public void Dispose() { SDL.SDL_GL_DeleteContext(Pointer); } } }