|
3 | 3 | ;作者:evilbinary on 01/08/17. |
4 | 4 | ;邮箱:rootdebug@163.com |
5 | 5 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | | -(import (scheme) (glut) (gles1) (imgui) ) |
| 6 | +(import (scheme) (gui glut) (gui gles1) (gui imgui) ) |
7 | 7 | (define (draw-image) |
8 | | - (glut-init) |
| 8 | + (glut-init (lambda () |
| 9 | + (let ((texture-id (imgui-load-texture "/sdcard/org.evilbinary.chez/number.png")) |
| 10 | + (rotation 2.0) |
| 11 | + (square-vertices (glut-vector 'float |
| 12 | + (vector |
| 13 | + -0.2 -0.2 |
| 14 | + 0.2 -0.2 |
| 15 | + -0.2 0.2 |
| 16 | + 0.2 0.2 |
| 17 | + ))) |
| 18 | + (texture-array (glut-vector 'float |
| 19 | + (vector |
| 20 | + 0.0 1.0 |
| 21 | + 1.0 1.0 |
| 22 | + 0.0 0.0 |
| 23 | + 1.0 0.0) )) |
| 24 | + ) |
| 25 | + (glut-display (lambda() |
| 26 | + (glClearColor 0.5 0.5 0.5 1.0 ); |
| 27 | + (glClear GL_COLOR_BUFFER_BIT); |
| 28 | + (glRotatef rotation 0.0 0.0 0.1) |
| 29 | + ;;绘制矩形 |
| 30 | + (glEnable GL_TEXTURE_2D); // 启用纹理映射 |
| 31 | + (glBindTexture GL_TEXTURE_2D texture-id); |
| 32 | + (glEnableClientState GL_TEXTURE_COORD_ARRAY); |
| 33 | + |
| 34 | + (glEnableClientState GL_VERTEX_ARRAY); |
| 35 | + (glVertexPointer 2 GL_FLOAT 0 square-vertices); |
| 36 | + (glTexCoordPointer 2 GL_FLOAT 0 texture-array); |
| 37 | + (glDrawArrays GL_TRIANGLE_STRIP 0 4); |
| 38 | + (glDisableClientState GL_VERTEX_ARRAY) |
| 39 | + (glDisable GL_TEXTURE_2D) |
| 40 | + (glDisable GL_TEXTURE_COORD_ARRAY) |
| 41 | + |
| 42 | + ) |
| 43 | + ) |
| 44 | + |
| 45 | + ) |
| 46 | + )) |
9 | 47 |
|
10 | 48 | (glut-touch-event (lambda (type x y) |
11 | 49 | (glut-log (format "type ~a ~a ~a" type x y )) |
12 | 50 | )) |
13 | 51 | (glut-key-event (lambda (event) |
14 | 52 | (glut-log (format "event ~a" event)) |
15 | | - |
16 | | - )) |
17 | | - (let ((texture-id (imgui-load-texture "./number.png")) |
18 | | - (rotation 2.0) |
19 | | - (square-vertices (glut-vector 'float |
20 | | - (vector |
21 | | - -0.2 -0.2 |
22 | | - 0.2 -0.2 |
23 | | - -0.2 0.2 |
24 | | - 0.2 0.2 |
25 | | - ))) |
26 | | - (texture-array (glut-vector 'float |
27 | | - (vector |
28 | | - 0.0 1.0 |
29 | | - 1.0 1.0 |
30 | | - 0.0 0.0 |
31 | | - 1.0 0.0) )) |
32 | | - ) |
33 | | - (glut-display (lambda() |
34 | | - (glClearColor 0.5 0.5 0.5 1.0 ); |
35 | | - (glClear GL_COLOR_BUFFER_BIT); |
36 | | - (glRotatef rotation 0.0 0.0 0.1) |
37 | | - ;;绘制矩形 |
38 | | - (glEnable GL_TEXTURE_2D); // 启用纹理映射 |
39 | | - (glBindTexture GL_TEXTURE_2D texture-id); |
40 | | - (glEnableClientState GL_TEXTURE_COORD_ARRAY); |
| 53 | + (if (= 4 (glut-event-get event 'keycode )) |
| 54 | + (begin (imgui-exit) |
| 55 | + (glut-exit))) |
41 | 56 |
|
42 | | - (glEnableClientState GL_VERTEX_ARRAY); |
43 | | - (glVertexPointer 2 GL_FLOAT 0 square-vertices); |
44 | | - (glTexCoordPointer 2 GL_FLOAT 0 texture-array); |
45 | | - (glDrawArrays GL_TRIANGLE_STRIP 0 4); |
46 | | - (glDisableClientState GL_VERTEX_ARRAY) |
47 | | - (glDisable GL_TEXTURE_2D) |
48 | | - (glDisable GL_TEXTURE_COORD_ARRAY) |
49 | | - |
50 | | - ) |
51 | | - ) |
52 | | - |
53 | | - ) |
| 57 | + )) |
54 | 58 | (glut-reshape (lambda(w h) |
55 | 59 | (glut-log (format "reshape")) |
56 | 60 | (glClearDepthf 1.0) |
|
0 commit comments