#lang racket/gui
(require (planet stephanh/rgl:1:0/rgl)
ffi/vector)
(define frame
(new frame%
[label "Example"]
[width 300]
[height 300]))
(define (print-info)
(for ((ext (in-set (gl-extensions))))
(printf "Extension: ~a~%" ext))
(printf "~s~%" (gl-version))
(if (gl-has-extension? 'GL_EXT_texture_object)
(printf "Yep, we have GL_EXT_texture_object~%")
(printf "Sorry no GL_EXT_texture_object~%"))
(let ((v (glGetIntegerv GL_VERTEX_ARRAY)))
(printf "glGet on GL_VERTEX_ARRAY = ~s~%" (s32vector-ref v 0))))
(define first-call #t)
(define (draw)
(when first-call
(set! first-call #f)
(print-info))
(glClear GL_COLOR_BUFFER_BIT)
(define vertex-array
(f64vector -0.5 -0.5
0.5 -0.5
0.5 0.5
-0.5 0.5))
(glVertexPointer 2 (gl-vector->type vertex-array) 0 (f64vector->cpointer vertex-array))
(glEnableClientState GL_VERTEX_ARRAY)
(glDrawArrays GL_QUADS 0 4)
(glDisableClientState GL_VERTEX_ARRAY))
(define gl-canvas%
(class canvas%
(super-new)
(inherit with-gl-context swap-gl-buffers)
(define/override (on-paint)
(with-gl-context (lambda () (draw)))
(swap-gl-buffers))))
(define c
(new gl-canvas%
[style '(gl)] [parent frame]))
(send c set-canvas-background (send the-color-database find-color "black"))
(send frame show #t)