X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=graphics%2Ftext-rendering.lisp;fp=graphics%2Ftext-rendering.lisp;h=146dfa243a76f91e7b4e428e098be46823c619bb;hb=f4f51b6f1f774bc2e93f93d47d3471a6c6a49767;hp=6d03125cb410367186f0c2d8a2492d877b0c10bd;hpb=0a63af2cc1f946ff65ccea1168b2933ba1e8a24c;p=rulp%2Frulp.git diff --git a/graphics/text-rendering.lisp b/graphics/text-rendering.lisp index 6d03125..146dfa2 100644 --- a/graphics/text-rendering.lisp +++ b/graphics/text-rendering.lisp @@ -14,7 +14,13 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with this program. If not, see . -(in-package :graphics) +(in-package :rulp.graphics) + +(defparameter *tr-s-rectangle* (sdl2:make-rect 0 0 60 130)) ; FIXME: hardcoded, + ; defparameter over + ; font for + ; generalization +(defparameter *tr-d-rectangle* (sdl2:make-rect 0 0 10 10)) (defun coordinate-to-grid-index (value) "translate a coordinate into the chess coordinate as a string" @@ -32,10 +38,11 @@ `(let ((value-indexes (tr-parse-string ,value))) (loop :for character :in value-indexes :for character-position :from 0 :to (length value-indexes) - :do (let ((source-rectangle (sdl2:make-rect (* character 60) 0 60 130)) - (destination-rectangle (sdl2:make-rect (+ ,x (* character-position ,width)) ,y ,width ,height))) - (sdl2:render-copy ,renderer *tr-texture* - :source-rect source-rectangle - :dest-rect destination-rectangle) - (sdl2:free-rect source-rectangle) - (sdl2:free-rect destination-rectangle))))) + :do (setf (sdl2:rect-x *tr-s-rectangle*) (* character 60) + (sdl2:rect-x *tr-d-rectangle*) (+ ,x (* character-position ,width)) + (sdl2:rect-y *tr-d-rectangle*) ,y + (sdl2:rect-width *tr-d-rectangle*) ,width + (sdl2:rect-height *tr-d-rectangle*) ,height) + (sdl2:render-copy ,renderer *tr-texture* + :source-rect *tr-s-rectangle* + :dest-rect *tr-d-rectangle*))))