Exemple #1
0
        public void Init()
        {
            context.imguiContext = ImGui.CreateContext();
            ImGui.SetCurrentContext(context.imguiContext);
            var io = ImGui.GetIO();

            io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset;
            fontTexture      = new Texture2D();
            context.renderTargets["imgui_font"] = fontTexture;

            ImFontPtr font = io.Fonts.AddFontFromFileTTF("c:\\Windows\\Fonts\\SIMHEI.ttf", 14, null, io.Fonts.GetGlyphRangesChineseFull());

            io.Fonts.GetTexDataAsRGBA32(out byte *pixels, out int width, out int height, out int bytesPerPixel);
            io.Fonts.TexID = context.GetStringId("imgui_font");

            fontTexture.width     = width;
            fontTexture.height    = height;
            fontTexture.mipLevels = 1;
            fontTexture.format    = Format.R8G8B8A8_UNorm;
            imguiMesh             = context.GetMesh("imgui_mesh");

            GPUUpload gpuUpload = new GPUUpload();

            gpuUpload.texture2D   = fontTexture;
            gpuUpload.format      = Format.R8G8B8A8_UNorm;
            gpuUpload.textureData = new byte[width * height * bytesPerPixel];
            new Span <byte>(pixels, gpuUpload.textureData.Length).CopyTo(gpuUpload.textureData);

            context.uploadQueue.Enqueue(gpuUpload);
        }
Exemple #2
0
        public void Initialize()
        {
            commonRenderPipeline.context = context;
            GUIRender.context            = context;
            context.LoadDefaultResource();
            commonRenderPipeline.Initialize();



            GPUUpload uploadTest = new GPUUpload();

            uploadTest.mesh = context.GetMesh("quad");
            uploadTest.Quad();
            context.uploadQueue.Enqueue(uploadTest);

            GUIRender.Init();
            context.imguiInputHandler      = new ImGuiInputHandler();
            context.imguiInputHandler.hwnd = Win32Window.Handle;

            context.graphicsContext.Initialize(context.device);
            context.device.SetupSwapChain((IntPtr)Win32Window.Handle);
        }