opengl-text

http://github.com/Ramarren/opengl-text/tree/master

(eval-when (:compile-toplevel :load-toplevel :execute)
  (require :cl-glut)
  (require :opengl-text))

(defvar *font-loader*
  (zpb-ttf:open-font-loader
   #p"/usr/share/fonts/truetype/vlgothic/VL-PGothic-Regular.ttf"))

(defclass string-window (glut:window)
  ((opengl-text :initform (make-instance 'opengl-text:opengl-text
                                         :font *font-loader*
                                         :emsquare 64)))
  (:default-initargs :title "OpenGL Text"
    :mode '(:single :rgb :depth)))

(defmethod glut:keyboard ((window string-window) key x y)
  (declare (ignore x y))
  (case key
    ((#\Esc #\q) (glut:destroy-current-window))))

(defmethod glut:reshape ((window string-window) w h)
  (gl:viewport 0 0 w h)
  (gl:matrix-mode :projection)
  (gl:load-identity)
  (gl:ortho 0 w 0 h -1 1))

(defmethod glut:display-window :before ((w string-window))
  (gl:clear-color 0 0 0 0))              ; 次の clear で使う色

(defmethod glut:display ((window string-window))
  (with-slots (opengl-text) window
    (gl:clear :color-buffer-bit)        ; クリア
    (%gl:color-3f 1 1 1)                ; 描画に使う色
    (gl:enable :texture-2d)
    (gl:enable-client-state :vertex-array)
    (gl:enable-client-state :texture-coord-array)
    (gl:matrix-mode :modelview)
    (gl:load-identity)
    (gl:scale 24 24 1)                  ; 24 x 24 ピクセル
    (gl:translate 0 0 0)                ; デフォルト左下に表示
    (opengl-text:draw-gl-string "まみむめも♪" opengl-text)
    (gl:flush)))

(defun run ()
  (glut:display-window (make-instance 'string-window)))
(run)