-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.bak
72 lines (57 loc) · 1.6 KB
/
test2.bak
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
#lang racket
(require (lib "gl.ss" "sgl")
(lib "gl-vectors.ss" "sgl")
(lib "class.ss")
(lib "mred.ss" "mred")
)
(define bm (read-bitmap "model1.jpeg"))
(define (sx-bitmap-new width height)
;(make-object bitmap% width height #f)
(let ((config (new gl-config%)))
(let* ((b (make-gl-bitmap width height config))
(dc (new bitmap-dc% (bitmap b)))
(gl (send dc get-gl-context)))
(send dc set-bitmap bm)
(display "gl: ")(display gl)(newline)
b)))
(define (resize w h)
(display "resize: ")
(sx-bitmap-new 100 100)
(glViewport 0 0 w h)
#t
)
(define (draw-opengl)
(display "draw: ")
(sx-bitmap-new 100 100)
(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)
(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)))
(sx-bitmap-new 100 100)
(send win show #t)