Coder Social home page Coder Social logo

imgui.net's People

Contributors

amerkoleci avatar bennybroseph avatar callumdev avatar chairclr avatar cuber01 avatar darthdeus avatar devsaider avatar dpethes avatar drcynic avatar dvlcx avatar feliwir avatar flyingpie avatar freeapophis avatar giawa avatar kaydax avatar mbwilding avatar mellinoe avatar mrmav avatar nasser avatar noahstolk avatar oledfish avatar prime31 avatar roeyskoe avatar sergey-tihon avatar sneusse avatar tarik02 avatar thraka avatar tillalex avatar zaafar avatar zingballyhoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgui.net's Issues

Update to 1.51

1.51 is out and has some breaking changes and other improvements.

Add missing native imports and remove "duplicates"

Currently, ImGui.NET is very close to having full coverage of all cimgui exports for version 1.49. I did a quick diff and identified the following list of functions that are not yet imported. There are also a few functions in ImGuiNative that define helper overloads which call the actual imported function. IMO, there should only be a single import for each cimgui function, and helper overloads should go into the ImGui class, which is supposed to have the safe, friendly wrappers.

@dpethes Did you mention that you were working on TreeNode stuff? I think I am going to try to finish all of the below before I start handling the 1.50 upgrade and breaking changes.

Missing imports (Added in 93f9e60)

  • igCreateContext
  • igDestroyContext
  • igGetColorU32
  • igGetColorU32Vec
  • igGetCurrentContext
  • igGetFontTexUvWhitePixel
  • igGetKeyIndex
  • igGetTreeNodeToLabelSpacing
  • igIsItemClicked
  • igIsRootWindowOrAnyChildHovered
  • igNewLine
  • igPlotHistogram2
  • igPlotLines2
  • igProgressBar
  • igSetCurrentContext
  • igSetItemAllowOverlap
  • igSetNextWindowSizeConstraints
  • igTreeAdvanceToLabelPos
  • igValueColor
  • igValueColor2
  • ImFontConfig_DefaultConstructor
  • ImGuiIO_ClearInputCharacters

Use va_list or ... (problematic)

  • igBulletTextV
  • igLabelTextV
  • igSetTooltipV
  • igTextColoredV
  • igTextDisabledV
  • igTextV
  • igTextWrappedV
  • igTreeNodePtrV
  • igTreeNodeStrV
  • igTreeNodeExV
  • igTreeNodeExPtr
  • igTreeNodeExStr
  • igTreeNodeExVPtr

I think we should ignore the above. You can just use string.Format() and pass that to the single-string overload.

Duplicate imports

  • ImFontAtlas_AddFontDefault
  • igSliderFloat
  • igBeginPopupModal (x2)

FontAtlas issue

So when I call NewFrame I make it to line 2133 in imgui.cpp before it throws an exception:

IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded());
// Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?

In the ImGui fonts readme it states:

The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' that you can use without any external files.
The files in this folder are only provided as a convenience, you can use any of your own .TTF files.

Fonts are rasterized in a single texture at the time of calling either of io.Fonts.GetTexDataAsAlpha8()/GetTexDataAsRGBA32()/Build().

#########################
FONTS LOADING INSTRUCTIONS
#########################

Load default font with:

ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontDefault();

It seems ( I could be totally wrong) that in the sample this was achieved by:

ImGui.GetIO().FontAtlas.AddDefaultFont();

However the most recent version no longer has this method. I did notice that ImGui does have LoadDefaultFont(). I am unsure if this is meant to serve the same purpose, however, it did not seem to fix the issue. Thanks for any guidance, and awesome job on creating this.

PlotHistogram: Unexpected Values.

I'm getting strange values for the histogram bars, with a really simple example:

float[] _testArray = new float[11] { 0, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f };
ImGui.PlotHistogram("Stride1", _testArray, _testArray.Length, "", 0.0f, 1.0f, new System.Numerics.Vector2(160, 40), 1);
ImGui.PlotHistogram("Stride2", _testArray, _testArray.Length, "", 0.0f, 1.0f, new System.Numerics.Vector2(160, 40), 2);

plothistogram

