(require "ppcamera.ss")

(clear)

(define v
"
varying vec2 tc;
void main(){
   gl_Position = ftransform();
   tc = gl_MultiTexCoord0.st;
}")

(define f
"
uniform sampler2D tex;
varying vec2 tc;
void main() {
  gl_FragColor = texture2D(tex,abs(tc-vec2(0.5))+vec2(0.5));
}")

(define p (build-pixels 2048 1024 #t))

(with-primitive p
	(scale 0))

(set-camera-transform (mtranslate (vector 0 0 -10)))

(define (render)
    (pp-input-camera p)
    (with-pixels-renderer p
        (texture (load-texture "test.png"))
        (with-state
            (hint-unlit)
            (identity)
            (scale 5.0)
            (draw-cube))))

(with-primitive (build-plane)
		(texture (pixels->texture p))
		(shader-source v f)
		(scale (vector 20 15 1)))

(every-frame (render))

