#lang racket/gui
(require (planet "rgl.rkt" ("stephanh" "RacketGL.plt" 1 3)))
(require ffi/vector)
(require "viewer.rkt")
(define texture #f)
(define (setup)
(set! texture (load-texture "plt-logo-red-gradient.png" #:repeat 'both)))
(define (draw)
(define vertex-array
(f64vector -0.5 -0.5
0.5 -0.5
0.5 0.5
-0.5 0.5))
(define texcoord-array
(s16vector 0 2
2 2
2 0
0 0))
(glBindTexture GL_TEXTURE_2D texture)
(glEnable GL_TEXTURE_2D)
(glBlendFunc GL_ONE GL_ONE_MINUS_SRC_ALPHA) (glEnable GL_BLEND)
(let-values (((type cptr) (gl-vector->type/cpointer vertex-array)))
(glVertexPointer 2 type 0 cptr))
(let-values (((type cptr) (gl-vector->type/cpointer texcoord-array)))
(glTexCoordPointer 2 type 0 cptr))
(glEnableClientState GL_VERTEX_ARRAY)
(glEnableClientState GL_TEXTURE_COORD_ARRAY)
(glDrawArrays GL_QUADS 0 4)
(glDisableClientState GL_TEXTURE_COORD_ARRAY)
(glDisableClientState GL_VERTEX_ARRAY))
(view draw setup)