Last active
December 19, 2019 03:42
-
-
Save t-sin/b60fe645a6973c5616bbf139f989d2f4 to your computer and use it in GitHub Desktop.
This shader renders white pixels but apears black window...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage #:test | |
(:use #:cl) | |
(:import-from #:cl-glfw3 | |
#:with-init-window | |
#:def-key-callback | |
#:get-proc-address | |
#:set-key-callback | |
#:set-window-should-close | |
#:window-should-close-p | |
#:swap-buffers | |
#:poll-events) | |
(:export #:main)) | |
(in-package #:test) | |
(defparameter *context* | |
(list :title "Lazy Sweet Dream" | |
:version (asdf:component-version (asdf:find-system :lsd)) | |
:width 800 | |
:height 600)) | |
(def-key-callback quit-on-escape (window key scancode action mod-keys) | |
(declare (ignore window scancode mod-keys)) | |
(when (and (eq key :escape) (eq action :press)) | |
(set-window-should-close))) | |
(defun show-window (context) | |
(with-init-window (:title (getf context :title) | |
:width (getf context :width) | |
:height (getf context :height) | |
:context-version-major 4 | |
:context-version-minor 0 | |
:resizable nil) | |
;; print OpenGL version | |
(format t "OpenGL version: ~a.~a.~a" | |
(glfw:get-window-attribute :context-version-major) | |
(glfw:get-window-attribute :context-version-minor) | |
(glfw:get-window-attribute :context-revision)) | |
(set-key-callback 'quit-on-escape) | |
(glfw:swap-interval 1) | |
(let* ((vs-code '(pos)) | |
(fs-code '((vari:vec4 1 1 1 1))) | |
(vsc (varjo:translate (varjo:make-stage :vertex '((pos :vec4)) nil '(:400) vs-code))) | |
(fsc (varjo:translate (varjo:make-stage :fragment '() nil '(:400) fs-code))) | |
(vs (gl:create-shader :vertex-shader)) | |
(fs (gl:create-shader :fragment-shader)) | |
(p (gl:create-program))) | |
(print (varjo:glsl-code vsc)) | |
(print (varjo:glsl-code fsc)) | |
(gl:shader-source vs (varjo:glsl-code vsc)) | |
(gl:compile-shader vs) | |
(print (gl:get-shader-info-log vs)) | |
(gl:attach-shader p vs) | |
(gl:shader-source fs (varjo:glsl-code fsc)) | |
(gl:compile-shader fs) | |
(print (gl:get-shader-info-log fs)) | |
(gl:attach-shader p fs) | |
(gl:bind-attrib-location p 0 "POS") | |
(let ((outname (varjo:glsl-name (nth 0 (varjo:output-variables fsc))))) | |
(print outname) | |
(gl:bind-frag-data-location p 0 outname)) | |
(gl:link-program p) | |
(gl:use-program p)) | |
(loop | |
:until (window-should-close-p) | |
:do (progn | |
(gl:clear :color-buffer)) | |
:do (swap-buffers) | |
:do (poll-events)))) | |
(defun main () | |
(show-window *context*)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment