imgui bindings for CHICKEN scheme
Find a file
2026-01-15 17:08:04 -08:00
imgui@5b5d5b049d first commit 2026-01-15 16:12:55 -08:00
.gitignore first commit 2026-01-15 16:12:55 -08:00
.gitmodules first commit 2026-01-15 16:12:55 -08:00
demo.scm first commit 2026-01-15 16:12:55 -08:00
gl.scm first commit 2026-01-15 16:12:55 -08:00
imgui.egg first commit 2026-01-15 16:12:55 -08:00
imgui.scm first commit 2026-01-15 16:12:55 -08:00
README.md updates build instructions 2026-01-15 17:08:04 -08:00
sdl.scm first commit 2026-01-15 16:12:55 -08:00

imgui-egg

Dear ImGui bindings for CHICKEN Scheme with SDL2 + OpenGL2 backend.

Requirements

  • CHICKEN Scheme 5.x
  • SDL2 (brew install sdl2 on macOS)
  • OpenGL (system provided)

Installation

git clone <repo-url>
cd imgui-egg
git submodule update --init
chicken-install .

Usage

(import scheme
        chicken.base
        chicken.bitwise
        sdl
        gl
        imgui)

;; Initialize SDL
(SDL_Init SDL_INIT_VIDEO)

;; Setup OpenGL attributes
(SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1)
(SDL_GL_SetAttribute SDL_GL_DEPTH_SIZE 24)
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MAJOR_VERSION 2)
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 1)

;; Create window and GL context
(define window
  (SDL_CreateWindow "My App"
                    SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED
                    1280 720
                    (bitwise-ior SDL_WINDOW_OPENGL SDL_WINDOW_RESIZABLE)))

(define gl-context (SDL_GL_CreateContext window))
(SDL_GL_MakeCurrent window gl-context)

;; Setup ImGui
(imgui-create-context)
(imgui-setup-io)
(imgui-style-colors-dark)
(imgui-impl-sdl2-init-for-opengl window gl-context)
(imgui-impl-opengl2-init)

;; Main loop
(let loop ()
  (when (= (imgui-poll-and-process-events window) 1)
    ;; New frame
    (imgui-impl-opengl2-new-frame)
    (imgui-impl-sdl2-new-frame)
    (imgui-new-frame)

    ;; Your UI here
    (when (imgui-begin "Hello")
      (imgui-text "Hello from Scheme!")
      (imgui-end))

    ;; Render
    (imgui-render)
    (glClearColor 0.1 0.1 0.1 1.0)
    (glClear GL_COLOR_BUFFER_BIT)
    (imgui-impl-opengl2-render-draw-data)
    (SDL_GL_SwapWindow window)
    (loop)))

;; Cleanup
(imgui-impl-opengl2-shutdown)
(imgui-impl-sdl2-shutdown)
(imgui-destroy-context)
(SDL_GL_DeleteContext gl-context)
(SDL_DestroyWindow window)
(SDL_Quit)

Modules

  • sdl - Basic SDL2 bindings (window, GL context, events)
  • gl - Basic OpenGL bindings (clear, viewport, textures)
  • imgui - Dear ImGui bindings (widgets, windows, draw lists)

Demo

A demo application is included. After installing the egg:

csc -o imgui-demo demo.scm
./imgui-demo

License

BSD-2-Clause. See source files for the full license text.

Dear ImGui is licensed under the MIT License (see imgui/LICENSE.txt).