Skip to content

Commit

Permalink
Ensure host application started before continuing engine initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Oct 2, 2018
1 parent dcafb3a commit 895740a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
26 changes: 13 additions & 13 deletions graphics/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@

(defmethod enabling-flow ((this graphics-system))
(with-slots (resource-executor) this
(ge.ng:>> (call-next-method)
(for-host ()
(execute resource-executor
(lambda ()
(bind-rendering-context :main nil)
(log:debug "Shared context bound"))
:priority :highest :important-p t)
(framebuffer-size))
(ge.ng:-> this (viewport)
(declare (type vec2 viewport))
(update-context-framebuffer-size (floor (x viewport))
(floor (y viewport)))))))

(ge.ng:>>
(call-next-method)
(for-host ()
(execute resource-executor
(lambda ()
(bind-rendering-context :main nil)
(log:debug "Shared context bound"))
:priority :highest :important-p t)
(framebuffer-size))
(ge.ng:-> this (viewport)
(declare (type vec2 viewport))
(update-context-framebuffer-size (floor (x viewport))
(floor (y viewport)))))))


(defmethod dispatch ((this graphics-system) (task function) invariant &rest args
Expand Down
20 changes: 14 additions & 6 deletions host/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

(define-constant +expected-dpi+ 96)

(defclass host-application (bodge-host:window) ())
(defclass host-application (bodge-host:window)
((init-continuation :initarg :continuation)))

(defclass host-system (enableable dispatching generic-system)
((host-application :initform nil)
Expand Down Expand Up @@ -35,6 +36,11 @@
t)


(defmethod bodge-host:on-init ((this host-application))
(with-slots (init-continuation) this
(funcall init-continuation)))


(defmethod bodge-host:on-hide ((this host-application))
(post 'viewport-hiding-event))

Expand Down Expand Up @@ -67,8 +73,9 @@
(post 'character-input-event :character character))


(defun make-host-application ()
(defun make-host-application (cont)
(make-instance 'host-application
:continuation cont
:opengl-version (property '(:host :opengl-version) '(3 3))
:resizable (property '(:host :viewport-resizable) nil)
:decorated (property '(:host :viewport-decorated) t)
Expand All @@ -78,11 +85,12 @@
(defmethod enabling-flow ((this host-system))
(with-slots (host-application shared) this
(ge.ng:>> (call-next-method)
(instantly ()
(setf host-application (make-host-application)
shared (bodge-host:make-shared-rendering-context host-application))
(ge.ng:%> ()
(setf host-application (make-host-application #'ge.ng:continue-flow))
(bodge-host:open-window (host-application this))
(log:debug "Host system initialized")))))
(log:debug "Host system initialized"))
(instantly ()
(setf shared (bodge-host:make-shared-rendering-context host-application))))))


(defmethod disabling-flow ((this host-system))
Expand Down

0 comments on commit 895740a

Please sign in to comment.