Add a priority parameter to defmodule
This commit is contained in:
parent
4985c8a179
commit
326fe654c2
4 changed files with 37 additions and 36 deletions
|
|
@ -150,7 +150,7 @@
|
|||
t)))
|
||||
*thread-list*)))
|
||||
|
||||
(defmodule stoe/core/jobs)
|
||||
(defmodule stoe/core/jobs :jobs)
|
||||
|
||||
(defgeneric get-next-job (thread))
|
||||
(defmethod get-next-job ((thread base-thread)))
|
||||
|
|
|
|||
|
|
@ -8,45 +8,46 @@
|
|||
(:export #:initialize-modules #:finalize-modules #:update-modules #:defmodule))
|
||||
(in-package :stoe/core/modules)
|
||||
|
||||
(defparameter *initialize-hook* nil
|
||||
"Hook run on initialization.
|
||||
Functions attached to this hook should expect an optional argument containing
|
||||
the program argv.")
|
||||
(defparameter *modules-list* nil)
|
||||
|
||||
(defparameter *finalize-hook* nil
|
||||
"Hook run on finalization.")
|
||||
|
||||
(defparameter *update-hook* nil
|
||||
"Hook run each frame.
|
||||
Functions attached to this hook should expect an argument containing the time
|
||||
since last frame.")
|
||||
|
||||
(defmacro initialize-modules (&optional argv)
|
||||
(defun initialize-modules (&optional argv)
|
||||
"Perform the engine and subsystems initialization process."
|
||||
`(progn
|
||||
(format t "Initialize...~%")
|
||||
,@(loop for fun in *initialize-hook*
|
||||
collect (list fun argv))))
|
||||
(format t "Initialize...~%")
|
||||
(loop for module in *modules-list*
|
||||
do (funcall (intern "INITIALIZE" (cdr module)) argv)))
|
||||
|
||||
(defmacro finalize-modules ()
|
||||
"Perform the engine and subsystems finalization process."
|
||||
`(progn
|
||||
(format t "Finalize...~%")
|
||||
,@(loop for fun in *finalize-hook*
|
||||
collect (list fun))))
|
||||
(defun finalize-modules ()
|
||||
"Perform the engine and subsystems initialization process."
|
||||
(format t "Initialize...~%")
|
||||
(loop for module in (reverse *modules-list*)
|
||||
do (funcall (intern "FINALIZE" (cdr module)))))
|
||||
|
||||
(defmacro update-modules (delta-time)
|
||||
"Update the modules each loop."
|
||||
`(progn
|
||||
,@(loop for fun in *update-hook*
|
||||
collect (list fun delta-time))))
|
||||
(defun update-modules (delta-time)
|
||||
"Update-the modules each loop."
|
||||
(loop for module in *modules-list*
|
||||
do (funcall (intern "UPDATE" (cdr module)) delta-time)))
|
||||
|
||||
(defmacro defmodule (module)
|
||||
(defun register-module (module priority)
|
||||
(pushnew (cons priority module) *modules-list*)
|
||||
(sort *modules-list* (lambda (prio1 prio2)
|
||||
(< prio1 prio2)) :key #'car))
|
||||
|
||||
(defmacro defmodule (module priority)
|
||||
"Register a new module.
|
||||
The module is expected to have at least `initialize', `update', and `finalize' functions.
|
||||
`initialize' accepts an optional `argv' argument,
|
||||
`update' accepts a delta-time argument."
|
||||
`(progn
|
||||
(setf *initialize-hook* (append *initialize-hook* (list (intern "INITIALIZE" ',module))))
|
||||
(push (intern "FINALIZE" ',module) *finalize-hook*)
|
||||
(setf *update-hook* (append *update-hook* (list (intern "UPDATE" ',module))))))
|
||||
`(register-module ',module
|
||||
,(ecase priority
|
||||
(:first (if (null *modules-list*)
|
||||
0
|
||||
(1- (caar *modules-list*))))
|
||||
(:last (if (null *modules-list*)
|
||||
10
|
||||
(1+ (caar (reverse *modules-list*)))))
|
||||
(:jobs 1)
|
||||
(:resources 2)
|
||||
(:input 3)
|
||||
(:game 4)
|
||||
(:render 9)
|
||||
(t priority))))
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
(defun update (delta-time)
|
||||
(declare (ignore delta-time)))
|
||||
|
||||
(defmodule stoe/core/resources)
|
||||
(defmodule stoe/core/resources :resources)
|
||||
|
||||
(defun register-resource (res)
|
||||
(assert (null (gethash (res-path res) *resources-db*)))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Destroy the opengl context and the related resources."
|
|||
(defun update (delta-time)
|
||||
(declare (ignore delta-time)))
|
||||
|
||||
(defmodule stoe/engine/render)
|
||||
(defmodule stoe/engine/render :render)
|
||||
|
||||
(defun render-single-mesh (mesh transform)
|
||||
(using-program (program 'blue-shader)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue