-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdrawer.rkt
102 lines (80 loc) · 2.16 KB
/
drawer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#lang racket/gui
(require (lib "gl.ss" "sgl")
(lib "gl-vectors.ss" "sgl")
)
(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)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)
(glMatrixMode GL_MODELVIEW)
(glLoadIdentity)
(glBegin GL_QUADS)
(glColor3d 0.0 1.0 0.0)
(glVertex3d 0.25 0.25 0.0)
(glColor3d 1.0 0.0 0.0)
(glVertex3d 0.75 0.25 0.0)
(glColor3d 1.0 1.0 1.0)
(glVertex3d 0.75 0.75 0.0)
(glColor3d 0.0 0.0 1.0)
(glVertex3d 0.25 0.75 0.0)
(glEnd)
)
(define count
(let ((c 0))
(lambda () (set! c ( + 1 c)) c)
)
)
(define (environ drawer)
#;(printf "in environ\n")
(define my-canvas%
(class* canvas% ()
(inherit with-gl-context swap-gl-buffers)
(define/override (on-paint)
(printf "on-paint ~s~n" (count))
(with-gl-context
(lambda ()
#;(printf "call drawer~n")
(drawer)
#;(printf "returned from drawer~n")
(swap-gl-buffers)
)
)
)
(define/override (on-size width height)
(with-gl-context
(lambda ()
(resize width height)
)
)
)
(super-instantiate () (style '(gl)))
)
)
#;(printf "before win~n")
(define win (new frame% (label "OpenGl Test") (min-width 600) (min-height 600)))
#;(printf "before my-canvas~n")
(define gl (new my-canvas% (parent win)))
#;(printf "before show~n")
(send win show #t) ; presumably this runs the on-paint method
#;(printf "out-environ~n")
)
#;(define win (new frame% (label "OpenGl Test") (min-width 200) (min-height 200)))
#;(define gl (new my-canvas% (parent win)))
#;(send win show #t)
#;(environ draw-opengl)
(provide environ)
;It should be pretty easy to tweak it.
;Hope this helps,
;Laurent
;- show quoted text -
; - show quoted text -
; _________________________________________________
; For list-related administrative tasks:
; http://lists.racket-lang.org/listinfo/users