From 9f4bd6e30c75f3d39194b96f25484c9cc55045d4 Mon Sep 17 00:00:00 2001 From: John Connors Date: Thu, 14 Aug 2008 23:40:27 +0100 Subject: [PATCH] Minor otimizations and renamings --- glrepl-main.lisp | 29 +++++++++++++++++------------ glrepl-window.lisp | 27 ++++++++++++++------------- glrepl.lisp | 3 ++- package.lisp | 6 +++++- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/glrepl-main.lisp b/glrepl-main.lisp index ea848b3..000673c 100644 --- a/glrepl-main.lisp +++ b/glrepl-main.lisp @@ -27,7 +27,7 @@ (format nil "~a" e)))))) eval-result)) -(cffi:defcallback char-callback :void ((key :int) (action :int)) +(cffi:defcallback console-char-callback :void ((key :int) (action :int)) ;; (format t "Char ~A " key) (when (and *console* (= action glfw:+press+)) (let ((c (code-char key))) @@ -35,7 +35,7 @@ (add-char *glwindow* (code-char key)))))) -(cffi:defcallback key-callback :void ((key :int) (action :int)) +(cffi:defcallback console-key-callback :void ((key :int) (action :int)) ;; (format t "Keypress ~A " key) (when (= action glfw:+press+) ;; f10 toggles console @@ -97,8 +97,8 @@ (defun callback-set () (setf *esc-pressed* nil) - (glfw:set-key-callback (cffi:callback key-callback)) - (glfw:set-char-callback (cffi:callback char-callback))) + (glfw:set-key-callback (cffi:callback console-key-callback)) + (glfw:set-char-callback (cffi:callback console-char-callback))) (defun callback-clear () (glfw:set-key-callback (cffi:null-pointer)) @@ -173,8 +173,18 @@ (format nil "Flexichain cursor pos ~A " (flexichain:cursor-pos (current-cursor *glwindow*))) 0 20)) -(defun render-world () +(defun render-console () (when *console* + ;; set up textures, clobber projection, give us raster-style viewport + (gl:enable gl:+texture-2d+) + (gl:enable gl:+blend+) + (gl:matrix-mode gl:+projection+) + (gl:load-identity) + (gl:push-matrix) + (gl:matrix-mode gl:+modelview+) + (gl:load-identity) + (gl:push-matrix) + (viewport *glwindow*) (render-debug) (let* ((rendered-chain (current-line *glwindow*)) (screen-line 0) @@ -234,10 +244,6 @@ (setf cursor (make-instance 'flexichain:left-sticky-flexicursor :position 0 :chain rendered-chain)))))))) -;; (render-char (font-of window) #\A 0.5 0.5)) - -(defun update-world (dt)) - (defun main-loop () (let ((t0 (glfw:get-time)) (dt 0.0) @@ -253,8 +259,7 @@ (gl:clear gl:+color-buffer-bit+) (setf dt (- (glfw:get-time) t0)) (setf t0 (glfw:get-time)) - (update-world dt) - (render-world) + (render-console) ;;(glrepl::render test-image) ;; update ;; check for time available if time is avaliable render @@ -276,7 +281,7 @@ (progn (init-gl) (format t "Making font..") - (setf (font-of *glwindow*) (make-font glrepl::*font-pathname*)) ;; prbly shld be mber of window + (setf (font-of *glwindow*) (make-font (merge-pathnames #P"VeraMono.ttf"))) ;; prbly shld be mber of window (format t "Done..") (glfw:swap-interval 1) (glfw:enable glfw:+key-repeat+) diff --git a/glrepl-window.lisp b/glrepl-window.lisp index 915b65a..05348df 100644 --- a/glrepl-window.lisp +++ b/glrepl-window.lisp @@ -111,22 +111,23 @@ ;; cursor motion (defgeneric cursor-up (win)) -(defmethod cursor-up ((win glrepl-window)) - (when (not (zerop (cursor-line-of win))) - (decf (cursor-line-of win) 2) - (if (not (zerop (top-line-of win))) - (decf (top-line-of win) 2) - (if (not (zerop (cursor-y-of win))) - (decf (cursor-y-of win)))))) + +;; (defmethod cursor-up ((win glrepl-window)) +;; (when (not (zerop (cursor-line-of win))) +;; (decf (cursor-line-of win) 2) +;; (if (not (zerop (top-line-of win))) +;; (decf (top-line-of win) 2) +;; (if (not (zerop (cursor-y-of win))) +;; (decf (cursor-y-of win)))))) (defgeneric cursor-down (win)) -(defmethod cursor-down ((win glrepl-window)) - (when (not (= (cursor-line-of win) (array-dimension (lines-of win) 0))) - (incf (cursor-line-of win) 2) - (if (> (- (cursor-line-of win) (top-line-of win)) (text-height-of win)) - (incf (top-line-of win) 2) - (incf (cursor-y-of win))))) +;; (defmethod cursor-down ((win glrepl-window)) +;; (when (not (= (cursor-line-of win) (array-dimension (lines-of win) 0))) +;; (incf (cursor-line-of win) 2) +;; (if (> (- (cursor-line-of win) (top-line-of win)) (text-height-of win)) +;; (incf (top-line-of win) 2) +;; (incf (cursor-y-of win))))) (defgeneric cursor-column (win)) diff --git a/glrepl.lisp b/glrepl.lisp index a30fb1e..20e2bad 100755 --- a/glrepl.lisp +++ b/glrepl.lisp @@ -23,6 +23,7 @@ (vecto:with-canvas (:width (bitmap-width-of result) :height (bitmap-height-of result)) (let ((repl-font (vecto:get-font (pathname-of result))) (repl-letter (string (code-char i)))) + (declare (base-string repl-letter)) (vecto:set-font repl-font 12) (when (zpb-ttf:glyph-exists-p (code-char i) repl-font) (handler-case @@ -46,7 +47,7 @@ (declare (fixnum y)) (setf (pixel-xy (aref (images-of result) i) x y) ;; #XFF000000 (pixval - (the fixunum (aref (zpng::data-array (vecto::image vecto::*graphics-state*)) y x 0)) + (the fixnum (aref (zpng::data-array (vecto::image vecto::*graphics-state*)) y x 0)) (the fixnum (aref (zpng::data-array (vecto::image vecto::*graphics-state*)) y x 1)) (the fixnum (aref (zpng::data-array (vecto::image vecto::*graphics-state*)) y x 2)) (the fixnum (aref (zpng::data-array (vecto::image vecto::*graphics-state*)) y x 3))) diff --git a/package.lisp b/package.lisp index 8ae3540..e0c7dbc 100644 --- a/package.lisp +++ b/package.lisp @@ -6,6 +6,8 @@ *font-pathname* *font-data* *font-images* + *gl-window* + *console* with-opengl name-of make-font @@ -48,6 +50,8 @@ lines-of kills-of window-pixel-atxy - viewport)) + viewport + console-key-callback + console-char-callback)) (in-package :glrepl) \ No newline at end of file -- 2.11.4.GIT