Skip to content

Commit

Permalink
v2.0 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
evilbinary committed Mar 19, 2017
1 parent 2836162 commit 765fb08
Show file tree
Hide file tree
Showing 92 changed files with 35,285 additions and 518 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -10,6 +10,12 @@ TARGET =bin/scheme
SOFILES= lib/libscm/libscm.so \
lib/libglut/libglut.so \
lib/libimgui/libimgui.so \
lib/libffi/libffi.so \
lib/libglfw/libglfw.so \
lib/libgl/libgles.so \
lib/libffi/libffi.so \
lib/libnanovg/libnanovg.so \
lib/libgui/libgui.so \
lib/scheme/scheme \
lib/boot/scheme.boot \
lib/boot/petite.boot \
Expand Down
2 changes: 1 addition & 1 deletion apps/calc.ss
Expand Up @@ -2,7 +2,7 @@
;作者:evilbinary on 11/19/16.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme) (gui gles1) (gui glut) (gui imgui) )
(import (scheme) (gles gles1) (glut glut) (gui imgui) )



Expand Down
81 changes: 81 additions & 0 deletions apps/cffi-test.ss
@@ -0,0 +1,81 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;作者:evilbinary on 11/19/16.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(import (scheme) (cffi cffi) )


; (ffi-dl-test)
(load-librarys "foo.so")


; (display "============test-normal============\n")

; (def-function floating "floating" (int float double double) int )
; (def-function foovv "foo_vv" () void )
; (def-function foop "foo_p" (void*) void )
; (def-function foo-string "foo_string" (string) void )
; (def-function foo-string-string "foo_string_string" (string) string )

; (time (display (floating 6 3.141590 0.333333 2.718282) ) )
; (time (display (foovv ) ) )
; (time (display (foo-string "hello,world")))
; (time (display (foo-string-string "hello,world")))

; (display "============test-normal============end\n\n")


;;test struct
(display "============test-struct============\n")
(def-struct A
(c char 64 )
(d double 64 )
(i int 64 )
)
(display "def-struct end\n")

(define a (make-A 10 20.0 30 ) )
(display (format "make-A ~a end\n" a) )


(display "make-A\n")
(define b (make-A) )
(display "make-A --end\n")

