imgui
imgui copied to clipboard
Fixed `UncheckedArray`
Edited imgui.nim:
ImVector.data: UncheckedArray[T]->ptr UncheckedArray[T]ImDrawList.cmdLists: UncheckedArray[ptr ImDrawList]->ptr UncheckedArray[ptr ImDrawList]
Usage Example
import nimgl/imgui, nimgl/imgui/[impl_opengl, impl_glfw]
import nimgl/[opengl, glfw]
proc main() =
doAssert glfwInit()
glfwWindowHint(GLFWContextVersionMajor, 3)
glfwWindowHint(GLFWContextVersionMinor, 3)
glfwWindowHint(GLFWOpenglForwardCompat, GLFW_TRUE)
glfwWindowHint(GLFWOpenglProfile, GLFW_OPENGL_CORE_PROFILE)
glfwWindowHint(GLFWResizable, GLFW_FALSE)
var w: GLFWWindow = glfwCreateWindow(1280, 720)
if w == nil:
quit(-1)
w.makeContextCurrent()
doAssert glInit()
let context = igCreateContext()
#let io = igGetIO()
doAssert igGlfwInitForOpenGL(w, true)
doAssert igOpenGL3Init()
igStyleColorsCherry()
while not w.windowShouldClose:
glfwPollEvents()
igOpenGL3NewFrame()
igGlfwNewFrame()
igNewFrame()
# Simple window
igBegin("Hello, world!")
var filter: ImGuiTextFilter # Before it complained Error: invalid type: 'UncheckedArray[ImGuiTextRange]' in this context: 'ImGuiTextFilter' for var
filter.addr.draw()
for line in ["aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world"]:
if filter.addr.passFilter(line):
igBulletText("%s", line)
igEnd()
# End simple window
igRender()
glClearColor(0.45f, 0.55f, 0.60f, 1.00f)
glClear(GL_COLOR_BUFFER_BIT)
igOpenGL3RenderDrawData(igGetDrawData())
w.swapBuffers()
igOpenGL3Shutdown()
igGlfwShutdown()
context.igDestroyContext()
w.destroyWindow()
glfwTerminate()
main()