private Sdl2GraphicsContext(IWindowInfo window) { // It is possible to create a GraphicsContext on a window // that is not owned by SDL (e.g. a GLControl). In that case, // we need to use SDL_CreateWindowFrom in order to // convert the foreign window to a SDL window. if (window is Sdl2WindowInfo) { Window = window; } else { Window = new Sdl2WindowInfo( SDL.CreateWindowFrom(window.Handle), null); } }
/// <summary> /// Creates a new Ultraviolet window from the specified native window and attaches it to the current context. /// </summary> /// <param name="ptr">A pointer that represents the native window to attach to the context.</param> /// <returns>The Ultraviolet window that was created.</returns> public IUltravioletWindow CreateFromNativePointer(IntPtr ptr) { var sdlptr = SDL.CreateWindowFrom(ptr); if (sdlptr == IntPtr.Zero) { throw new SDL2Exception(); } var win = new OpenGLUltravioletWindow(Ultraviolet, sdlptr); windows.Add(win); Ultraviolet.Messages.Subscribe(win, SDL2UltravioletMessages.SDLEvent); OnWindowCreated(win); return(win); }