diff --git a/business-tycoon.asd b/business-tycoon.asd index 0a557c7..0a96e15 100644 --- a/business-tycoon.asd +++ b/business-tycoon.asd @@ -16,6 +16,7 @@ :components ((:module "src" :serial t :components ((:file "package") + (:file "camera") (:file "shader") (:file "texture") (:file "renderer") diff --git a/shaders/light.frag b/shaders/light.frag new file mode 100644 index 0000000..b2a2083 --- /dev/null +++ b/shaders/light.frag @@ -0,0 +1,7 @@ +#version 330 core +out vec4 FragColor; + +void main() +{ + FragColor = vec4(1.0); +} diff --git a/shaders/light.vert b/shaders/light.vert new file mode 100644 index 0000000..70a22c7 --- /dev/null +++ b/shaders/light.vert @@ -0,0 +1,11 @@ +#version 330 core +layout (location = 0) in vec3 aPos; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +void main() +{ + gl_Position = projection * view * model * vec4(aPos, 1.0); +} diff --git a/shaders/shader.frag b/shaders/shader.frag index f5a29ee..17c8a6a 100644 --- a/shaders/shader.frag +++ b/shaders/shader.frag @@ -1,15 +1,147 @@ #version 330 core out vec4 FragColor; -in vec3 ourColor; -in vec2 TexCoord; +struct Material { + sampler2D diffuse; + sampler2D specular; + float shininess; +}; -uniform sampler2D texture1; -uniform sampler2D texture2; +struct DirLight { + vec3 direction; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +struct PointLight { + vec3 position; + + float constant; + float linear; + float quadratic; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +struct SpotLight { + vec3 position; + vec3 direction; + float cutOff; + float outerCutOff; + + float constant; + float linear; + float quadratic; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +#define NR_POINT_LIGHTS 4 + +in vec3 FragPos; +in vec3 Normal; +in vec2 TexCoords; + +uniform vec3 viewPos; +uniform DirLight dirLight; +uniform PointLight pointLights[NR_POINT_LIGHTS]; +uniform SpotLight spotLight; +uniform Material material; + +// function prototypes +vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir); +vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir); +vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir); void main() +{ + // properties + vec3 norm = normalize(Normal); + vec3 viewDir = normalize(viewPos - FragPos); + + // == ===================================================== + // Our lighting is set up in 3 phases: directional, point lights and an optional flashlight + // For each phase, a calculate function is defined that calculates the corresponding color + // per lamp. In the main() function we take all the calculated colors and sum them up for + // this fragment's final color. + // == ===================================================== + // phase 1: directional lighting + vec3 result = CalcDirLight(dirLight, norm, viewDir); + // phase 2: point lights + for(int i = 0; i < NR_POINT_LIGHTS; i++) + result += CalcPointLight(pointLights[i], norm, FragPos, viewDir); + // // phase 3: spot light + result += CalcSpotLight(spotLight, norm, FragPos, viewDir); + + FragColor = vec4(result, 1.0); +} + +// calculates the color when using a directional light. +vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir) +{ + vec3 lightDir = normalize(-light.direction); + // diffuse shading + float diff = max(dot(normal, lightDir), 0.0); + // specular shading + vec3 reflectDir = reflect(-lightDir, normal); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + // combine results + vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); + vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); + vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); + return (ambient + diffuse + specular); +} + +// calculates the color when using a point light. +vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir) +{ + vec3 lightDir = normalize(light.position - fragPos); + // diffuse shading + float diff = max(dot(normal, lightDir), 0.0); + // specular shading + vec3 reflectDir = reflect(-lightDir, normal); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + // attenuation + float distance = length(light.position - fragPos); + float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); + // combine results + vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); + vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); + vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); + ambient *= attenuation; + diffuse *= attenuation; + specular *= attenuation; + return (ambient + diffuse + specular); +} + +// calculates the color when using a spot light. +vec3 CalcSpotLight(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) { - FragColor = mix(texture(texture1, TexCoord), - texture(texture2, TexCoord), - 0.2); + vec3 lightDir = normalize(light.position - fragPos); + // diffuse shading + float diff = max(dot(normal, lightDir), 0.0); + // specular shading + vec3 reflectDir = reflect(-lightDir, normal); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + // attenuation + float distance = length(light.position - fragPos); + float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); + // spotlight intensity + float theta = dot(lightDir, normalize(-light.direction)); + float epsilon = light.cutOff - light.outerCutOff; + float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0); + // combine results + vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoords)); + vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoords)); + vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoords)); + ambient *= attenuation * intensity; + diffuse *= attenuation * intensity; + specular *= attenuation * intensity; + return (ambient + diffuse + specular); } diff --git a/shaders/shader.vert b/shaders/shader.vert index a10ed17..7380c82 100644 --- a/shaders/shader.vert +++ b/shaders/shader.vert @@ -1,14 +1,21 @@ #version 330 core layout (location = 0) in vec3 aPos; -layout (location = 1) in vec2 aTexCoord; +layout (location = 1) in vec3 aNormal; +layout (location = 2) in vec2 aTexCoords; + +out vec3 Normal; +out vec3 FragPos; +out vec2 TexCoords; -out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { - gl_Position = projection * view * model * vec4(aPos, 1.0); - TexCoord = vec2(aTexCoord.x, aTexCoord.y); + FragPos = vec3(model * vec4(aPos, 1.0)); + Normal = mat3(transpose(inverse(model))) * aNormal; + TexCoords = aTexCoords; + + gl_Position = projection * view * vec4(FragPos, 1.0); } diff --git a/src/camera.lisp b/src/camera.lisp index c7e96b7..2f9cc3d 100644 --- a/src/camera.lisp +++ b/src/camera.lisp @@ -10,7 +10,9 @@ #:process-mouse-movement #:process-mouse-scroll #:make-camera - #:*zoom*)) + #:*zoom* + #:*position* + #:*front*)) (in-package #:camera) diff --git a/src/renderer.lisp b/src/renderer.lisp index b30a546..b1e4ab5 100644 --- a/src/renderer.lisp +++ b/src/renderer.lisp @@ -1,17 +1,30 @@ +(defpackage #:renderer + (:use #:cl) + (:export #:init-renderer #:render) + (:import-from #:sb-cga #:vec #:vec* #:matrix* #:translate #:rotate) + (:import-from #:kit.math #:deg-to-rad)) -(in-package #:business-tycoon) +(in-package #:renderer) (defparameter *vbo* 0) (defparameter *vao* 0) (defparameter *ebo* 0) (defparameter *shader-program* nil) -(defparameter *texture1* nil) -(defparameter *texture2* nil) +(defparameter *light-shader* nil) + +(defparameter *diffuse-map* nil) +(defparameter *specular-map* nil) + +(defparameter *light-vao* 0) +(defparameter *light-pos* (sb-cga:vec 1.2 1.0 2.0)) (defun init-renderer () (setf *shader-program* (shader:load #p"shaders/shader.vert" #p"shaders/shader.frag")) - (setf *texture1* (texture:load #p"textures/container.png")) - (setf *texture2* (texture:load #p"textures/awesomeface.png")) + (setf *light-shader* (shader:load #p"shaders/light.vert" #p"shaders/light.frag")) + + (setf *diffuse-map* (texture:load #p"textures/container2.png")) + (setf *specular-map* (texture:load #p"textures/container2_specular.png")) + (setf *vbo* (gl:gen-buffer)) (setf *ebo* (gl:gen-buffer)) (setf *vao* (gl:gen-vertex-array)) @@ -20,56 +33,54 @@ (gl:bind-vertex-array *vao*) (gl:bind-buffer :array-buffer *vbo*) (gl:bind-buffer :element-array-buffer *ebo*) - ;; positions texture coords - (let* ((vertices #(-0.5 -0.5 -0.5 0.0 0.0 - +0.5 -0.5 -0.5 1.0 0.0 - +0.5 +0.5 -0.5 1.0 1.0 - -0.5 +0.5 -0.5 0.0 1.0 - -0.5 -0.5 -0.5 0.0 0.0 - - -0.5 -0.5 +0.5 0.0 0.0 - +0.5 -0.5 +0.5 1.0 0.0 - +0.5 +0.5 +0.5 1.0 1.0 - -0.5 +0.5 +0.5 0.0 1.0 - -0.5 -0.5 +0.5 0.0 0.0 - - -0.5 +0.5 +0.5 1.0 0.0 - -0.5 +0.5 -0.5 1.0 1.0 - -0.5 -0.5 -0.5 0.0 1.0 - -0.5 -0.5 +0.5 0.0 0.0 - -0.5 +0.5 +0.5 1.0 0.0 - - +0.5 +0.5 +0.5 1.0 0.0 - +0.5 +0.5 -0.5 1.0 1.0 - +0.5 -0.5 -0.5 0.0 1.0 - +0.5 -0.5 +0.5 0.0 0.0 - +0.5 +0.5 +0.5 1.0 0.0 - - -0.5 -0.5 -0.5 0.0 1.0 - +0.5 -0.5 -0.5 1.0 1.0 - +0.5 -0.5 +0.5 1.0 0.0 - -0.5 -0.5 +0.5 0.0 0.0 - -0.5 -0.5 -0.5 0.0 1.0 - - -0.5 +0.5 -0.5 0.0 1.0 - +0.5 +0.5 -0.5 1.0 1.0 - +0.5 +0.5 +0.5 1.0 0.0 - -0.5 +0.5 +0.5 0.0 0.0 - -0.5 +0.5 -0.5 0.0 1.0 - )) + ;; positions normals htexture coords + (let* ((vertices #(-0.5 -0.5 -0.5 +0.0 +0.0 -1.0 0.0 0.0 + +0.5 -0.5 -0.5 +0.0 +0.0 -1.0 1.0 0.0 + +0.5 +0.5 -0.5 +0.0 +0.0 -1.0 1.0 1.0 + -0.5 +0.5 -0.5 +0.0 +0.0 -1.0 0.0 1.0 + -0.5 -0.5 -0.5 +0.0 +0.0 -1.0 0.0 0.0 + + -0.5 -0.5 +0.5 +0.0 +0.0 +1.0 0.0 0.0 + +0.5 -0.5 +0.5 +0.0 +0.0 +1.0 1.0 0.0 + +0.5 +0.5 +0.5 +0.0 +0.0 +1.0 1.0 1.0 + -0.5 +0.5 +0.5 +0.0 +0.0 +1.0 0.0 1.0 + -0.5 -0.5 +0.5 +0.0 +0.0 +1.0 0.0 0.0 + + -0.5 +0.5 +0.5 -1.0 +0.0 +0.0 1.0 0.0 + -0.5 +0.5 -0.5 -1.0 +0.0 +0.0 1.0 1.0 + -0.5 -0.5 -0.5 -1.0 +0.0 +0.0 0.0 1.0 + -0.5 -0.5 +0.5 -1.0 +0.0 +0.0 0.0 0.0 + -0.5 +0.5 +0.5 -1.0 +0.0 +0.0 1.0 0.0 + + +0.5 +0.5 +0.5 +1.0 +0.0 +0.0 1.0 0.0 + +0.5 +0.5 -0.5 +1.0 +0.0 +0.0 1.0 1.0 + +0.5 -0.5 -0.5 +1.0 +0.0 +0.0 0.0 1.0 + +0.5 -0.5 +0.5 +1.0 +0.0 +0.0 0.0 0.0 + +0.5 +0.5 +0.5 +1.0 +0.0 +0.0 1.0 0.0 + + -0.5 -0.5 -0.5 +0.0 -1.0 +0.0 0.0 1.0 + +0.5 -0.5 -0.5 +0.0 -1.0 +0.0 1.0 1.0 + +0.5 -0.5 +0.5 +0.0 -1.0 +0.0 1.0 0.0 + -0.5 -0.5 +0.5 +0.0 -1.0 +0.0 0.0 0.0 + -0.5 -0.5 -0.5 +0.0 -1.0 +0.0 0.0 1.0 + + -0.5 +0.5 -0.5 +0.0 +1.0 +0.0 0.0 1.0 + +0.5 +0.5 -0.5 +0.0 +1.0 +0.0 1.0 1.0 + +0.5 +0.5 +0.5 +0.0 +1.0 +0.0 1.0 0.0 + -0.5 +0.5 +0.5 +0.0 +1.0 +0.0 0.0 0.0 + -0.5 +0.5 -0.5 +0.0 +1.0 +0.0 0.0 1.0)) (arr (gl:alloc-gl-array :float (length vertices)))) (dotimes (i (length vertices)) (setf (gl:glaref arr i) (aref vertices i))) (gl:buffer-data :array-buffer :static-draw arr) (gl:free-gl-array arr)) - (let* ((indices #(0 1 2 2 3 4 - 5 6 7 7 8 9 - 10 11 12 12 13 14 - 15 16 17 17 18 19 - 20 21 22 22 23 24 - 25 26 27 27 28 29 - 30 31 32 32 33 34)) + (let* ((indices #(0 1 2 2 3 4 + 5 6 7 7 8 9 + 10 11 12 12 13 14 + 15 16 17 17 18 19 + 20 21 22 22 23 24 + 25 26 27 27 28 29)) (arr (gl:alloc-gl-array :int (length indices)))) (dotimes (i (length indices)) (setf (gl:glaref arr i) (aref indices i))) @@ -77,16 +88,28 @@ (gl:free-gl-array arr)) (gl:vertex-attrib-pointer 0 3 :float nil - (* 5 (cffi:foreign-type-size :float)) + (* 8 (cffi:foreign-type-size :float)) (cffi:null-pointer)) (gl:enable-vertex-attrib-array 0) - (gl:vertex-attrib-pointer 1 2 :float nil - (* 5 (cffi:foreign-type-size :float)) - (cffi:make-pointer (* 3 (cffi:foreign-type-size :float)))) + + (gl:vertex-attrib-pointer 1 3 :float nil + (* 8 (cffi:foreign-type-size :float)) + (* 3 (cffi:foreign-type-size :float))) (gl:enable-vertex-attrib-array 1) - (shader:use *shader-program*) - (shader:set-int *shader-program* "texture1" 0) - (shader:set-int *shader-program* "texture2" 1)) + + (gl:vertex-attrib-pointer 2 2 :float nil + (* 8 (cffi:foreign-type-size :float)) + (* 6 (cffi:foreign-type-size :float))) + (gl:enable-vertex-attrib-array 2) + + (setf *light-vao* (gl:gen-vertex-array)) + (gl:bind-vertex-array *light-vao*) + (gl:bind-buffer :array-buffer *vbo*) + (gl:bind-buffer :element-array-buffer *ebo*) + (gl:vertex-attrib-pointer 0 3 :float nil + (* 8 (cffi:foreign-type-size :float)) + (cffi:null-pointer)) + (gl:enable-vertex-attrib-array 0)) (defun enable-wireframe () (gl:polygon-mode :front-and-back :line)) @@ -102,44 +125,108 @@ (setf wireframe (not wireframe)))) (defun render () + (gl:clear-color 0.1 0.1 0.1 1.0) (gl:clear :color-buffer :depth-buffer-bit) (shader:use *shader-program*) - (gl:active-texture :texture0) - (texture:bind *texture1*) - (gl:active-texture :texture1) - (texture:bind *texture2*) - (gl:bind-vertex-array *vao*) + (shader:set-int *shader-program* "material.diffuse" 0) + (shader:set-int *shader-program* "material.specular" 1) + (shader:set-vec *shader-program* "viewPos" camera:*position*) + (shader:set-float *shader-program* "material.shininess" 32.0) - (shader:set-mat4 *shader-program* "view" (camera:get-view-matrix) nil) - (shader:set-mat4 *shader-program* - "projection" - (kit.math:perspective-matrix (kit.math:deg-to-rad camera:*zoom*) - (apply #'/ (glfw:get-window-size)) - 0.1 - 100.0) - nil) - - (let ((cube-positions (list (sb-cga:vec 0.0 0.0 0.0) - (sb-cga:vec 2.0 5.0 -15.0) - (sb-cga:vec -1.5 -2.2 -2.5) - (sb-cga:vec -3.8 -2.0 -12.3) - (sb-cga:vec 2.4 -0.4 -3.5) - (sb-cga:vec -1.7 3.0 -7.5) - (sb-cga:vec 1.3 -2.0 -2.5) - (sb-cga:vec 1.5 2.0 -2.5) - (sb-cga:vec 1.5 0.2 -1.5) - (sb-cga:vec -1.3 1.0 -1.5)))) - (loop for position in cube-positions - for i from 0 - do (let* ((translation (sb-cga:translate position)) - (angle (coerce (* i (kit.math:deg-to-rad 20.0)) 'single-float)) - (rotation (sb-cga:rotate-around (sb-cga:vec 0.5 1.0 0.0) angle)) - (model (sb-cga:matrix* translation rotation))) - (shader:set-mat4 *shader-program* "model" model nil) - (gl:draw-elements :triangles - (gl:make-null-gl-array :unsigned-int) - :count 36)))) - (gl:bind-vertex-array 0) + (gl:active-texture :texture0) + (texture:bind *diffuse-map*) + (gl:active-texture :texture1) + (texture:bind *specular-map*) + + ;; Directional light + (shader:set-vec *shader-program* "dirLight.direction" (vec -0.2 -1.0 -0.3)) + (shader:set-vec *shader-program* "dirLight.ambient" (vec 0.05 0.05 0.05)) + (shader:set-vec *shader-program* "dirLight.diffuse" (vec 0.4 0.4 0.4)) + (shader:set-vec *shader-program* "dirLight.specular" (vec 0.5 0.5 0.5)) + + ;; Point lights + (let ((point-light-positions (list (vec +0.7 +0.2 +2.0) + (vec +2.3 -3.3 -4.0) + (vec -4.0 +2.0 -12.0) + (vec +0.0 +0.0 -3.0)))) + (dotimes (i (length point-light-positions)) + (shader:set-vec *shader-program* (format nil "pointLights[~a].position" i) + (nth i point-light-positions)) + (shader:set-vec *shader-program* (format nil "pointLights[~a].ambient" i) + (vec 0.05 0.05 0.05)) + (shader:set-vec *shader-program* (format nil "pointLights[~a].diffuse" i) + (vec 0.8 0.8 0.8)) + (shader:set-vec *shader-program* (format nil "pointLights[~a].specular" i) + (vec 1.0 1.0 1.0)) + (shader:set-float *shader-program* (format nil "pointLights[~a].constant" i) 1.0) + (shader:set-float *shader-program* (format nil "pointLights[~a].linear" i) 0.09) + (shader:set-float *shader-program* (format nil "pointLights[~a].quadratic" i) 0.032)) + + ;; Spot light + (shader:set-vec *shader-program* "spotLight.position" camera:*position*) + (shader:set-vec *shader-program* "spotLight.direction" camera:*front*) + (shader:set-vec *shader-program* "spotLight.ambient" (vec 0.0 0.0 0.0)) + (shader:set-vec *shader-program* "spotLight.diffuse" (vec 1.0 1.0 1.0)) + (shader:set-vec *shader-program* "spotLight.specular" (vec 1.0 1.0 1.0)) + (shader:set-float *shader-program* "spotLight.constant" 1.0) + (shader:set-float *shader-program* "spotLight.linear" 0.09) + (shader:set-float *shader-program* "spotLight.quadratic" 0.032) + (shader:set-float *shader-program* "spotLight.cutOff" (cos (deg-to-rad 12.5))) + (shader:set-float *shader-program* "spotLight.outerCutOff" (cos (deg-to-rad 15.0))) + + ;; view/projection transformations + (shader:set-mat4 *shader-program* "projection" + (kit.math:perspective-matrix (kit.math:deg-to-rad camera:*zoom*) + (apply #'/ (glfw:get-window-size)) + 0.1 + 100.0) + nil) + (shader:set-mat4 *shader-program* "view" (camera:get-view-matrix) nil) + + (gl:bind-vertex-array *vao*) + (let ((cube-positions (list (vec +0.0 +0.0 +0.0) + (vec +2.0 +5.0 -15.0) + (vec -1.5 -2.2 -2.5) + (vec -3.8 -2.0 -12.3) + (vec +2.4 -0.4 -3.5) + (vec -1.7 +3.0 -7.5) + (vec +1.3 -2.0 -2.5) + (vec +1.5 +2.0 -2.5) + (vec +1.5 +0.2 -1.5) + (vec -1.3 +1.0 -1.5)))) + (dotimes (i (length cube-positions)) + (shader:set-mat4 *shader-program* + "model" + (matrix* (translate (nth i cube-positions)) + (rotate (vec* (vec 1.0 0.3 0.5) + (deg-to-rad (* 20.0 i))))) + nil) + (gl:draw-elements :triangles + (gl:make-null-gl-array :unsigned-int) + :count 36))) + + (shader:use *light-shader*) + (shader:set-mat4 *light-shader* "view" (camera:get-view-matrix) nil) + (shader:set-mat4 *light-shader* + "projection" + (kit.math:perspective-matrix (kit.math:deg-to-rad camera:*zoom*) + (apply #'/ (glfw:get-window-size)) + 0.1 + 100.0) + nil) + (gl:bind-vertex-array *light-vao*) + (dotimes (i (length point-light-positions)) + (shader:set-float *light-shader* (format nil "pointLights[~a].constant" 1) 1.0) + (shader:set-mat4 *light-shader* + "model" + (sb-cga:matrix* (sb-cga:translate (nth i point-light-positions)) + (sb-cga:scale* 0.2 0.2 0.2)) + nil) + (gl:draw-elements :triangles + (gl:make-null-gl-array :unsigned-int) + :count 36)) + ) + (glfw:swap-buffers)) diff --git a/src/shader.lisp b/src/shader.lisp index c9a1e2b..8e5cfe3 100644 --- a/src/shader.lisp +++ b/src/shader.lisp @@ -1,7 +1,7 @@ (defpackage #:shader (:shadow #:load) (:use #:cl) - (:export #:load #:use #:shader-program #:set-bool #:set-int #:set-float #:set-mat4)) + (:export #:load #:use #:shader-program #:set-bool #:set-int #:set-float #:set-mat4 #:set-vec)) (in-package :shader) @@ -45,6 +45,7 @@ (define-set-uniform set-bool gl:uniformi) (define-set-uniform set-int gl:uniformi) (define-set-uniform set-float gl:uniformf) +(define-set-uniform set-vec gl:uniformfv) (defmethod set-mat4 ((self shader) name matrice &optional (transpose t)) (gl:uniform-matrix-4fv (gl:get-uniform-location (shader-program self) name) diff --git a/src/window.lisp b/src/window.lisp index b5ec069..88a474b 100644 --- a/src/window.lisp +++ b/src/window.lisp @@ -55,10 +55,9 @@ (glfw:set-cursor-position-callback 'cursor-pos-callback) (glfw:set-scroll-callback 'scroll-callback) (glfw:set-input-mode :cursor :disabled) - (gl:clear-color 0 0 0 0) (gl:viewport 0 0 width height) - (camera:make-camera) - (init-renderer) + (camera:make-camera (sb-cga:vec 1.0 2.0 6.0)) + (renderer:init-renderer) (loop until (glfw:window-should-close-p) do (let ((current-frame (glfw:get-time))) (setf *delta-time* (- current-frame *last-frame*)) @@ -67,6 +66,6 @@ (when (eq (glfw:get-key :s) :press) (camera:move-backward *delta-time*)) (when (eq (glfw:get-key :a) :press) (camera:move-left *delta-time*)) (when (eq (glfw:get-key :d) :press) (camera:move-right *delta-time*)) - (render) + (renderer:render) (glfw:poll-events))))) ;; ) diff --git a/textures/container2.png b/textures/container2.png new file mode 100644 index 0000000..596e8da Binary files /dev/null and b/textures/container2.png differ diff --git a/textures/container2_specular.png b/textures/container2_specular.png new file mode 100644 index 0000000..681bf6e Binary files /dev/null and b/textures/container2_specular.png differ