Fix unit test for the new defshader system
This commit is contained in:
parent
c910a4ce1f
commit
9b69dee238
1 changed files with 33 additions and 34 deletions
|
|
@ -8,52 +8,51 @@
|
|||
(:use :cl
|
||||
:stoe
|
||||
:prove
|
||||
:stoe.shader))
|
||||
:stoe.shader
|
||||
:stoe.shader.glsl))
|
||||
(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 fshader1 ((u-resolution :uniform :vec2)
|
||||
(u-mouse :uniform :vec2)
|
||||
(u-time :uniform :float))
|
||||
(let ((st :vec2 (abs (/ (- gl-fragcoord u-mouse) u-resolution))))
|
||||
(setf gl-fragcolor (vec4 (- 1.0 (x st)) (y st) 0.0 1.0))))
|
||||
|
||||
(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)
|
||||
(defshader fshader2 ((u-resolution :uniform :vec2)
|
||||
(u-mouse :uniform :vec2)
|
||||
(u-time :uniform :float))
|
||||
(let ((st :vec2 (+ (/ (sin (/ (- gl-fragcoord u-mouse) u-resolution)) 4.0) 0.75)))
|
||||
(setf gl-fragcolor (vec4 (- 1.0 (x st)) (y st) 0.0 1.0))))
|
||||
|
||||
;; 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-print fshader1)
|
||||
"vec2 uniform u_resolution;
|
||||
vec2 uniform u_mouse;
|
||||
float uniform u_time;
|
||||
|
||||
(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;
|
||||
vec2 st = abs ((gl_FragCoord - u_mouse) / u_resolution);
|
||||
|
||||
gl_FragColor = vec4 (1.0 - (st.x), st.y, 0.0, 1.0);
|
||||
}
|
||||
" "Simple Fragment shader definition" :test #'string=)
|
||||
" "shader 1")
|
||||
|
||||
(is (glsl-print fshader2)
|
||||
"vec2 uniform u_resolution;
|
||||
vec2 uniform u_mouse;
|
||||
float uniform u_time;
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec2 st = (( sin ((gl_FragCoord - u_mouse) / u_resolution)) / 4.0) + 0.75;
|
||||
|
||||
gl_FragColor = vec4 (1.0 - (st.x), st.y, 0.0, 1.0);
|
||||
}
|
||||
" "shader 2")
|
||||
|
||||
(finalize)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue