Skip to content
Permalink
Browse files

Properly set the viewport when binding a framebuffer.

  • Loading branch information...
Shinmera committed Oct 20, 2019
1 parent b91dd2e commit a707d20485c1a6ec12938084e69092da2a30d02f
Showing with 20 additions and 14 deletions.
  1. +1 −1 main.lisp
  2. +5 −5 pipeline.lisp
  3. +0 −1 render-texture.lisp
  4. +13 −4 resources/framebuffer.lisp
  5. +1 −3 shadow-map.lisp
@@ -69,7 +69,7 @@
(defmethod paint ((source main) (target main))
(paint (scene source) target)
(gl:bind-framebuffer :draw-framebuffer 0)
(%gl:blit-framebuffer 0 0 (width source) (height source) 0 0 (width source) (height source)
(%gl:blit-framebuffer 0 0 (width source) (height source) 0 0 (width *context*) (height *context*)
(cffi:foreign-bitfield-value '%gl::ClearBufferMask :color-buffer)
(cffi:foreign-enum-value '%gl:enum :nearest)))

@@ -59,7 +59,10 @@
(loop for texture across (textures pipeline)
for texspec across (texspecs pipeline)
do (multiple-value-bind (width height) (texspec-real-size texspec width height)
(resize texture width height))))
(resize texture width height)))
(loop for pass across (passes pipeline)
do (setf (width (framebuffer pass)) width)
(setf (height (framebuffer pass)) height)))

(defmethod normalized-texspec ((texspec list))
(assert (= 0 (getf texspec :level 0)))
@@ -175,10 +178,7 @@

(defmethod paint-with ((pipeline pipeline) source)
(loop for pass across (passes pipeline)
for fbo = (framebuffer pass)
do (gl:bind-framebuffer :framebuffer (gl-name fbo))
;; FIXME: Figure out which to clear depending on framebuffer attachments
(gl:clear :color-buffer :depth-buffer :stencil-buffer)
do (activate (framebuffer pass))
(paint-with pass source)))

(defmethod register-object-for-pass ((pipeline pipeline) object)
@@ -28,6 +28,5 @@
:key #'attachment))))

(defmethod paint-with :before ((target render-texture) source)
(gl:viewport 0 0 (width target) (height target))
(let ((c (clear-color target)))
(gl:clear-color (vx c) (vy c) (vz c) (if (vec4-p c) (vw c) 0.0))))
@@ -64,12 +64,21 @@
(gl:read-buffer :none)))
(unless (and (width framebuffer) (height framebuffer))
(error "The framebuffer has no attachments and no default width and height set!"))
(when-gl-extension :gl-arb-framebuffer-no-attachments
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-width (width framebuffer))
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-height (height framebuffer))))
(unless (attachments framebuffer)
(when-gl-extension :gl-arb-framebuffer-no-attachments
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-width (width framebuffer))
(%gl:framebuffer-parameter-i :framebuffer :framebuffer-default-height (height framebuffer)))))
(gl:bind-framebuffer :framebuffer 0)
(setf (data-pointer framebuffer) fbo)))))

(defmethod resize ((framebuffer framebuffer) width height)
(dolist (attachment (attachments framebuffer))
(resize (second attachment) width height)))
(resize (second attachment) width height))
(setf (width framebuffer) width)
(setf (height framebuffer) height))

(defmethod activate ((framebuffer framebuffer))
(gl:bind-framebuffer :framebuffer (gl-name framebuffer))
(gl:viewport 0 0 (width framebuffer) (height framebuffer))
;; FIXME: Figure out which to clear depending on framebuffer attachments
(gl:clear :color-buffer :depth-buffer :stencil-buffer))
@@ -29,11 +29,9 @@ void main(){}")
(defmethod paint-with ((pass shadow-map-pass) target)
(with-pushed-matrix ((projection-matrix (shadow-projection-matrix pass))
(view-matrix (shadow-view-matrix pass)))
(gl:viewport 0 0 2048 2048)
;(gl:cull-face :front)
(call-next-method)
(gl:cull-face :back)
(gl:viewport 0 0 (width *context*) (height *context*))))
(gl:cull-face :back)))

(define-shader-pass shadow-render-pass ()
((shadow-map :port-type input)

0 comments on commit a707d20

Please sign in to comment.
You can’t perform that action at this time.