diff options
-rw-r--r-- | chickadee/graphics/buffer.scm | 2 | ||||
-rw-r--r-- | chickadee/graphics/engine.scm | 5 | ||||
-rw-r--r-- | chickadee/graphics/framebuffer.scm | 1 | ||||
-rw-r--r-- | chickadee/graphics/shader.scm | 1 | ||||
-rw-r--r-- | chickadee/graphics/texture.scm | 1 |
5 files changed, 10 insertions, 0 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm index f5ec8c6..37a77e4 100644 --- a/chickadee/graphics/buffer.scm +++ b/chickadee/graphics/buffer.scm @@ -204,6 +204,7 @@ USAGE may be: NAME is simply an arbitrary string for debugging purposes that is never sent to the GPU." + (assert-current-graphics-engine) ;; Weird bugs will occur when creating a new vertex buffer while a ;; vertex array is bound. (with-graphics-state! ((vertex-array null-vertex-array)) @@ -561,6 +562,7 @@ argument may be overridden. The following values are supported: - triangles - triangle-strip - triangle-fan" + (assert-current-graphics-engine) (let ((array (%make-vertex-array (generate-vertex-array) indices attributes diff --git a/chickadee/graphics/engine.scm b/chickadee/graphics/engine.scm index 4f1250f..1531e3f 100644 --- a/chickadee/graphics/engine.scm +++ b/chickadee/graphics/engine.scm @@ -23,6 +23,7 @@ graphics-engine-guard! graphics-engine-reap! current-graphics-engine + assert-current-graphics-engine current-projection with-projection with-graphics-state @@ -200,6 +201,10 @@ (define current-graphics-engine (make-parameter #f)) +(define-syntax-rule (assert-current-graphics-engine) + (unless (current-graphics-engine) + (error "No active graphics engine. Make sure the game loop is running before calling this procedure."))) + (define* (graphics-engine-gl-context #:optional (engine (current-graphics-engine))) (%graphics-engine-gl-context engine)) diff --git a/chickadee/graphics/framebuffer.scm b/chickadee/graphics/framebuffer.scm index edf97a2..5a8be8d 100644 --- a/chickadee/graphics/framebuffer.scm +++ b/chickadee/graphics/framebuffer.scm @@ -101,6 +101,7 @@ (wrap-s 'repeat) (wrap-t 'repeat)) "Create a new framebuffer that renders to a texture with dimensions WIDTH x HEIGHT." + (assert-current-graphics-engine) (let* ((framebuffer-id (generate-framebuffer)) (renderbuffer-id (generate-renderbuffer)) (texture (make-texture #f width height diff --git a/chickadee/graphics/shader.scm b/chickadee/graphics/shader.scm index 335f79c..9b2070b 100644 --- a/chickadee/graphics/shader.scm +++ b/chickadee/graphics/shader.scm @@ -712,6 +712,7 @@ them into a GPU shader program." (error "unsupported attribute size" name size)) (hash-set! table name (make-attribute name location type))))) table)) + (assert-current-graphics-engine) (let ((vertex-id (make-shader-stage (version-2-0 vertex-shader) vertex-port)) (fragment-id (make-shader-stage (version-2-0 fragment-shader) diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm index 30ae9a0..f056be8 100644 --- a/chickadee/graphics/texture.scm +++ b/chickadee/graphics/texture.scm @@ -170,6 +170,7 @@ clamp-to-edge. FORMAT specifies the pixel format. Currently only ('clamp-to-border (texture-wrap-mode clamp-to-border-sgis)) ('clamp-to-edge (texture-wrap-mode clamp-to-edge-sgis)))) + (assert-current-graphics-engine) (let ((texture (%make-texture (gl-generate-texture) #f min-filter mag-filter wrap-s wrap-t 0 0 width height |