Add unit tests for shader to glsl compiling
This commit is contained in:
parent
f5a324bf4e
commit
e80c9ce69a
2 changed files with 61 additions and 1 deletions
|
|
@ -16,5 +16,6 @@
|
||||||
:components ((:module "t"
|
:components ((:module "t"
|
||||||
:components
|
:components
|
||||||
((:file "stoe")
|
((:file "stoe")
|
||||||
(:file "maths"))))
|
(:file "maths")
|
||||||
|
(:file "shader"))))
|
||||||
:perform (load-op :after (op c) (asdf:clear-system c)))
|
:perform (load-op :after (op c) (asdf:clear-system c)))
|
||||||
|
|
|
||||||
59
t/shader.lisp
Normal file
59
t/shader.lisp
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
#|
|
||||||
|
This file is a part of stoe project.
|
||||||
|
Copyright (c) 2014 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|
||||||
|
|#
|
||||||
|
|
||||||
|
(in-package :cl-user)
|
||||||
|
(defpackage stoe-test.shader
|
||||||
|
(:use :cl
|
||||||
|
:stoe
|
||||||
|
:cl-test-more
|
||||||
|
:stoe.shader))
|
||||||
|
(in-package :stoe-test.shader)
|
||||||
|
|
||||||
|
;; Preamble
|
||||||
|
(defshader test-vertex-shader-1 (:version 330
|
||||||
|
:in ((position :vec4 :location 0)
|
||||||
|
(color :vec4 :location 1))
|
||||||
|
:out ((out-color :vec4 :interp :smooth))
|
||||||
|
:uniform ((camera-to-clip :mat4)
|
||||||
|
(model-to-camera :mat4)))
|
||||||
|
"gl_Position = camera_to_clip * model_to_camera * position;
|
||||||
|
out_color = color;")
|
||||||
|
|
||||||
|
(defshader test-fragment-shader-1 (:version 330
|
||||||
|
:in ((out-color :vec4))
|
||||||
|
:out ((frag-color :vec4)))
|
||||||
|
"frag_color = out_color;")
|
||||||
|
|
||||||
|
(defprogram shader-program ()
|
||||||
|
:vertex-shader test-vertex-shader-1
|
||||||
|
:fragment-shader test-fragment-shader-1)
|
||||||
|
|
||||||
|
;; Start Tests
|
||||||
|
(plan 2)
|
||||||
|
|
||||||
|
(diag "Shader definitions")
|
||||||
|
(is (glsl-compiler::shader-code (gethash 'test-vertex-shader-1 shader::*shader-db*)) "#version 330 core
|
||||||
|
layout (location = 0) in vec4 position;
|
||||||
|
layout (location = 1) in vec4 color;
|
||||||
|
smooth out vec4 out_color;
|
||||||
|
uniform mat4 camera_to_clip;
|
||||||
|
uniform mat4 model_to_camera;
|
||||||
|
void main ()
|
||||||
|
{
|
||||||
|
gl_Position = camera_to_clip * model_to_camera * position;
|
||||||
|
out_color = color;
|
||||||
|
}
|
||||||
|
" "Simple Vertex shader definition" :test #'string=)
|
||||||
|
|
||||||
|
(is (glsl-compiler::shader-code (gethash 'test-fragment-shader-1 shader::*shader-db*)) "#version 330 core
|
||||||
|
in vec4 out_color;
|
||||||
|
out vec4 frag_color;
|
||||||
|
void main ()
|
||||||
|
{
|
||||||
|
frag_color = out_color;
|
||||||
|
}
|
||||||
|
" "Simple Fragment shader definition" :test #'string=)
|
||||||
|
|
||||||
|
(finalize)
|
||||||
Loading…
Add table
Reference in a new issue