Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
ImGui new thread - Page 3 — Gideros Forum

ImGui new thread

1356722

Comments

  • MoKaLuxMoKaLux Member
    edited April 2021


    :-1: error: cannot find -llua
    :-1: error: cannot find -lgideros...
    collect2.exe:-1: error: error: ld returned 1 exit status

    C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llua
    C:/Qt/Tools/mingw530_32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgideros...
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[1]: *** [debug\imgui.dll] Error 1
    mingw32-make: *** [debug] Error 2

    - I have cloned gideros github to my computer: C:\gideros\my_gideros\
    - I opened C:\gideros\my_gideros\plugins\imgui\source\Desktop\imgui.pro with Qt5.10.1 (with MinGW)


    The errors come from this line in imgui.pro:
    43 LIBS += -L"../../../../Sdk/lib/desktop" -llua -lgideros -lgid -lgvfs

    and effectively this folder is empty:
    C:\gideros\my_gideros\Sdk\lib\desktop\

    What am I missing? Any help please <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited April 2021
    MoKaLux said:

    and effectively this folder is empty:
    C:\gideros\my_gideros\Sdk\lib\desktop\

    But it should not


    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited April 2021


    ok so I copied the missing files from gideros installation folder to my gideros folder (c:/gideros/my_gideros/Sdk/lib/desktop) and that worked :) I could compile imgui.dll in both debug and release mode.
    Now I just need to copy the dll to C:\Program Files (x86)\Gideros\Plugins and test :smile: Thank you for your help rrraptor
    EDIT
    : that seems to work :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited April 2021
    I don't understand the magic :o
    imgui.h IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2);
    imgui.cpp ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
    TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING");
    imgui_demo.cpp ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink");
    imgui_widgets.cpp
    void ImGui::TextColored(const ImVec4& col, const char* fmt, ...)
    { va_list args; va_start(args, fmt); TextColoredV(col, fmt, args); va_end(args); }
    imgui_bindings.cpp
    int TextColored(lua_State* L) {
    const char* text = luaL_checkstring(L, 2);
    ImGui::TextColored(GColor::toVec4(luaL_checkinteger(L, 3), luaL_optnumber(L, 4, 1.0f)), "%s", text);
    return 0;
    }

    Every functions seem we should call textColored(0xff0000, 1, "some text") but instead it is used like this: ImGui:textColored(text, color)!?!?
    How is this possible? I don't understand!? Is there a secret file?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited April 2021
    to delete!
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited April 2021
    Ok I have tested my commit on my machine and I can say it didn't break anything :) (fixes 1 or 2 things see: https://github.com/gideros/gideros/pull/509/files)

    here is a modified imgui.dll https://github.com/mokalux/gideros_various you can paste it in your C:\Program Files (x86)\Gideros\Plugins (make a backup of the original), then call require "ImGuiX". I don't know if that works for all platforms or if I need to build those (which I don't know how to yet!)
    Let us know if you find other problems.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLux said:


    Every functions seem we should call textColored(0xff0000, 1, "some text") but instead it is used like this: ImGui:textColored(text, color)!?!?
    How is this possible? I don't understand!? Is there a secret file?

    I thought that fmt means format (like LUA string.format), so there is "%s" followed by text argument. And from LUA side it is
    textColored("some text", 0xff0000, 1)
    Take text argument:
    const char* text = luaL_checkstring(L, 2);
    Take the color as hex
    luaL_checkinteger(L, 3)
    Take alpha
    luaL_optnumber(L, 4, 1.0f)
    Convert color to ImGui format
    GColor::toVec4(...)
  • MoKaLuxMoKaLux Member
    edited April 2021
    oh yes that makes sense now that you wrote it :)
    int TextColored(lua_State* L)
    {
    const char* text = luaL_checkstring(L, 2);
    ImGui::TextColored(GColor::toVec4(luaL_checkinteger(L, 3), luaL_optnumber(L, 4, 1.0f)), "%s", text);
    return 0;
    }

    It's the lua function that wins. First argument = string (the text) and then the color (hex, alpha), and it returns nothing (int = 0). Thank you mister :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited April 2021
    Fun fact. ImGui draw lists is faster than gideros particles :D
    Particles: 1 fps (but when using imgui to show fps text, it says 7 fps, and then it slows down to 1)
    ImGui draw list: 21-24 fps
    Demo code:
    USE_IMUGI @ true -- change this line 
     
    GW @ 256
    GH @ 128
    TILE @ 4
    HTILE @ &TILE/2&
     
    require "FastNoise"
    local perlin = Noise.new()
    perlin:setNoiseType(Noise.PERLIN)
    perlin:setFrequency(0.06)
    perlin:setFractalOctaves(5)
     
    local ps = Particles.new()
    local tf = TextField.new()
    tf:setPosition(10,20)
    local timer = 0
     
     
    require "ImGui"
    local ui = ImGui.new()
    local IO = ui:getIO()
     
    if (not USE_IMUGI) then
    	stage:addChild(ps)
    	stage:addChild(tf)
    else
    	stage:addChild(ui)
    end
    -- actual area size
    local REAL = Pixel.new(0xff0000, 0.2, GW,GH)
    REAL:setY(11 * TILE)
    REAL:setScale(TILE)
    stage:addChild(REAL)
     
    local function onEnterFrame(e)
    	local dt = e.deltaTime
    	tf:setText(1//dt)
    	timer += dt
    	ps:removeParticles()
    	for y = 1, GH do 
    		for x = 1, GW do 
    			local v = (perlin:noise(x, y, timer*10)+1) / 2-- math.random(1, 5) - 1
    			if (v > 0) then 
    				local sx = (x - 1) * TILE
    				local sy = (y + 10) * TILE
    				local c = v * 255
    				ps:addParticles{{
    					x = sx + HTILE, 
    					y = sy + HTILE, 
    					size = -TILE,
    					color = ("0x%02x%02x%02x"):format(c,c,c)
    				}}
    			end
    		end
    	end
    end
    --
     
    local function onDrawGui(e)
    	ui:newFrame(e)
    	ui:value("FPS",IO:getFramerate())
     
    	local list = ui:getBackgroundDrawList()
    	for y = 1, GH do 
    		for x = 1, GW do 
    			local v = (perlin:noise(x, y, ui:getTime()*10)+1) / 2-- math.random(1, 5) - 1
    			if (v > 0) then 
    				local sx = (x - 1) * TILE
    				local sy = (y + 10) * TILE
    				local c = v * 255
    				list:addRectFilled(sx, sy, sx + TILE, sy + TILE, ("0x%02x%02x%02x"):format(c,c,c))
    			end
    		end
    	end
    	ui:render()
    	ui:endFrame()
    end
     
    local function onAppResize()
    	local minX, minY, maxX, maxY = application:getLogicalBounds()
    	local W, H = maxX - minX, maxY - minY
     
    	ui:setPosition(minX, minY)
    	IO:setDisplaySize(W, H)
    end
    --
    if (USE_IMUGI) then
    	onAppResize()
    	stage:addEventListener("enterFrame", onDrawGui)
    else
    	stage:addEventListener("enterFrame", onEnterFrame)
    end	
    stage:addEventListener("applicationResize", onAppResize)

    Also, it seems that gideros have limited amount of triangles that it can draw in a single frame because in this demo actual grid size must be 1024x512, but it shows a 1024x256 rectangle

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    rrraptor said:

    Fun fact. ImGui draw lists is faster than gideros particles :D
    ...
    Also, it seems that gideros have limited amount of triangles that it can draw in a single frame because in this demo actual grid size must be 1024x512, but it shows a 1024x256 rectangle

    Interesting. Actually the particle shader is quite convoluted, and probably not efficient for bare rectangles. That may explain the difference.

    Gideros isn't limited in number of triangles it can draw in a frame, but it is limited in number of indices it can send to the GPU in a single draw call. I thought it was 64k indices, but 512k triangles would already exceed this. Interesting issue...
  • "glGet with argument GL_MAX_ELEMENTS_VERTICES
    glGet with argument GL_MAX_ELEMENTS_INDICES"

    https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDrawRangeElements.xhtml
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • MoKaLuxMoKaLux Member
    edited June 2021
    :o latest imgui doesn't work for me on android and html5 :'( what could be the problem please?
    On both html5 and android I have got the same error message:
    Uploading finished.
    bad argument #3 to '?' (number expected, got string)
    stack traceback:
    	scenes/levelX.lua:65: in function
    line 46 is: self.imgui:render() !
    line 65 is: onEnterFrame() !

    Not very helpful!? so I disabled all imgui buttons, text, ... one by one to see if I can catch it but no result, always the same error even with no imgui UI only imgui render :'(

    Any help would be nice please :)

    PS: player and win export work fine

    PS2: I think I found the problem, ImGui.dll was updated (built) for windows only. Now we need to build the updated ImGui for the other platforms (html5, android, ios?, ...). I am trying to set my system up see if I can build those and hopefully make awesome ImGui work on ALL platforms :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited June 2021

    @rrraptor I think there is an error with the html5 export.

    Sometimes when I call imgui:render() I get an error:
    bad argument #3 to '?' (number expected, got string)

    This doesn't happen on the Windows player.

    What happens just before though is interesting, maybe it happens on Windows too, but not enough to crash it?



    This is the test app: https://web.reportcomplete.com/

    Here is a link to the unencrypted GApp so you can try it out:
    https://web.reportcomplete.com/ReportComplete.GApp.gidz

    If you export a project to HTML5, then replace the GApp.gidz file with that one, you should be able to test any HTML5 code modifications to your plugin.

    (I'm using the test build of Gideros, so I have your latest version submitted to github)

    I am hitting the same wall (see previous post) :*
    SinisterSoft I think the problem is we didn't build the new ImGui for html5, nor android, ios, ... Do you think you can build those? I am stuck with installing python and emsdk :/ That should solve the issue?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • up :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hgy29hgy29 Maintainer
    I always build all parts of Gideros with the same source code, and it seems that the one in Gideros repository is more recent than the one managed by @rrraptor, so I guess Gideros is actually up to date. Unless some changes weren't commited.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    I think the error is with the lua stack and one of the imgui calls. Something is managing to crash Gideros when you use imgui and html5.

    Likes: MoKaLux

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited June 2021
    @rrraptor , the above issue with Android would be nice to resolve.

    on the other hand finally i started to rework the gui of my app in imgui. when i had separate test project it only had the imgui menu. but now trying to put the whole thing into my app i need to stop mouse (or keyboard) event propagation whenever the mouse click/move/hover etc. is inside an imgui window, but should not stop propagation when i click etc. outside windows. how can i do this? thanks

    EDIT: this mouse event capture i could resolve by using IO:wantCaptureMouse() to check if imgui 'has' the mouse.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • i also don't understand how i can set the size of the visible area (outside which things are cropped), similarly the width of mainmenubar (the two questions probably have the same solution).
  • SinisterSoftSinisterSoft Maintainer
    edited June 2021
    I have code now that crashes (only on html5. Others such as android, etc seem ok) - within :render() - every time... :(

    https://web.reportcomplete.com
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • MoKaLuxMoKaLux Member
    edited June 2021
    @SinisterSoft could you post a minimum sample that works on android please?
    I tried a couple of things but was not able to use imgui on my old android samsung S5 (maybe that's the problem :D ). Hope we will get imgui working on all platforms <3 .
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • SinisterSoftSinisterSoft Maintainer
    pm'ed you...

    Likes: MoKaLux

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited June 2021
    I think It's important that we get imgui html5 fixed - as pwa is also now working ( https://forum.gideros.rocks/discussion/comment/64963#Comment_64963 ), it means that possibly (in the future) an editor, recoded in Gideros using imgui, could be used to code on any platform.

    Likes: keszegh

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited June 2021
    I agree and I am willing to help fund imgui html5 integration <3
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+2 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    Is there an example of a modal (popup window) for Gideros using imgui?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    My app that uses imgui is starting to shape up... :)





    Likes: keszegh, MoKaLux

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+2 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited June 2021
    i'm also finally working on redoing my animation app's gui with imgui and it is going well. but then i will depend on it so it would be great to have a perfectly working imgui plugin.
    +1 -1 (+2 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    I think there is an issue with textWrapped(...


    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • MoKaLuxMoKaLux Member
    edited June 2021
    DELETED useless comment :D

    The problem here seems to be with your \r\r thing:

    -'\n' = Linux
    -'\r\n' = Windows
    -'\r' = Mac

    Without those \r TextWrapped works fine :)

    Likes: SinisterSoft

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited June 2021
    Each frame I call this:
    	local temp=(application:getTextureMemoryUsage()/1024)
    	if temp~=oldUsage then
    		oldUsage=temp
    		print("Texture usage: "..temp.."MB")
    	end
    When I use imgui in combination with sceneManager there appears to be a texture memory leek, in my case about 2MB each time a new imgui is created and destroyed.

    Any ideas?

    Update:

    It looks like it's the fonts. Maybe the font texture space is not freed somehow?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • MoKaLuxMoKaLux Member
    edited June 2021
    I use font like this in scenemanager, didn't check memory leaks though:
    LevelX = Core.class(Sprite)
     
    function LevelX:init()
    	-- bg color
    	application:setBackgroundColor(0x6085A6)
    	-- app title
    	self.mytitle = ButtonMonster.new({
    		text="TEXT LINE REMOVER", ttf=font00, textcolorup=0xF2B66D,
    	})
    	self.mytitle:setPosition(1.7*myappwidth/2, 0.35*myappheight/10)
    	self:addChild(self.mytitle)
    	-- dear imgui
    	self.imgui = ImGui.new()
    	local imguiio = self.imgui:getIO()
    	local fontatlas = imguiio:getFonts()
    	local myfont = fontatlas:addFont("fonts/Cabin-Regular-TTF.ttf", 16*2)
    	imguiio:setFontDefault(myfont)
    	fontatlas:build()
    	self:addChild(self.imgui)
    	-- app ui
    	self.window01 = true
    	self.doctext = "please paste your original text here"
    	self.erasefromto = ""
    	-- flags
    	self.flags = ImGui.WindowFlags_NoDecoration | ImGui.WindowFlags_NoMove
    		| ImGui.WindowFlags_NoResize | ImGui.WindowFlags_NoSavedSettings
    	-- scene listeners
    	self:addEventListener("enterBegin", self.onTransitionInBegin, self)
    	self:addEventListener("enterEnd", self.onTransitionInEnd, self)
    	self:addEventListener("exitBegin", self.onTransitionOutBegin, self)
    	self:addEventListener("exitEnd", self.onTransitionOutEnd, self)
    end
     
    -- game loop
    function LevelX:onEnterFrame(e)
    	self.imgui:newFrame(e)
    	self.imgui:setNextWindowPos(8, 32*1.5)
    	self.window01 = self.imgui:beginWindow("W01", nil, self.flags) -- nil = no close button
    	if self.window01 then
    		local ischanged = false
    		-- display original document text
    		if self.imgui:button("PASTE YOUR TEXT FROM THE CLIPBOARD") then
    			self.doctext = application:getClipboard()
    			self:createOriginalTextTable()
    		end
    		self.doctext, ischanged = self.imgui:inputTextMultiline("### 1", self.doctext, 8*1024, myappwidth-8*4, 1.5*myappheight/2)
    		if ischanged then self:createOriginalTextTable() end
    		-- then action erase lines in table from wild card to wild card
    		self.erasefromto = self.imgui:inputTextWithHint("### 2", self.erasefromto, "erase lines (from to)", 2*1024)
    		self.imgui:sameLine() if self.imgui:button("REMOVE LINES") then self:createFinalTextTable() end
    		self.imgui:sameLine() if self.imgui:button("COPY NEW TEXT") then application:setClipboard(self.doctext) end
    	end
    	self.imgui:endFrame()
    	self.imgui:render()
    end
     
    -- functions
    function LevelX:createOriginalTextTable()
    	-- ...
    end
     
    function LevelX:createFinalTextTable()
    	-- ...
    end
     
    -- EVENT LISTENERS
    function LevelX:onTransitionInBegin() self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self) end
    function LevelX:onTransitionInEnd() self:myKeysPressed() end
    function LevelX:onTransitionOutBegin() self:removeEventListener(Event.ENTER_FRAME, self.onEnterFrame, self) end
    function LevelX:onTransitionOutEnd() end
     
    -- KEYS HANDLER
    function LevelX:myKeysPressed()
    	-- ...
    end
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.