GameLib is a collection of libraries for creating applications in Cakelisp.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1.3 KiB

(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import "Ogre.cake" "AssetBuilder.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?
(add-c-search-directory-module ".")
(c-import "<stdio.h>")
(defun main (&return int)
;; Ogre uses exceptions for error handling, so we can't gracefully close without getting all that
;; stuff set up (which I don't really want to do; it belongs in Gamelib)
(ogre-initialize)
(var monkey-mesh mesh-handle (ogre-load-mesh "Monkey_Mesh.mesh"))
(var monkey-node scene-node (ogre-node-from-item monkey-mesh))
(ogre-create-light)
(var exit-reason (* (const char)) null)
(var x float 0.f)
(var y float 0.f)
(var z float 0.f)
;; Main loop
(while true
(unless (ogre-handle-window-events)
(set exit-reason "Window closed")
(break))
(ogre-node-set-position (addr monkey-node) x y z)
(set x (+ x 0.01f))
(when (> x 0.3f)
(set exit-reason "Done animation")
(break))
(unless (ogre-render-frame)
(set exit-reason "Failed to render frame")
(break)))
(when exit-reason
(printf "Exit reason: %s\n" exit-reason))
(ogre-shutdown)
(return 0))
;; We need to place the executable relative to our data folders and such
(set-cakelisp-option executable-output "ogreApp")