-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rkt
65 lines (49 loc) · 1.49 KB
/
test.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#lang racket/gui
(require (lib "gl.ss" "sgl")
(lib "gl-vectors.ss" "sgl")
sgl/bitmap
)
(define bm (read-bitmap "model1.jpeg"))
(define (resize w h)
(glViewport 0 0 w h)
#t)
(define (draw-opengl)
(glClearColor 0.0 0.0 0.0 0.0)
(glClear GL_COLOR_BUFFER_BIT)
(glColor3d 1.0 1.0 1.0)
#|
(let* ([config (new gl-config%)]
[text-target (make-gl-bitmap 11 11 config)]
[bm-dc (new bitmap-dc% [bitmap text-target])])
(send bm-dc draw-line -100 -100 100 100)
(send bm-dc draw-line -100 100 100 -100)
(display (send bm-dc get-gl-context))
(glCallList (bitmap->gl-list text-target)))
|#
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)
(glMatrixMode GL_MODELVIEW)
(glLoadIdentity)
(glBegin GL_QUADS)
(glVertex3d 0.25 0.25 0.0)
(glVertex3d 0.75 0.25 0.0)
(glVertex3d 0.75 0.75 0.0)
(glVertex3d 0.25 0.75 0.0)
(glEnd))
(define my-canvas%
(class* canvas% ()
(inherit with-gl-context swap-gl-buffers)
(define/override (on-paint)
(with-gl-context
(lambda ()
(draw-opengl)
(swap-gl-buffers))))
(define/override (on-size width height)
(with-gl-context
(lambda ()
(resize width height))))
(super-instantiate () (style '(gl)))))
(define win (new frame% (label "OpenGl Test") (min-width 200) (min-height 200)))
(define gl (new my-canvas% (parent win)))
(send win show #t)