From c982399f44861f29a51805a5b4c1ed3be05f3757 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 29 Nov 2014 12:33:56 -0500 Subject: render: Delete renderer module. * sly/render/renderer.scm: Delete. * Makefile.am (SOURCES): Delete it. --- Makefile.am | 1 - sly/render/renderer.scm | 128 ------------------------------------------------ 2 files changed, 129 deletions(-) delete mode 100644 sly/render/renderer.scm diff --git a/Makefile.am b/Makefile.am index c184dfe..c43415e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,7 +57,6 @@ SOURCES = \ sly/render/tileset.scm \ sly/render/vertex-array.scm \ sly/render/context.scm \ - sly/render/renderer.scm \ $(WRAPPER_SOURCES) WRAPPER_SOURCES = \ diff --git a/sly/render/renderer.scm b/sly/render/renderer.scm deleted file mode 100644 index bb8f297..0000000 --- a/sly/render/renderer.scm +++ /dev/null @@ -1,128 +0,0 @@ -;;; Sly -;;; Copyright (C) 2014 David Thompson -;;; -;;; Sly is free software: you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by -;;; the Free Software Foundation, either version 3 of the License, or -;;; (at your option) any later version. -;;; -;;; Sly is distributed in the hope that it will be useful, but WITHOUT -;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -;;; License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see -;;; . - -;;; Commentary: -;; -;; OpenGL renderer. -;; -;;; Code: - -(define-module (sly render renderer) - #:use-module (system foreign) - #:use-module (ice-9 match) - #:use-module (srfi srfi-9) - #:use-module (srfi srfi-26) - #:use-module (gl) - #:use-module (gl low-level) - #:use-module (sly render shader) - #:use-module (sly render texture) - #:use-module (sly math transform) - #:use-module (sly math vector) - #:use-module (sly render utils) - #:use-module (sly render camera) - #:use-module (sly render context) - #:use-module (sly render vertex-array) - #:export (make-render-op render-op? - render-op-transform render-op-vertex-array - render-op-texture render-op-shader - render-op-blend-mode render-op-uniforms - transform-render-op - make-renderer renderer? - renderer-ops - render)) - -;; Representation of a single OpenGL render call. -(define-record-type - (%make-render-op transform vertex-array texture shader uniforms - blend-mode depth-test?) - render-op? - (transform render-op-transform) - (vertex-array render-op-vertex-array) - (texture render-op-texture) - (shader render-op-shader) - (uniforms render-op-uniforms) - (blend-mode render-op-blend-mode) - (depth-test? render-op-depth-test?)) - -(define* (make-render-op #:optional #:key (transform identity-transform) - (vertex-array #f) (texture #f) (shader #f) - (uniforms '()) (blend-mode default-blend-mode) - (depth-test? #t)) - "Create a new render operation object. Optional arguments include: -TRANSFORM, a model transformation matrix. VERTEX-ARRAY, the geometry -container. TEXTURE, the texture object to bind. SHADER, the shader -program to bind. UNIFORMS, the variables to be passed to the shader. -And DEPTH-TEST?, a flag that determines whether the depth buffer is -activated or not." - (%make-render-op transform vertex-array texture shader uniforms - blend-mode depth-test?)) - -(define apply-render-op - ;; Rendering should only ever happen from the main thread, so - ;; mutating this transform is just fine. - (let ((mvp (make-transform 0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 0 0 0))) - (lambda (context view op) - "Render OP by applying its transform (multiplied by VIEW), texture, -shader, vertex array, uniforms, blend mode, etc. to the render -CONTEXT." - (match op - (($ transform vertex-array texture shader uniforms - blend-mode depth-test?) - (set-render-context-depth-test?! context depth-test?) - (set-render-context-blend-mode! context blend-mode) - (set-render-context-shader! context shader) - (set-render-context-vertex-array! context vertex-array) - (set-render-context-texture! context texture) - (transform*! mvp transform view) - (for-each (lambda (uniform) - (match uniform - ((name value) - (uniform-set! shader name value)))) - `(("mvp" ,mvp) - ,@uniforms)) - (glDrawElements (begin-mode triangles) - (vertex-array-length vertex-array) - (data-type unsigned-int) - %null-pointer)))))) - -(define-record-type - (make-renderer context cameras ops) - renderer? - (context renderer-context) - (cameras renderer-cameras) - (ops renderer-ops)) - -(define render - (let ((view (make-transform 0 0 0 0 - 0 0 0 0 - 0 0 0 0 - 0 0 0 0))) - (lambda (renderer) - "Apply all of the render operations in RENDERER. The render -operations are applied once for each camera." - (let ((context (renderer-context renderer))) - (with-render-context context - (for-each (lambda (camera) - (transform*! view - (camera-location camera) - (camera-projection camera)) - (for-each (cut apply-render-op context view <>) - (renderer-ops renderer))) - (renderer-cameras renderer))))))) -- cgit v1.2.3