Last active
July 30, 2019 18:37
-
-
Save metacritical/1b46cb1e7e83d4434999ba855c51ce83 to your computer and use it in GitHub Desktop.
Inherit GameWindow using proxy and Override OnUpdateFrame method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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