Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds define-start-function #65

Closed
wants to merge 3 commits into from
Closed

Adds define-start-function #65

wants to merge 3 commits into from

Conversation

Gleefre
Copy link
Contributor

@Gleefre Gleefre commented Dec 15, 2022

After thinking about #58 I have come up with define-start-function which can be used like this:

(define-start-function start game (:resizable t :title "Sketchy game"))

Opening & closing other libraries (like sdl2-mixer):

(defmethod setup ((game game) &key &allow-other-keys)
  (sdl2-mixer:init-sound))

(defmethod kit.sdl2:close-window :before ((game game))
  (sdl2-mixer:quit-sound))

Under sbcl it can be saved to executable:

(defun)
(save-lisp-and-die "game.bin" :toplevel #'start :executable t)

Or it can be used with asdf:make (specify in asdf:defsystem).
With deploy:

(asdf:defsystem "game"
  ; system definition
  :defsystem-depends-on (:deploy)
  :build-operation #-darwin "deploy-op" #+darwin "osx-app-deploy-op"
  :build-pathname "game"
  :entry-point "game:start")

Or without:

(asdf:defsystem "game"
  ; system definition
  :build-operation "program-op"
  :build-pathname "game"
  :entry-point "game:start")

And a simple build.lisp script:

(ql:quickload '(:deploy :game))
;; with `deploy`: it ships foreign dependencies, but you should not ship OpenGL
(deploy:define-library cl-opengl-bindings::opengl :dont-deploy t)
(asdf:make :game)
(quit)

I'm not sure that this is a flexible way to define start function: this macro doesn't have a body and naming is not good as well.
Probably make-executable could be added.

Probable macro should be renamed: it shadows kit.sdl2:define-start-function right now.

@Gleefre
Copy link
Contributor Author

Gleefre commented Apr 1, 2023

I have added the possibility to use the function in a live image by passing optional parameter T.
So now (start t) won't assume it is in the deployed environment, it won't run in the sdl's main thread e.t.c.

I can't think of any more improvements, so I'll make the pull request as ready.

@Gleefre Gleefre marked this pull request as ready for review April 1, 2023 14:48
@Gleefre
Copy link
Contributor Author

Gleefre commented Apr 8, 2023

I'll rewrite the define-start-function macro and will open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant