Created
January 10, 2015 17:27
-
-
Save ianpreston/86782003870dc0e43b38 to your computer and use it in GitHub Desktop.
OpenGL Hello World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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