Skip to content

Instantly share code, notes, and snippets.

@metacritical
Last active July 30, 2019 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metacritical/1b46cb1e7e83d4434999ba855c51ce83 to your computer and use it in GitHub Desktop.
Save metacritical/1b46cb1e7e83d4434999ba855c51ce83 to your computer and use it in GitHub Desktop.
Inherit GameWindow using proxy and Override OnUpdateFrame method.
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(import [System]
[System.IO]
[System.Console]
[System.Drawing]
[OpenTK]
[OpenTK.Graphics.ES30 ClearBufferMask]
[OpenTK.Graphics.OpenGL GL]
[OpenTK.Input Keyboard Key]
[clojure.lang])
(defn on-update-frame [event]
(let [input (Keyboard/GetState)]
(if (.IsKeyDown input Key/Escape)
(Console/WriteLine "Escape Pressed!"))))
(defn new-window [width height]
(proxy [OpenTK.GameWindow] [width height nil "Mono Chromium BSU"]
(OnUpdateFrame [event]
(on-update-frame event))))
(defn -main []
(Console/WriteLine "Starting OpenTK Window.")
(let [window (new-window 800 600)]
(GL/ClearColor Color/CornflowerBlue)
(GL/Clear ClearBufferMask/ColorBufferBit)
(.SwapBuffers window)
(.Run window 30.0)))
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(import [System]
[System.IO]
[System.Console]
[System.Drawing]
[OpenTK]
[OpenTK.Graphics.ES30 ClearBufferMask]
[OpenTK.Graphics.OpenGL GL]
[OpenTK.Input Keyboard Key]
[clojure.lang])
(defn on-update-frame [this event]
(let [input (Keyboard/GetState)]
(if (.IsKeyDown input Key/Escape)
(.Exit this))))
(defn new-window [width height]
(proxy [OpenTK.GameWindow] [width height nil "Mono Chromium BSU"]
(OnUpdateFrame [event]
(on-update-frame this event))))
(defn -main []
(Console/WriteLine "Starting OpenTK Window.")
(let [window (new-window 800 600)]
(GL/ClearColor Color/CornflowerBlue)
(GL/Clear ClearBufferMask/ColorBufferBit)
(.SwapBuffers window)
(.Run window 30.0)))
(ns core
(:gen-class))
(assembly-load-from "./extern/OpenTK/lib/net20/OpenTK.dll")
(import [System]
[System.IO]
[System.Console]
[System.Drawing]
[OpenTK]
[OpenTK.Graphics.ES30 ClearBufferMask]
[OpenTK.Graphics.OpenGL GL]
[clojure.lang])
(defn new-window [width height]
(proxy [OpenTK.GameWindow] [width height nil "Mono Chromium BSU"]
(OnUpdateFrame [event]
(Console/WriteLine event))))
(defn -main []
(Console/WriteLine "Starting OpenTK Window.")
(let [window (new-window 800 600)]
(GL/ClearColor Color/CornflowerBlue)
(GL/Clear ClearBufferMask/ColorBufferBit)
(.SwapBuffers window)
(.Run window 30.0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment