From fa6eebfbfd7f241787adf1dc099cbf9225db180e Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Tue, 12 Sep 2023 12:53:13 -0400 Subject: WIP: GLSL functions seem to compile OK --- play/Display_vk.tcl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/play/Display_vk.tcl b/play/Display_vk.tcl index f9012b5f..28186b98 100644 --- a/play/Display_vk.tcl +++ b/play/Display_vk.tcl @@ -809,7 +809,7 @@ namespace eval Gpu { $fnBody } } - }] "\n"]] + }]] "\n"] vec4 frag() { $[join [lmap field $pushConstants { @@ -1153,6 +1153,7 @@ namespace eval Gpu { proc glslc {args} { set cmdargs [lreplace $args end end] set glsl [lindex $args end] + puts "GLSL ($glsl)" set glslfd [file tempfile glslfile glslfile.glsl]; puts $glslfd $glsl; close $glslfd split [string map {\n ""} [exec glslc {*}$cmdargs -mfmt=num -o - $glslfile]] "," } @@ -1225,23 +1226,23 @@ if {[info exists ::argv0] && $::argv0 eq [info script] || \ return res; }] set image [Gpu::pipeline {sampler2D image vec2 a vec2 b vec2 c vec2 d} {invBilinear} { - float u = 0; - float v = 0; - return texture(samplers[image], vec2(u, v)); + vec2 p = gl_FragCoord.xy; + vec2 uv = invBilinear(p, a, b, c, d); + return texture(samplers[image], uv); }] # FIXME: bounding box for scissors # FIXME: sampler2D, text # set im [Gpu::ImageManager::copyImageToGpu [image rechannel [image loadJpeg "/Users/osnr/Downloads/u9.jpg"] 4]] - # set im2 [Gpu::ImageManager::copyImageToGpu [image rechannel [image loadJpeg "/Users/osnr/Downloads/793.jpg"] 4]] + set im2 [Gpu::ImageManager::copyImageToGpu [image rechannel [image loadJpeg "/Users/osnr/Downloads/793.jpg"] 4]] Gpu::drawStart - Gpu::draw $circle {200 50} 30 - Gpu::draw $circle {300 300} 20 - Gpu::draw $line {0 0} {100 100} 10 - Gpu::draw $redOnRight - # Gpu::draw $image $im2 {0 0} {200 0} {200 200} {0 200} + # Gpu::draw $circle {200 50} 30 + # Gpu::draw $circle {300 300} 20 + # Gpu::draw $line {0 0} {100 100} 10 + # Gpu::draw $redOnRight + Gpu::draw $image $im2 {0 0} {200 0} {200 200} {0 200} Gpu::draw $line {0 0} {200 0} 10 Gpu::draw $line {200 0} {200 200} 10 Gpu::draw $line {200 200} {0 200} 10 -- cgit v1.2.3