Skip to content

Commit 713d310

Browse files
committed
DEVELOPMENT: enable profile in glcore and add comment
1 parent ad86127 commit 713d310

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

modules/ln_glcore/glcore.scm

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,26 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737
|#
3838
;; Absolutely minimal OpenGL (ES) interface
3939

40-
(define glcore:debuglevel 0)
41-
(define (glcore:log level . x)
42-
(if (>= glcore:debuglevel level) (apply log-system (append (list "glcore: " x)))))
40+
;;* Compiletime
41+
42+
;#| ;; enable manually in source
43+
(define-cond-expand-feature profile)
44+
;;|#
45+
46+
(cond-expand
47+
(debug
48+
(define glcore:debuglevel 0)
49+
(define (glcore:log level . x)
50+
(if (>= glcore:debuglevel level) (apply log-system (append (list "glcore: " x))))))
51+
(else))
52+
53+
(cond-expand
54+
(profile ;; ignore even when otherwise in `debug` mode
55+
(define-macro (glcore:log . ignored) #!void))
56+
(debug) ;; defined by previous `debug` expansion
57+
(else (define-macro (glcore:log . ignored) #!void)))
58+
59+
;;* Runtime
4360

4461
;; ----------------------------------
4562
;; Initialization
@@ -405,14 +422,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
405422
(define (_glCoreTextureBind t)
406423
(glcore:log 5 "_glCoreTextureBind")
407424
(let ((entry (table-ref glCore:textures t #f)))
408-
(if entry (begin
409-
(if (not (vector-ref entry 0)) (_glCoreTextureInit t))
410-
(let ((tx (u32vector-ref (vector-ref entry 1) 0)))
411-
(if (not (= glCore:curtexture tx)) (begin
412-
(glBindTexture GL_TEXTURE_2D tx)
413-
(set! glCore:curtexture tx))))
414-
) (log-error "glCoreTextureBind: unbound index " t)
415-
)))
425+
(if entry
426+
(begin
427+
(unless (vector-ref entry 0) (_glCoreTextureInit t)) ;; cache texture `t`
428+
(let ((tx (u32vector-ref (vector-ref entry 1) 0)))
429+
(if (not (= glCore:curtexture tx))
430+
(begin
431+
(glBindTexture GL_TEXTURE_2D tx)
432+
(set! glCore:curtexture tx)))))
433+
(log-error "glCoreTextureBind: unbound index " t))))
416434

417435
(define (_glCoreTextureInit t)
418436
(glcore:log 5 "_glCoreTextureInit")

0 commit comments

Comments
 (0)