Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Sep 17, 2016
0 parents commit 26671bd
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# lisp junk
*.FASL
*.fasl
*.lisp-temp

# emacs junk
\#*
*~
.\#*

# system dependent junk
local/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Pavel Korolev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# cl-bodge
Bodacious 3D game engine that is no good. Yet.

Use [CLinch](https://github.com/BradWBeer/CLinch) instead.
55 changes: 55 additions & 0 deletions bootstrap.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(in-package :cl-bodge.bootstrap)

(defvar *engine* nil)

(defun %render-to (window)
(glfw:make-context-current window)
(loop until (glfw:window-should-close-p window) do
(sleep 0.01)
(glfw:swap-buffers))
(log:info "Rendering thread exiting"))

(defstruct engine
(main-window nil :read-only t))

(defun %free-engine-resources ()
(setf *engine* nil))

(glfw:def-window-close-callback on-window-close (win)
(declare (ignore win))
(%free-engine-resources))

(defun startup ()
(if (not (null *engine*))
(error "Engine already started")
(with-body-in-main-thread ()
(handler-case
(glfw:with-init-window (:title "Rendering output" :width 640 :height 480
:context-version-major 4
:context-version-minor 1
:opengl-profile :opengl-core-profile
:opengl-forward-compat t
:samples 4)
(log:info "~%GL version: ~a~%GLSL version: ~a~%GL vendor: ~a~%GL renderer: ~a~%"
(gl:get* :version)
(gl:get* :shading-language-version)
(gl:get* :vendor)
(gl:get* :renderer))

(glfw:set-window-close-callback 'on-window-close)

(let* ((win glfw:*window*)
(rendering-thread (bt:make-thread (lambda () (%render-to win))
:name "rendering-thread")))
(setf *engine* (make-engine :main-window win))
(loop until (glfw:window-should-close-p) do
(glfw:wait-events))
(bt:join-thread rendering-thread)
(log:info "Main thread exiting")))
(t (e) (log:error "Unhandled error: ~a" e))))))

(defun shutdown ()
(cond
((null *engine*) (error "Engine is already offline"))
(t (glfw:set-window-should-close (engine-main-window *engine*))
(glfw:post-empty-event))))
17 changes: 17 additions & 0 deletions cl-bodge.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(in-package :cl-user)

(defpackage :cl-bodge.package
(:use :cl :asdf))

(in-package :cl-bodge.package)

(defsystem cl-bodge
:description "Bodacious Game Engine"
:version "0.0.1"
:author "Pavel Korolev"
:mailto "dev@borodust.org"
:license "MIT"
:depends-on (:cl-opengl :cl-glfw3 :log4cl :bordeaux-threads :trivial-main-thread)
:serial t
:components ((:file "packages")
(:file "bootstrap")))
14 changes: 14 additions & 0 deletions packages.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(in-package :cl-bodge.package)


(defpackage :cl-bodge.bootstrap
(:use :cl :trivial-main-thread)
(:export))


(defpackage :cl-bodge
(:use :cl)
(:nicknames :bge)
(:export))


0 comments on commit 26671bd

Please sign in to comment.