Browse files

remove LOAD/OFFLOAD method definitions for entities, convert to BAKE …

…where necessary.
  • Loading branch information...
Shinmera committed Dec 5, 2017
1 parent 7844c31 commit 12ea043055af1c82d00b191436fd2f6c2230f887
Showing with 12 additions and 69 deletions.
  1. +0 −8 array-container.lisp
  2. +0 −3 controller.lisp
  3. +0 −8 flare.lisp
  4. +0 −7 geometry-clipmap.lisp
  5. +0 −6 helpers.lisp
  6. +2 −4 selection-buffer.lisp
  7. +7 −15 shader-pass.lisp
  8. +3 −12 skybox.lisp
  9. +0 −6 ui/elements.lisp
@@ -39,14 +39,6 @@
(defmethod (setf unit) (value n (container array-container))
(setf (aref (objects container) n) value))

(defmethod load progn ((container array-container))
(for:for ((object across (objects container)))
(load object)))

(defmethod offload progn ((container array-container))
(for:for ((object across (objects container)))
(offload object)))

(defmethod finalize ((container array-container))
(for:for ((object across (objects container)))
(finalize object)))
@@ -40,9 +40,6 @@
:name :controller))

(defmethod load progn ((controller controller))
(load (text controller)))

(defmethod register-object-for-pass :after (pass (controller controller))
(register-object-for-pass pass (text controller)))

@@ -22,14 +22,6 @@
(translate vec)
(funcall func)))

(defmethod load progn ((container container))
(for:for ((object over container))
(load object)))

(defmethod offload progn ((container container))
(for:for ((object over container))
(offload object)))

(defmethod register-object-for-pass (pass (container container))
(for:for ((object over container))
(register-object-for-pass pass object)))
@@ -23,13 +23,6 @@
(setf (clipmap-trims clipmap) (loop for trim in trims
collect (make-asset 'mesh (list trim))))))

(defmethod load progn ((clipmap clipmap))
(load (clipmap-center clipmap))
(load (clipmap-block clipmap))
(load (clipmap-fixup clipmap))
(mapc #'load (clipmap-trims clipmap))
(load (texture clipmap)))

(defmethod paint ((clipmap clipmap) (pass shader-pass))
(gl:active-texture :texture0)
(gl:bind-texture :texture-2d-array (resource (texture clipmap)))
@@ -71,9 +71,6 @@
(%gl:draw-elements (vertex-form subject) (size vao) :unsigned-int 0)
(gl:bind-vertex-array 0)))

(defmethod load progn ((subject vertex-entity))
(load (vertex-array subject)))

(define-class-shader (vertex-entity :vertex-shader)
"layout (location = 0) in vec3 position;
@@ -139,9 +136,6 @@ void main(){
(gl:bind-texture (target tex) 0))))

(defmethod load progn ((subject textured-entity))
(load (texture subject)))

(define-class-shader (textured-entity :vertex-shader)
"layout (location = 1) in vec2 in_texcoord;
out vec2 texcoord;
@@ -45,12 +45,10 @@
(register (make-instance 'selection-buffer-pass) buffer)
(add-handler buffer scene))

(defmethod load progn ((buffer selection-buffer))
(defmethod bake ((buffer selection-buffer))
(pack buffer)
(for:for ((object over (scene buffer)))
(register-object-for-pass buffer object))
(loop for pass across (passes buffer)
do (load pass)))
(register-object-for-pass buffer object)))

(defmethod finalize :after ((buffer selection-buffer))
(remove-handler buffer (scene buffer)))
@@ -129,10 +129,6 @@
;; Object changed, recompile it
(refresh subject-class))))))

(defmethod load progn ((pass per-object-pass))
(loop for v being the hash-values of (assets pass)
do (load v)))

(defmethod shader-program-for-pass ((pass per-object-pass) (subject shader-entity))
(gethash (class-of subject) (assets pass)))

@@ -203,13 +199,12 @@
(samples :initarg :samples :accessor samples))
(:default-initargs :samples 8))

(defmethod load progn ((pass multisampled-pass))
(let ((fbo (make-asset 'framebuffer-bundle
`((:attachment :color-attachment0 :bits ,(samples pass) :target :texture-2d-multisample)
(:attachment :depth-stencil-attachment :bits ,(samples pass) :target :texture-2d-multisample))
:width (width *context*) :height (height *context*))))
(load fbo)
(setf (multisample-fbo pass) fbo)))
(defmethod bake ((pass multisampled-pass))
(setf (multisample-fbo pass)
(make-asset 'framebuffer-bundle
`((:attachment :color-attachment0 :bits ,(samples pass) :target :texture-2d-multisample)
(:attachment :depth-stencil-attachment :bits ,(samples pass) :target :texture-2d-multisample))
:width (width *context*) :height (height *context*))))

(defmethod paint-with :around ((pass multisampled-pass) target)
(let ((original-framebuffer (resource (framebuffer pass))))
@@ -243,7 +238,7 @@
(when loaded (load (shader-program single-shader-pass))))))

(defmethod load progn ((pass single-shader-pass))
(setf (shader-program pass) (load (make-class-shader-program pass))))
(setf (shader-program pass) (make-class-shader-program pass)))

(defmethod register-object-for-pass ((pass single-shader-pass) o))

@@ -259,9 +254,6 @@
(define-shader-pass post-effect-pass (single-shader-pass)
((vertex-array :initform (asset 'trial 'fullscreen-square) :accessor vertex-array)))

(defmethod load progn ((pass post-effect-pass))
(load (vertex-array pass)))

(defmethod paint-with ((pass post-effect-pass) thing)
(let ((vao (vertex-array pass)))
@@ -6,31 +6,22 @@

(in-package #:org.shirakumo.fraf.trial)

(define-shader-entity skybox ()
(define-shader-entity skybox (vertex-entity)
((texture :initarg :texture :accessor texture)
(vertex-array :initform NIL :Accessor vertex-array))
(:default-initargs :texture (error "TEXTURE required.")))

(defmethod load progn ((skybox skybox))
(load (texture skybox))
(setf (vertex-array skybox) (gl:gen-vertex-array)))

(defmethod offload progn ((skybox skybox))
(offload (texture skybox))
(gl:delete-vertex-arrays (list (vertex-array skybox))))
(:default-initargs :texture (error "TEXTURE required.")
:vertex-array (make-instance 'vertex-array)))

(defmethod paint ((skybox skybox) (pass shader-pass))
(let ((shader (shader-program-for-pass pass skybox))
(texture (texture skybox)))
(setf (uniform shader "view_matrix") (view-matrix))
(setf (uniform shader "projection_matrix") (projection-matrix))
(gl:depth-mask NIL)
(gl:bind-vertex-array (vertex-array skybox))
(gl:active-texture :texture0)
(gl:bind-texture (target texture) (resource texture))
(gl:draw-arrays :triangle-strip 0 4)
(gl:bind-texture (target texture) 0)
(gl:bind-vertex-array 0)
(gl:depth-mask T)))

(define-class-shader (skybox :vertex-shader)
@@ -67,12 +67,6 @@
(defmethod initialize-instance :after ((text-element text-element) &key text text-color font)
(setf (text-asset text-element) (make-instance 'text :text text :color text-color :font font)))

(defmethod load progn ((text-element text-element))
(load (text-asset text-element)))

(defmethod offload progn ((text-element text-element))
(offload (text-asset text-element)))

(defmethod text ((text-element text-element))
(text (text-asset text-element)))

0 comments on commit 12ea043

Please sign in to comment.