Startup and proc issues
Hi, I updated your library to the latest version and I have 3 issues.
- igPushFont() now requires a font size, is there a proc that still lets me use the old behavior?
- io.Fonts.ImFontAtlas_Build() doesn't exist anymore. It is used in this piece of code :
let io = igGetIO()
io.Fonts.ImFontAtlas_ClearFonts()
var config = new_ImFontConfig()
config.SizePixels = 16
#io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(pc98Font[0].addr, pc98Font.len, 16, config.addr, cast[ptr ImWchar](addr glyphRangesJapanese))
io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(pc98Font[0].addr, pc98Font.len, 16, config.addr, nil)
const ranges_icon_fonts = [ICON_MIN_FA.uint32, ICON_MAX_FA.uint32, 0]
const range_audio = [ICON_MIN_FAD.uint32, ICON_MAX_FAD.uint32, 0]
const range_audio2 = [0xF800.uint32, 0xF8FF, 0]
config.MergeMode = true
var fontAwesome = io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(fontAwesomeData[0].addr, fontAwesomeData.len.int32, 16, config.addr, cast[ptr ImWchar](ranges_icon_fonts[0].addr))
fonts[0] = fontAwesome
config.MergeMode = false
io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(pc98Font[0].addr, pc98Font.len, 16, config.addr, nil)
config.MergeMode = true
config.GlyphOffset.y += 5.0
var fontAudio = io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(fontAudioData[0].addr, fontAudioData.len.int32, 20, config.addr, cast[ptr ImWchar] (range_audio[0].addr))
fonts[1] = fontAudio
config.MergeMode = false
config.GlyphOffset.y = 0.0
var fontAwesomeAlone = io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(fontAwesomeData[0].addr, fontAwesomeData.len.int32, 16, config.addr, cast[ptr ImWchar] (ranges_icon_fonts[0].addr))
fonts[2] = fontAwesomeAlone
#io.Fonts.ImFontAtlas_Build()
config.MergeMode = false
io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(pc98Font[0].addr, pc98Font.len, 16, config.addr, nil)
config.MergeMode = true
var ran = [0x1F300.ImWchar32, 0x1FFFF.ImWchar32, 0]
var fontEmoji = io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(fontEmojiColorData[0].addr, fontEmojiColorData.len.int32, 16, config.addr, cast[ptr ImWchar](ran[0].addr))
fonts[3] = fontEmoji
#io.Fonts.ImFontAtlas_Build()
config.MergeMode = false
ran = [0x1.ImWchar32, 0x7E.ImWchar32, 0]
var fontPico8 = io.Fonts.ImFontAtlas_AddFontFromMemoryTTF(fontPico8Data[0].addr, fontPico8Data.len.int32, 22, config.addr, cast[ptr ImWchar](ran[0].addr))
fonts[4] = fontPico8
io.Fonts.ImFontAtlas_Build()
- I now have this error when starting the program up. I removed all occurences of io.Fonts.ImFontAtlas_Build() and added font size to igPushFont() to compile the program.
Here is my build script if this can help you :
switch "hint","Name:off"
switch "hint","XDeclaredButNotUsed:off"
#switch "app","gui" # dismiss background Window
when defined(windows):
switch "define", "release"
#switch "define", "danger"
#switch "opt", "size"
discard
else: # Linux
switch "define", "release"
discard
#const LTO = true # further reudce code size
const LTO = false
switch "app","gui" # dismiss background Window
#---------------------------------------
# Select static link or shared/dll link
#---------------------------------------
when defined(windows):
const STATIC_LINK_GLFW = false
const STATIC_LINK_CC = true #libstd++ or libc
switch "passL","-lgdi32 -limm32 -lcomdlg32 -luser32 -lshell32"
else: # for Linux
const STATIC_LINK_GLFW = true
const STATIC_LINK_CC= false
#
when STATIC_LINK_GLFW: # GLFW static link
switch "define","glfwStaticLib"
else: # shared/dll
when defined(windows):
switch "passL","-LC:\\glfw\\lib-mingw-w64"
switch "passL","-lglfw3"
switch "define", "glfwDLL"
#switch "define","cimguiDLL"
else:
switch "passL","-lglfw"
when STATIC_LINK_CC: # gcc static link
switch "passC", "-static"
switch "passL", "-static "
# Reduce code size further
when false:
switch "gc", "arc"
switch "define", "useMalloc"
switch "define", "noSignalHandler"
#switch "panics","on"
#switch "verbosity","1"
proc commonOpt() = # for gcc and clang
# switch "passL", "-s" # remov debug info from elf file
switch "passC", "-ffunction-sections"
switch "passC", "-fdata-sections"
switch "passL", "-Wl,--gc-sections"
#const NIMCACHE = ".nimcache_" & TC
switch "nimcache", ".nimcache"
commonOpt()
switch "cc","gcc"
when LTO: # These options let link time slow while reducing code size.
switch "define", "lto"
switch("d", "ImNodesEnable")
switch("d", "ImKnobsEnable")
switch("d", "ImGuiToggleEnable")
switch("d", "ImPlotEnable")
switch("d", "ImPlotEnable")
switch("d", "ImGuiFileDialogEnable")
switch("d", "ImColorTextEdit")
switch("d", "useLuajit")
switch("passC", "-DIMGUI_USE_WCHAR32")
switch("warning", "UnusedImport:off")
switch("warning", "CStringConv:off")
when defined(opt1):
switch("d", "release")
switch("opt", "speed")
when defined(opt2):
switch("d", "danger")
switch("opt", "speed")
--passC:"-o3 -ofast -fopt-info-vec-optimized -mavx -ffast-math -flto -fdevirtualize-at-ltrans -ftree-loop-vectorize -ftree-slp-vectorize"
when defined(fastComp):
#switch("cc", "tcc")
--gcc.exe:"tcc"
--gcc.linkerexe:"tcc"
--gcc.cpp.exe:"tcc"
--gcc.cpp.linkerexe:"tcc"
switch("tlsEmulation", "on")
switch("define", "useMalloc")
#--mm:refc
--passl:"-ldl -lm"
--threads:"on"
--stackTrace:on
--lineTrace:on
--parallelBuild:0
--incremental:on
--exceptions:goto
switch("passL", "-Llibs")
when defined(windows):
switch("passL", "-lluajit-windows")
else:
switch("passL", "-lluajit-linux")
#switch("passL", "-llua53")
when defined(windows):
# exec "x86_64-w64-mingw32-windres kurumi-xp.rc -O coff -o kurumi-xp.res"
--passL:"kurumi-xp.res"
--passL:"-lstdc++"
--gcc.exe:"x86_64-w64-mingw32-gcc"
--gcc.linkerexe:"x86_64-w64-mingw32-gcc"
--gcc.cpp.exe:"x86_64-w64-mingw32-g++"
--gcc.cpp.linkerexe:"x86_64-w64-mingw32-g++"
# --out: "kurumi_xp.exe"
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config
Are those issues normal? Thanks for your answer!
Hi, @system64MC
- The function
igPushFont()that has only one argument has been removed at CImGui 1.92.3 ( == latest imguin 1.92.3.0), that is caused by CImGui generator specifying "-D IMGUI_DISABLE_OBSOLETE_FUNCTIONS" in generator.lua.
So if you're going to keep track of the latest imguin, you should change your code according to this description. - About
io.Fonts.ImFontAtlas_Build(), see fonts-loading-instructions. - Comment out some settings in your build script for debug purpose
You would be able to see more error messages in background console.-
Comment out another
switch "app","gui" # dismiss background Window"line,#const LTO = true # further reudce code size const LTO = false #switch "app","gui" # dismiss background Window <<==== this line #--------------------------------------- # Select static link or shared/dll link #--------------------------------------- -
Comment out all optimization options,
#switch "define", "release" #switch "define", "danger" #switch("d", "release") #switch("opt", "speed") #switch("d", "danger")
-
Hi, I will try the proc changes, I try to fix the startup crash first. I have the exact same error with your samples. I tried to remove the first switch as you said, I have those undefined references :
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x11f): undefined reference to `__imp_CreateDCW'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x15e): undefined reference to `__imp_GetDeviceCaps'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x1b4): undefined reference to `__imp_DeleteDC'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x30b): undefined reference to `__imp_GetDeviceCaps'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x95b): undefined reference to `__imp_GetDeviceCaps'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0xaeb): undefined reference to `__imp_GetDeviceCaps'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0xf38): undefined reference to `__imp_CreateDCW'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0xf47): undefined reference to `__imp_GetDeviceGammaRamp'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0xf50): undefined reference to `__imp_DeleteDC'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x1042): undefined reference to `__imp_CreateDCW'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x1051): undefined reference to `__imp_SetDeviceGammaRamp'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_monitor.c.obj):win32_monitor.:(.text+0x105a): undefined reference to `__imp_DeleteDC'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x146): undefined reference to `__imp_CreateDIBSection'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x17d): undefined reference to `__imp_CreateBitmap'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x220): undefined reference to `__imp_DeleteObject'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x2bd): undefined reference to `__imp_DeleteObject'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x35b): undefined reference to `__imp_CreateRectRgn'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(win32_window.c.obj):win32_window.c:(.text+0x396): undefined reference to `__imp_DeleteObject'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x182): undefined reference to `__imp_SwapBuffers'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x423): undefined reference to `__imp_ChoosePixelFormat'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x431): undefined reference to `__imp_SetPixelFormat'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0xb59): undefined reference to `__imp_DescribePixelFormat'
c:/nim-2.2.4/dist/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/glfw/lib-mingw-w64\libglfw3.a(wgl_context.c.obj):wgl_context.c:(.text+0x127a): undefined reference to `__imp_SetPixelFormat'
Add to build script,
switch "passL","-lopengl32 -lgdi32"
Add to build script,
switch "passL","-lopengl32 -lgdi32"
I still have the same linking error
I still have the same linking error
Could you show simplified, minimum all source code and build script ?
or
Add import nimgl/[opengl] to main source code ?