X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela_draw.scm;h=f72c75142ecc314c7cb6adf98dd4e0a93c6c6d28;hb=ca3edcecf937f854c1b5d9eeac566d85dc749cd0;hp=184eba20b76348094b64ed3b1cc18b12737c16fa;hpb=e82142f2231e5aacf47e3f0cf5e82679d4291af2;p=gacela.git diff --git a/src/gacela_draw.scm b/src/gacela_draw.scm index 184eba2..f72c751 100644 --- a/src/gacela_draw.scm +++ b/src/gacela_draw.scm @@ -39,7 +39,8 @@ (glEnd)) (define (begin-draw number-of-points) - (cond ((= number-of-points 3) (glBegin GL_TRIANGLES)) + (cond ((= number-of-points 2) (glBegin GL_LINES)) + ((= number-of-points 3) (glBegin GL_TRIANGLES)) ((= number-of-points 4) (glBegin GL_QUADS)))) (define (draw-vertexes vertexes) @@ -59,9 +60,15 @@ (cond ((3d-mode?) (glVertex3f x y z)) (else (glVertex2f x y)))) -(define (load-image-for-texture filename) +(define (load-image filename) (init-sdl) (let ((image (IMG_Load filename))) + (cond (image + (SDL_DisplayFormatAlpha image))))) + +(define (load-image-for-texture filename) + (init-sdl) + (let ((image (load-image filename))) (cond (image (let* ((width (surface-w image)) (height (surface-h image)) (power-2 (nearest-power-of-two (min width height))) @@ -90,7 +97,7 @@ (texture (car (glGenTextures 1)))) (glBindTexture GL_TEXTURE_2D texture) - (glTexImage2D GL_TEXTURE_2D 0 3 width height 0 byteorder GL_UNSIGNED_BYTE (surface-pixels image)) + (glTexImage2D GL_TEXTURE_2D 0 4 width height 0 byteorder GL_UNSIGNED_BYTE (surface-pixels image)) (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER min-filter) (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER mag-filter) (set-texture-size! texture real-w real-h) @@ -106,6 +113,13 @@ (height (texture-h texture))) (draw-rectangle (* zoom width) (* zoom height) #:texture texture))))) +(define* (draw-line length #:optional color) + (let ((l (/ length 2))) + (cond (color + (with-color color (draw (list 0 l) (list 0 (- l))))) + (else + (draw (list 0 l) (list 0 (- l))))))) + (define* (draw-quad v1 v2 v3 v4 #:key texture color) (cond (texture (progn-textures