;(define-top-level-value 'aa make-A)
(display "define-top-level-value end \n")

;((syntax->datum `,(string->symbol "make-A") ) )

;( string->procedure "make-A")
;(display (format "top-level-value======~a\n" ((top-level-value 'make-A ) ) ))



(display a)(newline)


(display (A-c a) )(newline)
(A-c-set! a 17)
(display (A-c a) )(newline)
;(display a)(newline)
;(display (record-type-descriptor? (type-descriptor A)) )
(def-function struct1 "struct1" (A) A)
; (set! b (struct1 a) )

(time (display (struct1 a)))


(display "============test-struct============end \n\n")

; (display (slot-value a uc) )
; (newline)
; (display (slot-value a d) )


; (let loop ()
; (time (cffi-call) )

; )

6 changes: 3 additions & 3 deletions apps/dominos.ss
Expand Up @@ -15,8 +15,8 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(import (rnrs)
(gui gles1)
(gui glut)
(gles gles1)
(glut glut)
(dharmalab misc limit-call-rate)
(agave glamour misc)
(agave glamour window)
Expand All @@ -37,7 +37,7 @@
(title "Box2d Lite - Dominos")
(reshape (width height)
(lambda (w h)
(glViewport 0 0 w h)
(glViewport 0 0 (* w 2) (* 2 h));retina support *2
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
(glScalef 0.1 0.1 1.0)
Expand Down
23 changes: 16 additions & 7 deletions apps/draw-image.ss
Expand Up @@ -3,10 +3,19 @@
;作者:evilbinary on 01/08/17.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme) (gui glut) (gui gles1) (gui imgui) )
(import (scheme) (glut glut) (gles gles1) (gui imgui) )
;;资源文件目录设置
(define res-dir
(case (machine-type)
((arm32le) "/data/data/org.evilbinary.chez/files/")
(else "./")
))

(define (draw-image)
(glut-init (lambda ()
(let ((texture-id (imgui-load-texture "/sdcard/org.evilbinary.chez/number.png"))
(let (
; (texture-id 0)
(texture-id (imgui-load-texture (string-append res-dir "/test2.jpg")))
(rotation 2.0)
(square-vertices (glut-vector 'float
(vector
Expand Down Expand Up @@ -57,11 +66,11 @@
))
(glut-reshape (lambda(w h)
(glut-log (format "reshape"))
(glClearDepthf 1.0)
(glClearColor 0.0 0.0 0.0 0.0 )
(glViewport 0 0 w h)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
; (glClearDepthf 1.0)
; (glClearColor 0.0 0.0 0.0 0.0 )
; (glViewport 0 0 w h)
; (glMatrixMode GL_PROJECTION)
; (glLoadIdentity)

))
(glut-main-loop)
Expand Down
2 changes: 1 addition & 1 deletion apps/draw-point.ss
Expand Up @@ -2,7 +2,7 @@
;作者:evilbinary on 11/19/16.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme) (gui gles1) (gui glut) (gui imgui) )
(import (scheme) (gles gles1) (glut glut) (gui imgui) )
(define (gl-draw-point)
(define gx 0)
(define gy 0)
Expand Down
22 changes: 18 additions & 4 deletions apps/game-plane.ss
Expand Up @@ -3,8 +3,8 @@
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme)
(gui gles1)
(gui glut)
(gles gles1)
(glut glut)
(gui imgui)
(utils libutil)
(box2d-lite util math)
Expand All @@ -16,6 +16,8 @@
(box2d-lite arbiter)
(dharmalab misc is-vector)
(box2d-lite contact)
(sound alut)
(sound al)


)
Expand Down Expand Up @@ -48,6 +50,8 @@
(else "./")
))

(define bgmusic (string-append res-dir "game_bg.wav"))
(define shot-snd (string-append res-dir "bullet.wav" ))
(define (draw-img texture-id vec)
(let ((texture-array (glut-vector 'float
(vector
Expand Down Expand Up @@ -358,6 +362,14 @@
; (list p3 (create-plane 0.0 0.0 0.0 0.9) )
; (list p2 (create-plane 0.0 0.0 0.0 0.9) )
))
(alut-init )
;bg music
(let ((buffer (alut-create-buffer-from-file bgmusic))
(source (al-gen-source 1 ) ))
(al-source-i source AL-BUFFER buffer)
(al-source-i source AL-LOOPING AL-TRUE)
(al-source-play source)
)

)

Expand Down Expand Up @@ -404,6 +416,7 @@
(115 (set! deltay -0.01))
(32 (let ((l (create-bullet x (+ y 0.12) 2.0 0.0003 shot 1)))
(append! objects (list l) )
(alut-play-file shot-snd)
))
)
(begin
Expand Down Expand Up @@ -484,18 +497,19 @@

(glut-reshape (lambda(w h)
(imgui-resize w h)
(glut-log (format "reshape"))
(glut-log (format "reshape ~a ~a" w h))
(glClearDepthf 1.0)
(glClearColor 0.0 0.0 0.0 0.0 )
(glFrontFace GL_CCW);
(glEnable GL_BLEND);
(glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA);
(glViewport 0 0 w h)
;(glViewport 0 0 w h)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
))
(glut-main-loop)
(imgui-exit)
(alut-exit)
(glut-exit)
)

Expand Down
6 changes: 3 additions & 3 deletions apps/gl-demo.ss
Expand Up @@ -3,7 +3,7 @@
;作者:evilbinary on 12/24/16.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme) (gui glut) (gui gles1))
(import (scheme) (glut glut) (gles gles1))
;opengles1.x 例子
(define (gl-demo)
(define rotation 0.0)
Expand Down Expand Up @@ -112,12 +112,12 @@
;(gl-disable GL-DEPTH-TEST)
(glClearDepthf 1.0)
(glClearColor 0.0 0.0 0.0 0.0 )
(glViewport 0 0 w h)
;(glViewport 0 0 w h)
(glMatrixMode GL_PROJECTION)
(glLoadIdentity)
;(glutPrespective 45.0 (* 1.0 (/ w h)) 0.1 100.0)
;(gl-color-texture-reset)
;(glOrthof 0.0 0.0 480.0 480.0 -1.0 1.0)
;(glOrthof 0.0 0.0 w h -1.0 1.0)
;(glMatrixMode GL_MODELVIEW)
;(glLoadIdentity)
;(glEnable GL_LINE_SMOOTH)
Expand Down
92 changes: 92 additions & 0 deletions apps/glfw-test.ss
@@ -0,0 +1,92 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Copyright 2016-2080 evilbinary.
;作者:evilbinary on 12/24/16.
;邮箱:rootdebug@163.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(import (scheme) (glfw glfw) (gui imgui) (gles gles1) (glut glut) (utils libutil) (utils macro) )

(define window '() )
;;资源文件目录设置
(define res-dir
(case (machine-type)
((arm32le) "/data/data/org.evilbinary.chez/files/")
(else "")
))


(define (glfw-test)
(glfw-init)
(set! window (glfw-create-window 640 480 "Simple example" 0 0) )
(glfw-window-hint GLFW_DEPTH_BITS 16);
; (glfw-window-hint GLFW_CONTEXT_VERSION_MAJOR 1);
; (glfw-window-hint GLFW_CONTEXT_VERSION_MINOR 0);

(glfw-make-context-current window);

(display (glad-load-gles1-loader (get-glfw-get-proc-address) ) )

(glfw-swap-interval 1);

(glfw-set-cursor-pos-callback window
(glfw-make-cursor-pos-callback
(lambda (w x y)
(display (format "w=~x ~x ~a,~a\n" w window x y ))
;(glfw-swap-buffers w)
)
))

(glfw-set-key-callback window
(glfw-make-key-callback
(lambda (w k s a m)
(display (format "w=~x key=~a scancode=~a action=~a mods=~a\n" w k s a m))
)
))


;(display (format "procedure?=~a" (procedure? mouse-callback) ) )

(let (
(rotation 2.0)
(texture-id (imgui-load-texture (string-append res-dir "number.png")))
(square-vertices (glut-vector 'float
(vector
-0.2 -0.2
0.2 -0.2
-0.2 0.2
0.2 0.2
)))
(texture-array (glut-vector 'float
(vector
0.0 1.0
1.0 1.0
0.0 0.0
1.0 0.0) ))
)
(while (= (glfw-window-should-close window) 0)
;(glClearColor 1.0 0.0 0.0 1.0 )

(glClear (+ GL_DEPTH_BUFFER_BIT GL_COLOR_BUFFER_BIT))

(glRotatef rotation 0.0 0.0 0.1)
(glEnable GL_TEXTURE_2D); // 启用纹理映射
(glBindTexture GL_TEXTURE_2D texture-id);
(glEnableClientState GL_TEXTURE_COORD_ARRAY);

(glEnableClientState GL_VERTEX_ARRAY);
(glVertexPointer 2 GL_FLOAT 0 square-vertices);
(glTexCoordPointer 2 GL_FLOAT 0 texture-array);
(glDrawArrays GL_TRIANGLE_STRIP 0 4);
(glDisableClientState GL_VERTEX_ARRAY)
(glDisable GL_TEXTURE_2D)
(glDisable GL_TEXTURE_COORD_ARRAY)


(glfw-swap-buffers window)
(glfw-poll-events)
))
(glfw-destroy-window window);
(glfw-terminate)

)

(glfw-test)

0 comments on commit 765fb08

Please sign in to comment.