The values where the bars are not showing (ie from tooltip text) are really strange values like: -1.342e+08
even the third visable bar on the top histogram in the screenshot has a strange value of 1.074e+08
as you can see from the _testArray these values are not in the array at all.
in the stride2 example each of the odd numbered bars are the correct values of: 0, 0.1, 0.2, 0.3, 0.4, 0.5
every other value is negative.

Thoughts: Change assembly versioning to match imgui

I'm considering changing ImGui.NET's assembly versioning to follow the versioning of imgui's -- at least partially. It probably makes sense to use a scheme like x.y.z, where x.y is the imgui version (currently 1.53), and z is a patch version for minor fixes made to ImGui.NET itself. This would make it a lot easier to tell which version of imgui you are getting with a particular version of ImGui.NET, since you currently need to crawl through the commit history to do that.

The only downside is now there will be an unusual bump from 0.4.0 to 1.53.0. Not a big deal, but it might be confusing initially.

Glyph range font ?

Hi !
I'm looking to specify a glyph range when I load a ttf font but I've found nothing related.
The problem appear when I want to display text with accent (eg é, è..)

Thanks for your help, Catvert.

ImVector types

Since as far as I know this isn't possible...

    [StructLayout(LayoutKind.Sequential)]
    public unsafe struct ImVector<T>
        where T: struct
    {
        public int Size;
        public int Capacity;
        ///<summary>T* Data</summary>
        public T* Data;
    }

Would there be consideration to clean some of these up with something like T4 Text Templates and auto generate a series of ImVectors as something like ...

    [StructLayout(LayoutKind.Sequential)]
    public unsafe struct ImVector
    {
        public int Size;
        public int Capacity;
        ///<summary>DrawVert* Data</summary>
        public DrawVert* Data;
    }

Could even implement something like...

    [StructLayout(LayoutKind.Sequential)]
    public unsafe struct ImVector
    {
        public int Size;
        public int Capacity;
        ///<summary>T* Data</summary>
        public DrawVert* Data;

        public ref DrawVert this[int index]
        {
            get
            {
                ////could save a lot of protected memory errors
                //if(index <= 0 || index >= Size)
                //    throw new ArgumentOutOfRangeException(nameof(index));
                return ref Data[index];
            }
        }
    }

I'm not sure on the level of where you want to take this project if its simply just "its good enough" then thats fine and I can start work in my own fork to tidy things up. I think this sort of goes with this issue #23 though and would be the start in implementing more friendly things.

EDIT: I had a bit of a hassle using this project (and some others last time) due to inconsistencies between the projects and in the end I ported ImGui to straight .NET here https://github.com/xposure/ImGuiSharp this didn't feel well received so I haven't expanded on it. Now I'm on a new project and circling back around to this.

Hiding close button on windows

ImGui supports hiding the close button on BeginWindow by passing in a null pointer to the p_opened value. I made the following change to support this in the .NET bindings but it would break the existing API if anyone is using it and not sure if thats something you would want a PR on.

It looks like some of the native structs don't have real wrappings to them (especially the window struct). There is some functionality I need and was thinking about implementing them.

Also some of the lower level imgui functions are missing from the cimgui library like the XYZBehavior methods creating a lot of hacks to get around this with setting positions and using invisible buttons.

ImGui.cs

        public unsafe static bool BeginWindow(string windowTitle, ref bool? opened, WindowFlags flags)
        {
            byte value = (opened.HasValue && opened.Value) ? (byte)1 : (byte)0;
            byte* p_opened = opened.HasValue ? &value : null;

            var result = ImGuiNative.igBegin(windowTitle, p_opened, flags);

            if (opened.HasValue)
                 opened = value == 1;

            
            return result;

        }

ImGuiNative.cs

        public static extern bool igBegin(string name, byte* p_opened, WindowFlags flags);

Edit: Corrected the code to use p_opened instead of the result of the call.

Consecutive ImageButtons don't react as expected on mouse click

Hello,

first, many thanks for providing us this great lib.
second, a disclaimer. I'm not totally sure to know the origin of this issue and it could most likely be me.

