Skip to content

Commit

Permalink
Update ImGui to v1.85
Browse files Browse the repository at this point in the history
  • Loading branch information
lmariscal committed Oct 19, 2021
1 parent 6d09e7f commit de9928d
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 92 deletions.
1 change: 1 addition & 0 deletions CHANGE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change `cuchar` to `uint8`, since Nim 1.5 marks it as deprecated
223 changes: 139 additions & 84 deletions src/imgui.nim

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/imgui/impl_glfw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import ../imgui, nimgl/glfw

when defined(windows):
import nimgl/glfw/native

type
GlfwClientApi = enum
igGlfwClientApiUnkown
Expand Down Expand Up @@ -115,8 +118,8 @@ proc igGlfwInit(window: GLFWwindow, installCallbacks: bool, clientApi: GlfwClien
io.setClipboardTextFn = igGlfwSetClipboardText
io.getClipboardTextFn = igGlfwGetClipboardText
io.clipboardUserData = gWindow
# when defined windows:
# io.imeWindowHandle = gWindow.getWin32Window()
when defined windows:
io.imeWindowHandle = gWindow.getWin32Window()

gMouseCursors[ImGuiMouseCursor.Arrow.int32] = glfwCreateStandardCursor(GLFWArrowCursor)
gMouseCursors[ImGuiMouseCursor.TextInput.int32] = glfwCreateStandardCursor(GLFWIbeamCursor)
Expand Down
2 changes: 1 addition & 1 deletion src/imgui/impl_opengl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ proc igOpenGL3CheckShader(handle: uint32, desc: string) =

proc igOpenGL3CreateFontsTexture() =
let io = igGetIO()
var text_pixels: ptr cuchar
var text_pixels: ptr uint8
var text_w: int32
var text_h: int32
io.fonts.getTexDataAsRGBA32(text_pixels.addr, text_w.addr, text_h.addr)
Expand Down
2 changes: 1 addition & 1 deletion tests/tnull.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "CreateContext() - {version}".fmt
igCreateContext(nil)
let io = igGetIO()

var text_pixels: ptr cuchar = nil
var text_pixels: ptr uint8 = nil
var text_w: int32
var text_h: int32
io.fonts.getTexDataAsRGBA32(text_pixels.addr, text_w.addr, text_h.addr, nil)
Expand Down
6 changes: 3 additions & 3 deletions tools/generator.nim
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ proc translateType(name: string): string =
result = result.replace("_Simple", "")
if result.contains("char") and not result.contains("Wchar"):
if result.contains("uchar"):
result = "cuchar"
result = "uint8"
elif depth > 0:
result = result.replace("char", "cstring")
depth.dec
Expand Down Expand Up @@ -313,7 +313,7 @@ proc genProcs(output: var string) =
argDefault.add("{letters[p]}: {argPices[p]}, ".fmt)
argDefault = argDefault[0 ..< argDefault.len - 2] & ")"

if (argType.startsWith("ImGui") or argType.startsWith("Im")) and not argType.contains("Callback"):
if (argType.startsWith("ImGui") or argType.startsWith("Im")) and not argType.contains("Callback") and not argType.contains("ImVec"): # Ugly hack, should fix later
argDefault.add(".{argType}".fmt)

if argName.startsWith("_"):
Expand Down Expand Up @@ -375,7 +375,7 @@ proc genProcs(output: var string) =
if outSplit[1] == outSplit[2] or outSplit[1].split('{')[0] == outSplit[2].split('{')[0]:
output = "{outSplit[0]}\n{outSplit[1]}\n".fmt

output.add("\n{.pop.}\n")
output.add("\n{postProcs}\n".fmt)

proc igGenerate*() =
var output = srcHeader
Expand Down
6 changes: 6 additions & 0 deletions tools/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ const notDefinedStructs* = """

const preProcs* = """
# Procs
{.push warning[HoleEnumConv]: off.}
when not defined(cpp) or defined(cimguiDLL):
{.push dynlib: imgui_dll, cdecl, discardable.}
else:
{.push nodecl, discardable.}
"""

const postProcs* = """
{.pop.} # push dynlib / nodecl, etc...
{.pop.} # push warning[HoleEnumConv]: off
"""

let reservedWordsDictionary* = [
"end", "type", "out", "in", "ptr", "ref"
]
Expand Down

0 comments on commit de9928d

Please sign in to comment.