protected unsafe virtual void Create() { IO io = ImGui.GetIO(); // Build texture atlas FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); // Create OpenGL texture g_FontTexture = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, g_FontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, texData.Width, texData.Height, 0, PixelFormat.Alpha, PixelType.UnsignedByte, new IntPtr(texData.Pixels)); // Store the texture identifier in the ImFontAtlas substructure. io.FontAtlas.SetTexID(g_FontTexture); // Cleanup (don't clear the input data if you want to append new fonts later) //io.Fonts->ClearInputData(); io.FontAtlas.ClearTexData(); GL.BindTexture(TextureTarget.Texture2D, 0); }
private Texture2D CreateFontTexture() { IO io = ImGui.GetIO(); // Build texture atlas FontTextureData texData = io.FontAtlas.GetTexDataAsRGBA32(); using (var bitmap = new Bitmap(texData.Width, texData.Height, PixelFormat.Format32bppArgb)) { var srcStride = texData.BytesPerPixel * texData.Width; var locked = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); for (int i = 0; i < locked.Height; ++i) { Buffer.MemoryCopy( texData.Pixels + srcStride * i, (locked.Scan0 + locked.Stride * i).ToPointer(), locked.Width * 4, locked.Width * 4); } bitmap.UnlockBits(locked); var font = _device.CreateTexture2D(bitmap); io.FontAtlas.SetTexID(1); io.FontAtlas.ClearTexData(); return(font); } }
/// <summary> /// Recreates the device texture used to render text. /// </summary> public unsafe void RecreateFontDeviceTexture(GraphicsDevice gd) { IO io = ImGui.GetIO(); // Build FontTextureData textureData = io.FontAtlas.GetTexDataAsRGBA32(); // Store our identifier io.FontAtlas.SetTexID(_fontAtlasID); _fontTexture = gd.ResourceFactory.CreateTexture(TextureDescription.Texture2D( (uint)textureData.Width, (uint)textureData.Height, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.Sampled)); _fontTexture.Name = "ImGui.NET Font Texture"; gd.UpdateTexture( _fontTexture, (IntPtr)textureData.Pixels, (uint)(textureData.BytesPerPixel * textureData.Width * textureData.Height), 0, 0, 0, (uint)textureData.Width, (uint)textureData.Height, 1, 0, 0); _fontTextureView = gd.ResourceFactory.CreateTextureView(_fontTexture); io.FontAtlas.ClearTexData(); }
protected unsafe virtual void Create() { IO io = ImGui.GetIO(); // Build texture atlas FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); int lastTexture; GL.GetInteger(GetPName.TextureBinding2D, out lastTexture); // Create OpenGL texture GL.GenTextures(1, out g_FontTexture); GL.BindTexture(TextureTarget.Texture2D, g_FontTexture); GL.TextureParameterI((int)TextureTarget.Texture2D, All.TextureMinFilter, new int[] { (int)TextureMagFilter.Linear, (int)TextureMagFilter.Linear }); GL.PixelStore(PixelStoreParameter.UnpackRowLength, 0); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, texData.Width, texData.Height, 0, PixelFormat.Alpha, PixelType.UnsignedByte, new IntPtr(texData.Pixels) ); // Store the texture identifier in the ImFontAtlas substructure. io.FontAtlas.SetTexID(g_FontTexture); io.FontAtlas.ClearTexData(); // Clears CPU side texture data. GL.BindTexture(TextureTarget.Texture2D, lastTexture); }
private static void createFontsTexture() { // build texture atlas IO io = ImGui.GetIO(); FontTextureData pixels = io.FontAtlas.GetTexDataAsRGBA32(); // copy data to managed array byte[] pixelsArray = new byte[pixels.Width * pixels.Height * pixels.BytesPerPixel]; unsafe { Marshal.Copy(new IntPtr(pixels.Pixels), pixelsArray, 0, pixelsArray.Length); } // create texture GL.GetInteger(GetPName.TextureBinding2D, out int lastTexture); _fontsTextureHandle = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, _fontsTextureHandle); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.PixelStore(PixelStoreParameter.UnpackRowLength, 0); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, pixels.Width, pixels.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, pixelsArray); io.FontAtlas.SetTexID(_fontsTextureHandle); io.FontAtlas.ClearTexData(); // restore state GL.BindTexture(TextureTarget.Texture2D, lastTexture); }
public ImGuiHelper(Game game) { this.game = game; game.Keyboard.KeyDown += Keyboard_KeyDown; game.Keyboard.KeyUp += Keyboard_KeyUp; game.Keyboard.TextInput += Keyboard_TextInput; SetKeyMappings(); var io = ImGui.GetIO(); unsafe { io.GetNativePointer()->IniFilename = IntPtr.Zero; } Default = io.FontAtlas.AddDefaultFont(); using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.Roboto-Medium.ttf")) { var ttf = new byte[stream.Length]; stream.Read(ttf, 0, ttf.Length); ttfPtr = Marshal.AllocHGlobal(ttf.Length); Marshal.Copy(ttf, 0, ttfPtr, ttf.Length); Noto = io.FontAtlas.AddFontFromMemoryTTF(ttfPtr, ttf.Length, 15); } using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.checkerboard.png")) { checkerboard = LibreLancer.ImageLib.Generic.FromStream(stream); CheckerboardId = RegisterTexture(checkerboard); } using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.circle.png")) { circle = LibreLancer.ImageLib.Generic.FromStream(stream); CircleId = RegisterTexture(circle); } unsafe { ImGuiExt.BuildFontAtlas((IntPtr)ImGuiNative.igGetIO()->FontAtlas); } FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); fontTexture = new Texture2D(texData.Width, texData.Height, false, SurfaceFormat.R8); var bytes = new byte[texData.Width * texData.Height * texData.BytesPerPixel]; unsafe { Marshal.Copy((IntPtr)texData.Pixels, bytes, 0, texData.Width * texData.Height * texData.BytesPerPixel); } fontTexture.SetData(bytes); fontTexture.SetFiltering(TextureFiltering.Linear); io.FontAtlas.SetTexID(FONT_TEXTURE_ID); io.FontAtlas.ClearTexData(); textShader = new Shader(vertex_source, text_fragment_source); colorShader = new Shader(vertex_source, color_fragment_source); dot = new Texture2D(1, 1, false, SurfaceFormat.Color); var c = new Color4b[] { Color4b.White }; dot.SetData(c); Theme.Apply(); }
public static unsafe void Initiailize(Game game) { _game = game; var graphicsDevice = _game.GraphicsDevice; _vertexBuffer = new VertexBuffer(graphicsDevice, ImGuiVertex.VertexDeclaration, 1024, BufferUsage.WriteOnly); _indexBuffer = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, 256, BufferUsage.WriteOnly); var io = ImGui.GetIO(); io.KeyMap[GuiKey.Tab] = (int)Keys.Tab; io.KeyMap[GuiKey.LeftArrow] = (int)Keys.Left; io.KeyMap[GuiKey.RightArrow] = (int)Keys.Right; io.KeyMap[GuiKey.UpArrow] = (int)Keys.Up; io.KeyMap[GuiKey.DownArrow] = (int)Keys.Down; io.KeyMap[GuiKey.PageUp] = (int)Keys.PageUp; io.KeyMap[GuiKey.PageDown] = (int)Keys.PageDown; io.KeyMap[GuiKey.Home] = (int)Keys.Home; io.KeyMap[GuiKey.End] = (int)Keys.End; io.KeyMap[GuiKey.Delete] = (int)Keys.Delete; io.KeyMap[GuiKey.Backspace] = (int)Keys.Back; io.KeyMap[GuiKey.Enter] = (int)Keys.Enter; io.KeyMap[GuiKey.Escape] = (int)Keys.Escape; io.KeyMap[GuiKey.A] = (int)Keys.A; io.KeyMap[GuiKey.C] = (int)Keys.C; io.KeyMap[GuiKey.V] = (int)Keys.V; io.KeyMap[GuiKey.X] = (int)Keys.X; io.KeyMap[GuiKey.Y] = (int)Keys.Y; io.KeyMap[GuiKey.Z] = (int)Keys.Z; //io.FontAtlas.AddFontFromFileTTF("C:\\windows\\fonts\\segoeui.ttf", 24); io.FontAtlas.AddDefaultFont(); // Build texture atlas FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); var colorData = new Color[texData.Width * texData.Height]; var pixels = texData.Pixels; for (var i = 0; i < colorData.Length; i++) { var v = pixels[i]; colorData[i] = new Color(1f, 1f, 1f, 255f / v) * (255f / v); } fontTexture = new Texture2D(graphicsDevice, texData.Width, texData.Height); fontTexture.SetData(colorData); io.FontAtlas.SetTexID(fontTexture.GetHashCode()); io.FontAtlas.ClearTexData(); }
public unsafe void RecreateFontDeviceTexture(RenderContext rc) { var io = ImGui.GetIO(); // Build _textureData = io.FontAtlas.GetTexDataAsRGBA32(); int[] pixels = new int[_textureData.Width * _textureData.Height]; for (int i = 0; i < pixels.Length; i++) { pixels[i] = ((int *)_textureData.Pixels)[i]; } _fontTexture = new RawTextureDataArray <int>(pixels, _textureData.Width, _textureData.Height, _textureData.BytesPerPixel, PixelFormat.R8_G8_B8_A8); // Store our identifier io.FontAtlas.SetTexID(_fontAtlasID); var deviceTexture = rc.ResourceFactory.CreateTexture(_fontTexture.PixelData, _textureData.Width, _textureData.Height, _textureData.BytesPerPixel, PixelFormat.R8_G8_B8_A8); _fontTextureBinding = rc.ResourceFactory.CreateShaderTextureBinding(deviceTexture); io.FontAtlas.ClearTexData(); }
private unsafe void CreateFontsTexture(RenderContext rc) { IO io = ImGui.GetIO(); if (!string.IsNullOrEmpty(Preferences.Instance.MenuFont)) { if (File.Exists(Preferences.Instance.MenuFont)) { float fontSize = Math.Max(4, Math.Min(48, Preferences.Instance.FontSize)); var font = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(io.GetNativePointer()->FontAtlas, Preferences.Instance.MenuFont, fontSize, IntPtr.Zero, null); } else { Console.WriteLine("Font listed in preferences doesn't exist: " + Preferences.Instance.MenuFont); } } else { ImGui.LoadDefaultFont(); } // Build _textureData = io.FontAtlas.GetTexDataAsRGBA32(); int[] pixels = new int[_textureData.Width * _textureData.Height]; for (int i = 0; i < pixels.Length; i++) { pixels[i] = ((int *)_textureData.Pixels)[i]; } _fontTexture = new RawTextureDataArray <int>(pixels, _textureData.Width, _textureData.Height, _textureData.BytesPerPixel, PixelFormat.R8_G8_B8_A8); // Store our identifier io.FontAtlas.SetTexID(_fontAtlasID); // Cleanup (don't clear the input data if you want to append new fonts later) io.FontAtlas.ClearTexData(); }
private unsafe void CreateDeviceObjects() { int lastTexture, lastArrayBuffer, lastVertexArray; GL.GetInteger(GetPName.TextureBinding2D, out lastTexture); GL.GetInteger(GetPName.ArrayBufferBinding, out lastArrayBuffer); GL.GetInteger(GetPName.VertexArrayBinding, out lastVertexArray); const string vertShader = "" + "#version 330\n" + "uniform mat4 ProjMtx;\n" + "" + "in vec2 Position;\n" + "in vec2 UV;\n" + "in vec4 Color;\n" + "" + "out vec2 Frag_UV;\n" + "out vec4 Frag_Color;\n" + "" + //"out vec4 vertPos;\n" + "" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n" + //" vertPos = gl_Position;" + "}\n"; const string fragShader = "" + "#version 330\n" + "" + "uniform sampler2D Texture;\n" + "in vec2 Frag_UV;\n" + "in vec4 Frag_Color;\n" + //"in vec4 vertPos;\n" + "out vec4 Out_Color;\n" + "" + "void main()\n" + "{\n" + " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" + "}\n"; shaderHandle = GL.CreateProgram(); vertHandle = GL.CreateShader(ShaderType.VertexShader); fragHandle = GL.CreateShader(ShaderType.FragmentShader); GL.ShaderSource(vertHandle, vertShader); GL.ShaderSource(fragHandle, fragShader); GL.CompileShader(vertHandle); GL.CompileShader(fragHandle); GL.AttachShader(shaderHandle, vertHandle); GL.AttachShader(shaderHandle, fragHandle); if (GL.GetShaderInfoLog(vertHandle) != "") { Console.WriteLine("Vert Error: " + GL.GetShaderInfoLog(vertHandle)); } if (GL.GetShaderInfoLog(fragHandle) != "") { Console.WriteLine("Frag Error: " + GL.GetShaderInfoLog(fragHandle)); } GL.LinkProgram(shaderHandle); if (GL.GetProgramInfoLog(shaderHandle) != "") { Console.WriteLine("Program Error: " + GL.GetProgramInfoLog(shaderHandle)); } attribLocationTex = GL.GetUniformLocation(shaderHandle, "Texture"); attribLocationProjMtx = GL.GetUniformLocation(shaderHandle, "ProjMtx"); attribLocationPosition = GL.GetAttribLocation(shaderHandle, "Position"); attribLocationUV = GL.GetAttribLocation(shaderHandle, "UV"); attribLocationColor = GL.GetAttribLocation(shaderHandle, "Color"); //Console.WriteLine(GL.GetError()); GL.GenBuffers(1, out vboHandle); GL.GenBuffers(1, out elementsHandle); GL.GenVertexArrays(1, out vaoHandle); GL.BindVertexArray(vaoHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, vboHandle); GL.EnableVertexAttribArray(attribLocationPosition); GL.EnableVertexAttribArray(attribLocationUV); GL.EnableVertexAttribArray(attribLocationColor); //Console.WriteLine(GL.GetError()); GL.VertexAttribPointer( attribLocationPosition, 2, VertexAttribPointerType.Float, false, sizeof(DrawVert), new IntPtr(DrawVert.PosOffset) ); GL.VertexAttribPointer( attribLocationUV, 2, VertexAttribPointerType.Float, false, sizeof(DrawVert), new IntPtr(DrawVert.UVOffset) ); //new IntPtr(&(((DrawVert*)0)->uv)) GL.VertexAttribPointer( attribLocationColor, 4, VertexAttribPointerType.UnsignedByte, true, sizeof(DrawVert), new IntPtr(DrawVert.ColOffset) ); //Fonts IO io = ImGui.GetIO(); io.FontAtlas.AddFontFromFileTTF("Roboto-Regular.ttf", 15); FontTextureData texData = io.FontAtlas.GetTexDataAsRGBA32(); fontTexture = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, fontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texData.Width, texData.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, new IntPtr(texData.Pixels)); io.FontAtlas.SetTexID(fontTexture); io.FontAtlas.ClearTexData(); GL.BindTexture(TextureTarget.Texture2D, 1); //Restore GL.BindTexture(TextureTarget.Texture2D, lastTexture); GL.BindBuffer(BufferTarget.ArrayBuffer, lastArrayBuffer); GL.BindVertexArray(lastVertexArray); }
/// <summary> /// Creates the device objects, initializes GUI shaders, and the font texture. /// </summary> private unsafe void CreateDeviceObjects() { //Backup OpenGL state so it can be restored after creating new shaders/program int lastTexture, lastArrayBuffer, lastVertexArray; GL.GetInteger(GetPName.TextureBinding2D, out lastTexture); GL.GetInteger(GetPName.ArrayBufferBinding, out lastArrayBuffer); GL.GetInteger(GetPName.VertexArrayBinding, out lastVertexArray); const string vertShader = "" + "#version 330\n" + "uniform mat4 ProjMtx;\n" + "" + "in vec2 Position;\n" + "in vec2 UV;\n" + "in vec4 Color;\n" + "" + "out vec2 Frag_UV;\n" + "out vec4 Frag_Color;\n" + "" + //"out vec4 vertPos;\n" + "" + "void main()\n" + "{\n" + " Frag_UV = UV;\n" + " Frag_Color = Color;\n" + " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n" + //" vertPos = gl_Position;" + "}\n"; const string fragShader = "" + "#version 330\n" + "" + "uniform sampler2D Texture;\n" + "in vec2 Frag_UV;\n" + "in vec4 Frag_Color;\n" + //"in vec4 vertPos;\n" + "out vec4 Out_Color;\n" + "" + "void main()\n" + "{\n" + " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" + "}\n"; //Create and compile shaders into program _guiShaderHandle = GL.CreateProgram(); _vertHandle = GL.CreateShader(ShaderType.VertexShader); _fragHandle = GL.CreateShader(ShaderType.FragmentShader); GL.ShaderSource(_vertHandle, vertShader); GL.ShaderSource(_fragHandle, fragShader); GL.CompileShader(_vertHandle); GL.CompileShader(_fragHandle); GL.AttachShader(_guiShaderHandle, _vertHandle); GL.AttachShader(_guiShaderHandle, _fragHandle); if (GL.GetShaderInfoLog(_vertHandle) != "") { Console.WriteLine("Vert Error: " + GL.GetShaderInfoLog(_vertHandle)); } if (GL.GetShaderInfoLog(_fragHandle) != "") { Console.WriteLine("Frag Error: " + GL.GetShaderInfoLog(_fragHandle)); } GL.LinkProgram(_guiShaderHandle); if (GL.GetProgramInfoLog(_guiShaderHandle) != "") { Console.WriteLine("Program Error: " + GL.GetProgramInfoLog(_guiShaderHandle)); } //Get locations for Texture, Projection Matrix, Position, UV, and Color fields _guiAttribLocationTex = GL.GetUniformLocation(_guiShaderHandle, "Texture"); _guiAttribLocationProjMtx = GL.GetUniformLocation(_guiShaderHandle, "ProjMtx"); _attribLocationPosition = GL.GetAttribLocation(_guiShaderHandle, "Position"); _attribLocationUv = GL.GetAttribLocation(_guiShaderHandle, "UV"); _attribLocationColor = GL.GetAttribLocation(_guiShaderHandle, "Color"); //Gen vbo, vao, and element array GL.GenBuffers(1, out _guiVboHandle); GL.GenBuffers(1, out _elementsHandle); GL.GenVertexArrays(1, out _guiVaoHandle); GL.BindVertexArray(_guiVaoHandle); GL.BindBuffer(BufferTarget.ArrayBuffer, _guiVboHandle); GL.EnableVertexAttribArray(_attribLocationPosition); GL.EnableVertexAttribArray(_attribLocationUv); GL.EnableVertexAttribArray(_attribLocationColor); //Setup attributes for Location, UV, and Color GL.VertexAttribPointer( _attribLocationPosition, 2, VertexAttribPointerType.Float, false, sizeof(DrawVert), new IntPtr(DrawVert.PosOffset) ); GL.VertexAttribPointer( _attribLocationUv, 2, VertexAttribPointerType.Float, false, sizeof(DrawVert), new IntPtr(DrawVert.UVOffset) ); GL.VertexAttribPointer( _attribLocationColor, 4, VertexAttribPointerType.UnsignedByte, true, sizeof(DrawVert), new IntPtr(DrawVert.ColOffset) ); //Create fonts IO io = ImGui.GetIO(); FontConfig config; //Get font from file and add as RGBA32 io.FontAtlas.AddFontFromFileTTF(new Uri(_baseDirectory + "/Resources/Fonts/Roboto-Regular.ttf").LocalPath, 18.0f); //TODO add fontawsome //Merge normal font texture with font awesome fonts //config.MergeMode = true; //io.FontAtlas.AddFontFromFileTTF(new Uri(_baseDirectory + "/Resources/Fonts/fontawesome-webfont.ttf").LocalPath, 18); //char[] iconRanges = new[] {ICON_MIN_FA, ICON_MAX_FA, 0 }; FontTextureData texData = io.FontAtlas.GetTexDataAsRGBA32(); //Create font texture _fontTexture = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, _fontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texData.Width, texData.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, new IntPtr(texData.Pixels)); io.FontAtlas.SetTexID(_fontTexture); io.FontAtlas.ClearTexData(); GL.BindTexture(TextureTarget.Texture2D, 1); //Restore old OpenGL state GL.BindTexture(TextureTarget.Texture2D, lastTexture); GL.BindBuffer(BufferTarget.ArrayBuffer, lastArrayBuffer); GL.BindVertexArray(lastVertexArray); }
internal static unsafe void Init(Window window) { if (!Engine.Get.RenderImGui) { return; } if (Initialized) { return; } Initialized = true; window.InputActionEvent += OnInputAction; window.InputScrollWheel += OnInputScrollWheel; IO io = ImGui.GetIO(); io.KeyMap[GuiKey.Tab] = (int)Key.Tab; io.KeyMap[GuiKey.LeftArrow] = (int)Key.Left; io.KeyMap[GuiKey.RightArrow] = (int)Key.Right; io.KeyMap[GuiKey.UpArrow] = (int)Key.Up; io.KeyMap[GuiKey.DownArrow] = (int)Key.Down; io.KeyMap[GuiKey.PageUp] = (int)Key.PageUp; io.KeyMap[GuiKey.PageDown] = (int)Key.Down; io.KeyMap[GuiKey.Home] = (int)Key.Home; io.KeyMap[GuiKey.End] = (int)Key.End; io.KeyMap[GuiKey.Delete] = (int)Key.Delete; io.KeyMap[GuiKey.Backspace] = (int)Key.Backspace; io.KeyMap[GuiKey.Enter] = (int)Key.Enter; io.KeyMap[GuiKey.Escape] = (int)Key.Escape; io.KeyMap[GuiKey.A] = (int)Key.A; io.KeyMap[GuiKey.C] = (int)Key.C; io.KeyMap[GuiKey.V] = (int)Key.V; io.KeyMap[GuiKey.X] = (int)Key.X; io.KeyMap[GuiKey.Y] = (int)Key.Y; io.KeyMap[GuiKey.Z] = (int)Key.Z; // Build texture atlas FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); // Create OpenGL texture _fontTexture = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, _fontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); GL.TexImage2D( TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, texData.Width, texData.Height, 0, PixelFormat.Alpha, PixelType.UnsignedByte, new IntPtr(texData.Pixels)); // Store the texture identifier in the ImFontAtlas substructure. io.FontAtlas.SetTexID(_fontTexture); // Cleanup (don't clear the input data if you want to append new fonts later) //io.Fonts->ClearInputData(); io.FontAtlas.ClearTexData(); GL.BindTexture(TextureTarget.Texture2D, 0); }