I'm using ImGui.net 0.4.3 with Monogame 3.7, and compiled 1.53 versions of imgui and cimgui.
I'm running an old 4.6.2 Mono, on Ubuntu.

I have an unexpected behavior with ImageButtons. If I add multiple buttons consecutively, in a child frame, only the first one actually return true when clicked. The other ones are actually showing imgui change of style when hovered and clicked, but they still return false when clicked.

I made a quick piece of code inside "SubmitImguiStuff()" to reproduce the issue and to ensure that it was not from my existing UIs , something like :
`int imagecount = 4;

        for (int i = 0; i < imagecount; i++)

        {

            if (ImGui.ImageButton(new IntPtr(0), new SVector2(25,25), SVector2.Zero, SVector2.One,2, SVector4.Zero, SVector4.One ))

            {

                _pressImageCount += 1;

            }

            if(i<imagecount-1) ImGui.SameLine();

        }

        ImGui.Text($"Image Buttons pressed {_pressImageCount} times.", new SVector4(0, 1, 1, 1));`

( using font atlas as a texture image, Svectors are shortcuot for System.Numerics.Vectors )

Any idea would be greatly appreciated.

Thanks in advance.
Best regards.

MIT license?

what's the license for this repo?

i'm willing to <-> integrate between my imgui wrapper which also boasts software rendering support, but I need the license to be MIT so I can reuse this for my dayjob

OpenTK window not opening when running sample on linux

I'm not sure if this is just an issue with using archlinux or not as you said you were able to get it running on ubuntu, but when running the provided sample program using the dotnet tools it doesn't crash but it doesn't display an OpenTK window either.

Clipboard

Hello

When I run the sample with openTK it's look like clipboard is natively managed. With my implementation who use SDL2 ( OpenTK for gl call) I don't have access to this function (ctrl-V, ctrl-C, ctrl-X).

It's not really an issue but if someone has managed to integrate IMGUI with SDL2CS can he say me if clipboard is native or I need to to do some stuff with GetClipboardTextFn and SetClipboardTextFn ?

Thanks !

