Skip to content

Instantly share code, notes, and snippets.

@ianpreston
Created January 10, 2015 17:27
Show Gist options
  • Save ianpreston/86782003870dc0e43b38 to your computer and use it in GitHub Desktop.
Save ianpreston/86782003870dc0e43b38 to your computer and use it in GitHub Desktop.
OpenGL Hello World
#lang racket/gui
(require sgl)
(require sgl/gl-vectors)
(define (render canvas dc)
(send canvas with-gl-context
(lambda ()
(gl-matrix-mode 'projection)
(gl-load-identity)
(gl-ortho -10 10 -10 10 -1 1)
(gl-clear-color 0.0 0.0 0.0 0.0)
(gl-clear 'color-buffer-bit 'depth-buffer-bit)
(gl-begin 'triangles)
(gl-vertex 0 0 0)
(gl-vertex 0 5 0)
(gl-vertex 5 0 0)
(gl-end)
(send canvas swap-gl-buffers)
(gl-flush)
)))
(define frame (new frame%
[label "Example"]
[width 640]
[height 640]))
(new canvas% [parent frame]
[style '(gl)]
[paint-callback render])
(send frame show #t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment