Skip to content

Commit

Permalink
Asset management fixes and various package tinkering
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Jan 2, 2017
1 parent 0164b1a commit d5d3948
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
5 changes: 2 additions & 3 deletions cl-bodge.asd
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@
:author "Pavel Korolev"
:mailto "dev@borodust.org"
:license "MIT"
:depends-on (cl-bodge/engine cl-bodge/utils cl-bodge/graphics cl-bodge/assets log4cl
cl-bodge/assets)
:depends-on (cl-bodge/engine cl-bodge/utils cl-bodge/graphics cl-bodge/assets log4cl)
:pathname "text"
:serial t
:components ((:file "packages")
Expand Down Expand Up @@ -260,7 +259,7 @@
:license "MIT"
:depends-on (cl-bodge/engine cl-bodge/utils cl-bodge/assets cl-bodge/graphics
cl-bodge/animation cl-bodge/scenegraph flexi-streams log4cl
cl-fad bodge-sndfile opticl)
cl-bodge/text cl-fad bodge-sndfile opticl)
:pathname "resources"
:serial t
:components ((:file "packages")
Expand Down
1 change: 1 addition & 0 deletions graphics/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@

define-shader-library
define-shading-program
find-program-descriptor
load-shading-program
build-shading-program))
3 changes: 2 additions & 1 deletion poiu/text-renderer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
(define-system-function make-text-renderer graphics-system
(width height font line-height &key (color (vec4 0.0 0.0 0.0 1.0)))
(make-instance 'text-renderer
:shading-program (load-shading-program 'text-shading)
:shading-program (load-shading-program
(find-program-descriptor 'text-shading))
:font font
:width width
:height height
Expand Down
23 changes: 22 additions & 1 deletion resources/converters.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:scale (sequence->vec3 scale))))))))))


(define-system-function chunk->mesh graphics-system (mesh-chunk)
(define-system-function chunk->mesh ge.gx:graphics-system (mesh-chunk)
(let* ((arrays (mesh-chunk-arrays mesh-chunk))
(v-count (length (cadar arrays)))
(chunk-bones (mesh-chunk-bones mesh-chunk))
Expand Down Expand Up @@ -49,3 +49,24 @@
node)))
(unless (null chunk)
(%traverse chunk))))


(defun chunk->image (chunk)
(make-instance 'image
:width (image-chunk-width chunk)
:height (image-chunk-height chunk)
:pixel-format (image-chunk-pixel-format chunk)
:data (image-chunk-data chunk)))


(define-system-function chunk->font ge.gx:graphics-system (font-chunk atlas-image)
(let ((glyphs (loop for g in (font-atlas-chunk-children font-chunk)
collect (ge.txt:make-glyph (code-char (glyph-metrics-character g))
(glyph-metrics-origin g)
(glyph-metrics-bounding-box g)
(glyph-metrics-advance-width g)
(glyph-metrics-kernings g)))))
(ge.txt:make-font atlas-image glyphs
(font-atlas-chunk-ascender font-chunk)
(- (font-atlas-chunk-descender font-chunk))
(font-atlas-chunk-line-gap font-chunk))))
6 changes: 4 additions & 2 deletions resources/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

(defpackage :cl-bodge.resources
(:nicknames :ge.rsc)
(:use :cl :cl-bodge.utils :cl-bodge.engine)
(:use :cl :cl-bodge.utils :cl-bodge.engine :cl-bodge.assets)
(:export load-resource
find-chunk

Expand Down Expand Up @@ -48,4 +48,6 @@

chunk->animation
chunk->skeleton
chunk->mesh))
chunk->mesh
chunk->image
chunk->font))
32 changes: 18 additions & 14 deletions text/font.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,24 @@
(gethash character glyph-table)))


(define-system-function font-atlas-chunk->font graphics-system (font-chunk atlas-image)
(let ((glyphs (loop for g in (font-atlas-chunk-children font-chunk)
collect (make-instance 'glyph
:character (glyph-metrics-character g)
:origin (glyph-metrics-origin g)
:bounding-box (glyph-metrics-bounding-box g)
:advance-width (glyph-metrics-advance-width g)
:kernings (glyph-metrics-kernings g)))))
(make-instance 'font
:glyphs glyphs
:atlas (make-2d-texture atlas-image :grey :generate-mipmaps-p nil)
:ascender-height (font-atlas-chunk-ascender font-chunk)
:descender-height (- (font-atlas-chunk-descender font-chunk))
:line-gap (font-atlas-chunk-line-gap font-chunk))))
(defun make-glyph (character origin bounding-box advance-width kernings)
(make-instance 'glyph
:character character
:origin origin
:bounding-box bounding-box
:advance-width advance-width
:kernings kernings))


(define-system-function make-font graphics-system (atlas-image glyphs ascender-height
descender-height
line-gap)
(make-instance 'font
:glyphs glyphs
:atlas (make-2d-texture atlas-image :grey :generate-mipmaps-p nil)
:ascender-height ascender-height
:descender-height descender-height
:line-gap line-gap))


(defun measure-string (string font)
Expand Down
3 changes: 2 additions & 1 deletion text/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
(defpackage :cl-bodge.text
(:nicknames :ge.txt)
(:use :cl :cl-bodge.utils :cl-bodge.engine :cl-bodge.graphics :cl-bodge.assets)
(:export font-atlas-chunk->font
(:export make-glyph
make-font
font-ascender-height
font-descender-height
font-line-gap
Expand Down

0 comments on commit d5d3948

Please sign in to comment.