Issue with DLL

  1. Added ImGui.NET to project via NuGet. (Also tried downloading project and building it and adding dll from release folder.

  2. Added reference in .cs

     using ImGuiNET;
    
  3. Added code just to add basic window.

     private void ImguiTest()
     {
         ImGui.BeginWindow("Test");
         ImGui.Text("Hello,");
         ImGui.Text("World!");
         ImGui.EndWindow();
     }
    

Getting error:
System.DllNotFoundException: 'Unable to load DLL 'cimgui': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

Not sure the issue?

"Issue: Assembly outside lib folder"

I have been trying to integrate ImGui.NET into a project that I am working on, but when I attempt to build and run the project with ImGui.NET included, I get the series of warnings shown in this picture:

http://i.imgur.com/FCteV0o.png

If I try to run the project, it fails, saying that it can't find that DLL.

I am using Visual Studio Community 2017 on a Windows 10 machine. The version of ImGui.NET that I am using in the project is the latest commit on the master branch. I have tried moving the DLL to several lib folders on various layers of the project, but to no avail.

Error Unsafe Context

@mellinoe
I get this error while building the project.
Using .Net Framework 4.6

CS0103 The name 'Unsafe' does not exist in the current context Imgui.NET c:\Users\Magic DPI\Documents\Visual Studio 2015\Projects\Imgui-FNA\Imgui.NET\TextInputBuffer.cs 49

Style issues

I have the code as a submodule and using the latest from master. I have the following issues...

  1. When calling GetStyle(), it seems like none of the colors are set. If i use PushStyleColor/Pop it works as expected.
  2. If I set Alpha to 0 on the style it crashes with unable to read or write protected memory in one of the end methods.

This seems straight forward so not sure what I'm doing wrong... I've tried updating the style after different rendering times.

EDIT: To clarify, the colors are set when calling GetColor from the style, but they don't appear to be used in ImGui unless I use Push/Pop instead.

    public class GameWindow
    {

        private Style style;

        public GameWindow()
        {
            SetupDefaultStyle();

        }

        private void SetupDefaultStyle()
        {
            if (style == null)
                style = ImGui.GetStyle();

            style.WindowRounding = 0;
            //style.Alpha = 0f; //crashes later when calling a EndXYZ method
            style.SetColor(ColorTarget.WindowBg, new Vector4(0));
            style.SetColor(ColorTarget.MenuBarBg, new Vector4(1f, 0f, 0f, 0));
        }

        public void Update()
        {
            SetupDefaultStyle();

        }

        public void Draw()
        {


            var io = ImGui.GetIO();
            var mainMenuBarHeight = 0f;

            //ImGui.PushStyleColor(ColorTarget.MenuBarBg, new Vector4(45 / 255f, 45 / 255f, 45 / 255f, 0));
            //draw main menu bar
            {
                ImGui.BeginMainMenuBar();
                if (ImGui.BeginMenu("hello"))
                {
                    ImGui.EndMenu();
                }
                mainMenuBarHeight = ImGui.GetWindowHeight();
                ImGui.EndMainMenuBar();
            }

            {
                ImGui.SetNextWindowPos(new Vector2(0, mainMenuBarHeight + 100), Condition.Always);
                ImGui.SetNextWindowSize(io.DisplaySize - new Vector2(0, mainMenuBarHeight), Condition.Always);

                ImGui.BeginWindow("Container", WindowFlags.NoTitleBar | WindowFlags.NoMove | WindowFlags.NoResize | WindowFlags.NoCollapse | WindowFlags.NoScrollbar | WindowFlags.NoScrollWithMouse | WindowFlags.NoFocusOnAppearing | WindowFlags.NoInputs);

                ImGui.EndWindow();
            }

            //ImGui.PopStyleColor();

        }

    }

Namespace and function names

Hello,
I realize this hasn't really been publicized and is work-in-progress (I stumbled on it yesterday while doing searches).
Thanks for looking into that!

Have only looked briefly, but may I suggest that the ImGuiNative.igButton() syntax be changed to something like ImGui.Button(). ?
O.

Input problem on OSX

Using trackpad, sample program always show

Current Mouse Position = <-9999,-9999> Pressed=false

Using a USB mouse, Pressed does respond, but Current Mouse Position is still the same

Using macOS Sierra version 10.12.6 and dotnet SDK 1.1.5

Tried

dotnet restore -r osx.10.11-x64
dotnet publish -c release -r osx.10.11-x64

and

dotnet restore -r osx.10.12-x64
dotnet publish -c release -r osx.10.12-x64

Same results.

Open File Dialog

As our project relies on a lot input and output, most of it controlled by the user, ImGui presents a major issue since it has no "native" (read: already implemented) open file/directory dialog. If my understanding is correct, this is mostly due to the fact that it is difficult to create a reliable cross-platform open file dialog due to the differences between systems (Windows, Linux, iOS).

Ocornut had a discussion about it here, and it seems that the result of that thread was imguifilesystem. This, however, is for the original ImGui, in C++. There is the option of converting the C++ to C#, but the file is large with a lot of branches depending on the underlying system. Is there an easier way to integrate this pre-made ImGui add-on with ImGui-NET? Or would we be better off working out our own open file dialog?

Shared project setup

Thoughts on moving to a shared project setup so that we can create bindings for different targets (like monogame for example)?

This would also help with this issue here #17

ImGui.ImageButton putting the application to a crawl.

Hey, just recently set up this project and i'm experimenting a bit with it, when i realized my frames started tanking with just 1 imgui window rendering.
First i suspected the rendering, since i didn't put in any work to adjust it to my rendering pipeline, but turns out that the culprit is in the ImGui.ImageButton() call. (removed all rendering calls and frames were still tanking).
It drops from the 120frame cap to 100 with 5 imagebuttons, and to 75 with 10 imagebuttons.

I didn't start any intense performance testing, but it appears the ImGui.*Widget calls generally consume quite a lot of time. Can you confirm or deny that?

Build info

Hi, it would be good to have some up-to-date build info - I assume the project is no longer buildable under VS2015 for example (I also have build issues after the last VS2017 update, but that's most likely unrelated)

I can not load images

I am to load images from file, it seems the texture I pass to the ImGui.Image() is never included in the drawlists.
Here is my image loader

GameItem.TextureID = GL.GenTexture();
                            Bitmap IconBitmap = GameItem.GetBitmap();
                            GL.BindTexture(TextureTarget.Texture2D, GameItem.TextureID);
                            BitmapData PixelData = IconBitmap.LockBits(new Rectangle(0, 0, 50, 50)
                                , ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, 50, 50, 0,
                                OpenTK.Graphics.OpenGL.PixelFormat.UnsignedShort, PixelType.Bitmap, PixelData.Scan0);
                            IconBitmap.UnlockBits(PixelData);
                            GL.BindTexture(TextureTarget.Texture2D, 0);

Then I load to imgui

foreach (GameItem GameItem in GameItems)
              {
                            ImGui.Image((IntPtr)GameItem.TextureID, new Vector2(50, 50), new Vector2(0, 0), new Vector2(1, 1),
                                new Vector4(0, 0, 0, 0), new Vector4(1, 1, 1, 1));
                        }

this is my imgui rendering method, adapted from you examples

private unsafe void RenderImDrawData(DrawData* draw_data)
        {
            // Rendering
            int display_w, display_h;
            display_w = Width;
            display_h = Height;

            Vector4 clear_color = new Vector4(114f / 255f, 144f / 255f, 154f / 255f, 1.0f);
            GL.Viewport(0, 0, display_w, display_h);
            GL.ClearColor(clear_color.X, clear_color.Y, clear_color.Z, clear_color.W);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            // We are using the OpenGL fixed pipeline to make the example code simpler to read!
            // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
            int last_texture;
            GL.GetInteger(GetPName.TextureBinding2D, out last_texture);
            GL.PushAttrib(AttribMask.EnableBit | AttribMask.ColorBufferBit | AttribMask.TransformBit);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.DepthTest);
            GL.Enable(EnableCap.ScissorTest);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.EnableClientState(ArrayCap.ColorArray);
            GL.Enable(EnableCap.Texture2D);

            GL.UseProgram(1);

            // Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
            IO io = ImGui.GetIO();
            ImGui.ScaleClipRects(draw_data, io.DisplayFramebufferScale);

            // Setup orthographic projection matrix
            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.LoadIdentity();
            GL.Ortho(
                0.0f,
                io.DisplaySize.X / io.DisplayFramebufferScale.X,
                io.DisplaySize.Y / io.DisplayFramebufferScale.Y,
                0.0f,
                -1.0f,
                1.0f);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PushMatrix();
            GL.LoadIdentity();

            // Render command lists

            for (int n = 0; n < draw_data->CmdListsCount; n++)
            {
                NativeDrawList* cmd_list = draw_data->CmdLists[n];
                byte* vtx_buffer = (byte*)cmd_list->VtxBuffer.Data;
                ushort* idx_buffer = (ushort*)cmd_list->IdxBuffer.Data;

                GL.VertexPointer(2, VertexPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.PosOffset));
                GL.TexCoordPointer(2, TexCoordPointerType.Float, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.UVOffset));
                GL.ColorPointer(4, ColorPointerType.UnsignedByte, sizeof(DrawVert), new IntPtr(vtx_buffer + DrawVert.ColOffset));

                for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
                {
                    DrawCmd* pcmd = &(((DrawCmd*)cmd_list->CmdBuffer.Data)[cmd_i]);
                    if (pcmd->UserCallback != IntPtr.Zero)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        GL.BindTexture(TextureTarget.Texture2D, pcmd->TextureId.ToInt32());
                        GL.Scissor(
                            (int)pcmd->ClipRect.X,
                            (int)(io.DisplaySize.Y - pcmd->ClipRect.W),
                            (int)(pcmd->ClipRect.Z - pcmd->ClipRect.X),
                            (int)(pcmd->ClipRect.W - pcmd->ClipRect.Y));
                        GL.DrawElements(PrimitiveType.Triangles, (int)pcmd->ElemCount, DrawElementsType.UnsignedShort, new IntPtr(idx_buffer));
                    }                    
                    if (pcmd->TextureId.ToInt32() > 2)
                    {
//break here
                    }
                    idx_buffer += pcmd->ElemCount;
                }
            }

            // Restore modified state
            GL.DisableClientState(ArrayCap.ColorArray);
            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GL.DisableClientState(ArrayCap.VertexArray);
            GL.BindTexture(TextureTarget.Texture2D, last_texture);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PopMatrix();
            GL.MatrixMode(MatrixMode.Projection);
            GL.PopMatrix();
            GL.PopAttrib();

            SwapBuffers();
        }

