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); }