Permalink
Browse files

Fix some more stuff.

  • Loading branch information...
Shinmera committed Jun 29, 2018
1 parent 88d1a79 commit 0d873cdab88fd1e66956027bfa742b6a6873735b
Showing with 19 additions and 49 deletions.
  1. +2 −4 resources/buffer-object.lisp
  2. +3 −1 resources/texture.lisp
  3. +3 −0 resources/vertex-buffer.lisp
  4. +5 −5 toolkit.lisp
  5. +6 −39 workbench.lisp
@@ -40,10 +40,7 @@
(with-slots (buffer-type data-usage size) buffer
(gl:bind-buffer buffer-type (gl-name buffer))
(unwind-protect
(let* ((pointer (if data-start
(cffi:inc-pointer data data-start)
data))
(buffer-start (or buffer-start 0)))
(let ((pointer (if data-start (cffi:inc-pointer data data-start) data)))
(if (or buffer-start buffer-end)
(%gl:buffer-sub-data buffer-type (or buffer-start 0) (- (or data-end buffer-end size) data-start) pointer)
(%gl:buffer-data buffer-type size pointer data-usage)))
@@ -118,6 +115,7 @@
:buffer-start buffer-start
:buffer-end buffer-end))
((and #+sbcl T #-sbcl NIL
(typep buffer-data 'simple-array)
(find (array-element-type buffer-data) *native-array-element-types* :test 'equal))
(sb-sys:with-pinned-objects (buffer-data)
(update-buffer-data buffer (sb-sys:vector-sap buffer-data)
View
@@ -362,7 +362,9 @@
(32 32))
(ecase type
(:signed :i)
(:unsigned :u)
;; KLUDGE: For some fucking reason if I put :ui I here GL refuses
;; to upload the texture data with tex-image-2d.
(:unsigned "")
(:float :f)))
"KEYWORD"))
@@ -12,6 +12,9 @@
:buffer-type :array-buffer
:element-type :float))
(defmethod initialize-instance :before ((buffer vertex-buffer) &key element-type)
(check-vertex-buffer-element-type element-type))
(defmethod update-buffer-data ((buffer vertex-buffer) data &rest args)
(let ((element-type (getf args :element-type)))
(when (and element-type (not (equal element-type (element-type buffer))))
View
@@ -521,7 +521,10 @@
:geometry-shader :fragment-shader
:tess-control-shader :tess-evaluation-shader)
(define-enum-check vertex-buffer-type
(define-enum-check vertex-buffer-element-type
:double :float :int :uint :char)
(define-enum-check buffer-object-type
:array-buffer :atomic-counter-buffer
:copy-read-buffer :copy-write-buffer
:dispatch-indirect-buffer :draw-indirect-buffer
@@ -530,10 +533,7 @@
:shader-storage-buffer :texture-buffer
:transform-feedback-buffer :uniform-buffer)
(define-enum-check vertex-buffer-element-type
:double :float :int :uint :char)
(define-enum-check vertex-buffer-data-usage
(define-enum-check buffer-object-data-usage
:stream-draw :stream-read :stream-copy :static-draw
:static-read :static-copy :dynamic-draw :dynamic-read
:dynamic-copy)
View
@@ -4,59 +4,26 @@
:base 'trial)
(define-asset (workbench cube) mesh
(make-cube 200))
(make-cube 20))
(define-asset (workbench cat) image
#p"~/clipmaps/4096/0,0.png"
:min-filter :linear)
#p"cat.png")
(define-shader-entity tester (vertex-entity textured-entity)
()
(:default-initargs
:name :tester
:vertex-array (asset 'workbench 'cube)
:texture (asset 'workbench 'cat))
(:inhibit-shaders (textured-entity :fragment-shader)))
())
(defmethod update :after ((main main) tt dt)
(let ((clipmap (unit :clipmap (scene main)))
(tester (unit :tester (scene main))))
(let ((clipmap (unit :clipmap (scene main))))
(when clipmap
(case 0
(0 (setf (location clipmap) (load-time-value (vec 0 0 0))))
(1 (maybe-show-region clipmap (- (mod (* 100 tt) 1024) 512) 0))
(2 (maybe-show-region clipmap (* 64 (sin (* 2 tt))) (* 64 (cos (* 2 tt)))))))))
(define-class-shader (tester :fragment-shader)
"in vec2 texcoord;
out vec4 color;
uniform sampler2D texture_image;
void main(){
color = vec4(texture(texture_image, texcoord).r, 0, 0, 1);
}")
(progn
(defmethod setup-scene ((main main) scene)
(cond ((= 1 0)
(enter (make-instance 'tester :texture (make-instance 'texture :pixel-format :red
:min-filter :linear
:pixel-type (infer-pixel-type 16)
:internal-format (infer-internal-format 16 :red)
:width (* 2 512)
:height (* 2 512))) scene)
(enter (make-instance 'target-camera :location (vec 400 400 0)) scene))
(T
(enter (make-instance 'editor-camera :move-speed 0.5
:rotation (VEC3 0.63999623 1.4305115e-6 0.0)
:location (VEC3 -0.79987687 497.58453 775.5049)) scene)
(let ((clipmap (make-instance 'geometry-clipmap
:data-directory #p"~/clipmaps/"
:levels 5
:name :clipmap)))
(enter clipmap scene)
;(enter (make-instance 'tester :texture (texture-buffer clipmap)) scene)
)))
(enter (make-instance 'tester :vertex-array (asset 'workbench 'cube) :texture (asset 'workbench 'cat)) scene)
(enter (make-instance 'target-camera :location (vec 50 50 0)) scene)
(enter (make-instance 'render-pass) scene))
(maybe-reload-scene))

0 comments on commit 0d873cd

Please sign in to comment.