I can comfirm that the textures are being generated, and they have id greater than 2, also there are at least 8 bitmaps loaded from a list of files. But there are no textureids greater than 2 in the drawlists.

OpenTK + SDL2 issues on Windows

I had encountered this most bizzare issue: I couldn't get the sample program running when I returned to imgui.net after some time; even the older builds didn't work. Long story short - I figured out that after setting _nativeWindow.Visible = true; it was still false, so it wouldn't enter the eventloop and just close right away. It only happens when SDL2 is in the library load path - the GraphicsContext creates an internal context of type {OpenTK.Platform.Windows.WinGLContext}, but when it can find SDL2, it creates a context of type {OpenTK.Platform.SDL2.Sdl2GraphicsContext}, which exhibits the issue. So it probably has some bug, or needs some additional setup in this case.
It happens both with OpenTK for .net core and regular OpenTK2, on Windows 7/10, various SDL2 versions.

Auto-generate the native binding and marshalling code

In order to improve the maintainability of the library, I'm working on generating the native binding and marshalling code, building on top of the auto generated C bindings. This will allow me to generate struct and function definitions from pre-processed JSON files which include all the information I need, and which will be automatically updated with new imgui versions. We should also be able to get benefits like Unicode support much more easily with this approach, because we can spit out a lot of annoying boilerplate automatically. The autogen branch includes the current state of this work.

This will likely involve some breaking changes in the API. Newer versions of imgui (1.60+) already include a number of breaking changes that folks will have to react to anyways, so I think it is a good time to break things.

无法运行

我用VS2015打不开Git上的Sample工程
我自建了一个工程,把代码导入后,也运行不了
image

Add ListBox to ImGui wrapper class

Me again :)

I'm just getting started with ImGui.NET (having no prior experience with imgui). One of the first things I tried was creating a ListBox, but although this exists in ImGuiNative, it doesn't appear to be wrapped in ImGui. Am I missing something, or is this really not implemented?

If not, I'm happy to do a PR for it.

[Suggestion] Support Chinese Language

I add the code in Imgui like this.
image
then I modify the addFontbyFile function just follow imgui samples.
image
but is did not work just show chinese as ???.

PushStyleColor not pushing the correct color?

There seems to be a stange issue with ImGui.PushStyleColor(). It only seems to work with black, red and white. Any other color variant will generally result in black text.

System.Numerics.Vector4 color = new System.Numerics.Vector4(0, 128 / 255, 0, 1);
ImGui.PushStyleColor(ColorTarget.Text, color);
ImGui.Text("This text should be green, but it is black");
ImGui.PopStyleColor();

Any idea why this is happening @mellinoe ?
Thank you

SliderInt with custom display format has incorrect value

When using a SliderInt with a non-null display format, the format is respected but the value used for %d is incorrect.
When the slider is not being changed the value is 0.
When it is being changed the value seems to be completely random.

Here's the code i used to test this, in the sample program's SubmitUI method, under the SliderFloat example:

int fps = 10;

 ImGui.SliderInt("int", ref fps, 0, 60, "%d");

Even if fps is made static to retain the value it still happens.

The SliderFloat does work correctly when using format %0.1f, which leads me to assume that something is wrong with the specific type used, but the native demo's SliderInt works correctly.

I think it's caused by this code: https://github.com/ocornut/imgui/blob/ec04e8bb050ef42f25aee6e5748f4e0e153266bf/imgui_widgets.cpp#L2295

It only does this if the type is int32 but the strcmp should return 0 if i pass "%d", so i'm not sure what's going on here. I tried to marshal the display format as an ANSI string to see if encoding mattered, but that didn't do anything.

I've also noticed that there's an unused igSliderFloat overload that takes a float*, could this be related somehow?

Remove System.Numerics dependency

I'm maintaining a fork for .Net 4.0, which means I can't use System.Numerics. Therefore I replaced it with custom basic ImVec[234] structs (which also seems to me to follow the original's spirit). Would you accept this change? It would be a tremendous help for sychronizing between the projects.

IO.MousePosition goes negative when leaving window bounds

Small thing with the sample window.

https://github.com/mellinoe/ImGui.NET/blob/6b2c655922cee66dbb3938a1cd94b0f169d7966d/src/ImGui.NET.SampleProgram/SampleWindow.cs#L322

Should read as

if (_nativeWindow.Focused)

I know that file probably hasn't been touched in quite some time, but for myself and probably others, the code in that file is what we use to quickly get ImGui initialized without having to write a bunch of translated code. Figured I'd help fix that small annoyance.

For those wondering, this is what makes the values on a DragFloat or similar widget go negative when leaving the window. In all the imgui c++ examples, you are supposed to check to see if the window is focused, so I did the same here instead of seeing if the mouse is contained in the current context.

Can't load

Hello,
i can't load project in to visual studio 2015, .sln or .csproj throws error

C:\Downloads\ImGui.NET-master\src\ImGui.NET\ImGui.NET.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. C:\Downloads\ImGui.NET-master\src\ImGui.NET\ImGui.NET.csproj

C:\Downloads\ImGui.NET-master\src\ImGui.NET.SampleProgram\ImGui.NET.SampleProgram.csproj : error : The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. C:\Downloads\ImGui.NET-master\src\ImGui.NET.SampleProgram\ImGui.NET.SampleProgram.csproj

Strange code in sample renderer

Hey there :)

I was taking a look at the sample renderer in order to help somebody at the imgui gitter, and found somethings I can't make sense of:

https://github.com/mellinoe/ImGui.NET/blob/1826f494b64af97ad5c48f761c56f6646932e222/src/ImGui.NET.SampleProgram/SampleWindow.cs#L403-L405
https://github.com/mellinoe/ImGui.NET/blob/1826f494b64af97ad5c48f761c56f6646932e222/src/ImGui.NET.SampleProgram/SampleWindow.cs#L426-L427

I believe these are bogus code, but I could be wrong because I'm just browsing from the web.

Font's returned as garbage

I'm not getting back the default font correctly. I'm receiving it as garbage. Only portions of the first two lines are read, and nothing else is returned properly

IO io = ImGui.GetIO();

        FontTextureData textureData = io.FontAtlas.GetTexDataAsRGBA32();

int[] pixels = new int[textureData.Width * textureData.Height];
int count = 0;
for (int i = 0; i < textureData.Height; i++)
{
for (int j = 0; j < textureData.Width; j++)
{

                pixels[i + j] = *((uint* )textureData.Pixels + count);
                count += textureData.BytesPerPixel; 
            }
        }

Is an example of how I'm getting the data. It seems to read the only the first two lines, then it returns transparent pixels for the rest.

If I load the font texture myself (as a png I took from the native imgui) everything works fine.

Unsafe code

I just did a quick once over and is there any particular reason there is so much unsafe code in here?

Most of the functions just look like a raw pointer needs to be changed to a reference. It says there is an effort underway to change the exposed messages to safe code, but is that still planned? Is contribution welcomed?

ShowBorders

Seems like WindowFlags.ShowBorders is ignored. Looking at the imgui this was built against, it seems if show border is set to true it will simply draw a 1px border but I can't get it to.

Newer version of imgui .net have created a border size in the style struct, any eta on this?

Click events are sometimes eaten.

Click events are sometimes eaten.
eg: fast click a button 10 times, at least 3 times no response

I test the native imGui version 1.53(the same version as imGUI.NET), no this problem.

this is compare gif

Native imGUI:
imgui_opengl3-export

ImGUI.NET:
imgui net-export


environment:
macOS 10.12.6
ImGui.NET with metal Backend, opengl Backend

v1.52?

Hi !
I noticed that version 1.52 of cimgui had been released for some time so I wonder when you plan to upgrade ImGui.Net to this new version?
Thanks, Catvert.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.