AtlatestRepositorysigil-studio
sigil-studio / tree / testtest-draw-texture.sgl
1
;;; test-draw-texture.sgl - Test texture rendering2
;;;3
;;; Opens a window and draws a test image to the screen.5
(import (sigil core)6
(sigil app)7
(sigil graphics))9
(display "Loading test image...\n")11
;; Load image (we'll load it before the app starts, then create texture in init)12
(define test-image-path "test/test-image.png")13
(define img (load-image test-image-path))15
(if (not img)16
(begin17
(display "ERROR: Could not load test image at: ")18
(display test-image-path)19
(display "\n")20
(display "Please ensure test/test-image.png exists.\n")21
1)22
(begin23
(display "Image loaded: ")24
(display (image-width img))25
(display "x")26
(display (image-height img))27
(display "\n")29
;; Variables to hold texture (will be set in init)30
(define tex #f)31
(define angle 0.0)33
;; Init callback - create GPU texture34
(define (on-init)35
(display "Initializing texture...\n")36
(set! tex (load-texture img))37
(if tex38
(begin39
(display "Texture created successfully!\n")40
;; Free CPU image data since we have GPU texture now41
(image-free! img))42
(display "ERROR: Failed to create texture!\n")))44
;; Frame callback - render45
(define (on-frame)46
(begin-frame)47
(clear-screen 0.2 0.2 0.3) ;; Dark blue-gray background48
(when tex49
;; Draw texture at fixed position (100, 100)50
(draw-texture tex 100 100))51
(end-frame))53
;; Cleanup callback54
(define (on-cleanup)55
(display "Cleaning up...\n"))57
;; Run the app58
(display "Starting app...\n")59
(app-run on-init60
on-frame61
on-cleanup62
"Texture Test"63
800 600)))