Exemplo n.º 1
0
        static FNAPlatform()
        {
            /* I suspect you may have an urge to put an #if in here for new
             * FNAPlatform implementations.
             *
             * DON'T.
             *
             * Determine this at runtime, or load dynamically.
             * No amount of whining will get me to budge on this.
             * -flibit
             */

            // Environment.GetEnvironmentVariable("FNA_PLATFORM_BACKEND");

            CreateWindow =			SDL2_FNAPlatform.CreateWindow;
            DisposeWindow =			SDL2_FNAPlatform.DisposeWindow;
            BeforeInitialize =		SDL2_FNAPlatform.BeforeInitialize;
            RunLoop =			SDL2_FNAPlatform.RunLoop;
            CreateGLDevice =		SDL2_FNAPlatform.CreateGLDevice;
            CreateALDevice =		SDL2_FNAPlatform.CreateALDevice;
            SetPresentationInterval =	SDL2_FNAPlatform.SetPresentationInterval;
            GetGraphicsAdapters =		SDL2_FNAPlatform.GetGraphicsAdapters;
            GetKeyFromScancode =		SDL2_KeyboardUtil.GetKeyFromScancode;
            StartTextInput =		SDL2.SDL.SDL_StartTextInput;
            StopTextInput =			SDL2.SDL.SDL_StopTextInput;
            GetMouseState =			SDL2_FNAPlatform.GetMouseState;
            SetMousePosition =		SDL2.SDL.SDL_WarpMouseInWindow;
            OnIsMouseVisibleChanged =	SDL2_FNAPlatform.OnIsMouseVisibleChanged;
            GetGamePadCapabilities =	SDL2_FNAPlatform.GetGamePadCapabilities;
            GetGamePadState =		SDL2_FNAPlatform.GetGamePadState;
            SetGamePadVibration =		SDL2_FNAPlatform.SetGamePadVibration;
            GetGamePadGUID =		SDL2_FNAPlatform.GetGamePadGUID;
            SetGamePadLightBar =		SDL2_FNAPlatform.SetGamePadLightBar;
            GetStorageRoot =		SDL2_FNAPlatform.GetStorageRoot;
            IsStoragePathConnected =	SDL2_FNAPlatform.IsStoragePathConnected;
            ShowRuntimeError =		SDL2_FNAPlatform.ShowRuntimeError;
            TextureDataFromStream =		SDL2_FNAPlatform.TextureDataFromStream;
            SavePNG =			SDL2_FNAPlatform.SavePNG;

            Log = Console.WriteLine;

            AppDomain.CurrentDomain.ProcessExit += SDL2_FNAPlatform.ProgramExit;
            SDL2_FNAPlatform.ProgramInit();
        }
Exemplo n.º 2
0
        public static void InitPlatformInterface()
        {
            ImGuiViewportPtr mainViewport = ImGui.GetMainViewport();

            var mainWindowHandle = GetMainWindowHandle();

            mainViewport.PlatformHandle = mainWindowHandle;

            var data = ViewportData.Default;

            data.Window = mainWindowHandle;
            IntPtr dataID = BindViewportData(data);

            mainViewport.PlatformUserData = dataID;

            var io = ImGui.GetPlatformIO();

            _createWindowDelegate    = ImGui_ImplGlfw_CreateWindow;
            io.Platform_CreateWindow = Marshal.GetFunctionPointerForDelegate(_createWindowDelegate);

            _destroyWindowDelegate    = ImGui_ImplGlfw_DestroyWindow;
            io.Platform_DestroyWindow = Marshal.GetFunctionPointerForDelegate(_destroyWindowDelegate);

            _showWindowDelegate    = ImGui_ImplGlfw_ShowWindow;
            io.Platform_ShowWindow = Marshal.GetFunctionPointerForDelegate(_showWindowDelegate);

            _setWindowPosDelegate    = ImGui_ImplGlfw_SetWindowPos;
            io.Platform_SetWindowPos = Marshal.GetFunctionPointerForDelegate(_setWindowPosDelegate);

            _getWindowPosDelegate    = ImGui_ImplGlfw_GetWindowPos;
            io.Platform_GetWindowPos = Marshal.GetFunctionPointerForDelegate(_getWindowPosDelegate);

            _setWindowSizeDelegate    = ImGui_ImplGlfw_SetWindowSize;
            io.Platform_SetWindowSize = Marshal.GetFunctionPointerForDelegate(_setWindowSizeDelegate);

            _getWindowSizeDelegate    = ImGui_ImplGlfw_GetWindowSize;
            io.Platform_GetWindowSize = Marshal.GetFunctionPointerForDelegate(_getWindowSizeDelegate);

            _setWindowFocusDelegate    = ImGui_ImplGlfw_SetWindowFocus;
            io.Platform_SetWindowFocus = Marshal.GetFunctionPointerForDelegate(_setWindowFocusDelegate);

            _getWindowFocusDelegate    = ImGui_ImplGlfw_GetWindowFocus;
            io.Platform_GetWindowFocus = Marshal.GetFunctionPointerForDelegate(_getWindowFocusDelegate);

            _getWindowMinimizedDelegate    = ImGui_ImplGlfw_GetWindowMinimized;
            io.Platform_GetWindowMinimized = Marshal.GetFunctionPointerForDelegate(_getWindowMinimizedDelegate);

            _setWindowAlphaDelegate    = ImGui_ImplGlfw_SetWindowAlpha;
            io.Platform_SetWindowAlpha = Marshal.GetFunctionPointerForDelegate(_setWindowAlphaDelegate);

            _setWindowTitleDelegate    = ImGui_ImplGlfw_SetWindowTitle;
            io.Platform_SetWindowTitle = Marshal.GetFunctionPointerForDelegate(_setWindowTitleDelegate);

            _renderWindowDelegate    = ImGui_ImplGlfw_RenderWindow;
            io.Platform_RenderWindow = Marshal.GetFunctionPointerForDelegate(_renderWindowDelegate);

            _swapBuffersDelegate    = ImGui_ImplGlfw_SwapBuffers;
            io.Platform_SwapBuffers = Marshal.GetFunctionPointerForDelegate(_swapBuffersDelegate);

            SetUpMonitorData();
        }