Texture Rendering #9
@@ -3,10 +3,6 @@ package draw_qr
|
|||||||
import draw ".."
|
import draw ".."
|
||||||
import "../../qrcode"
|
import "../../qrcode"
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Layer 1 — pure: encoded QR buffer → RGBA pixels + descriptor
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Returns the number of bytes to_texture will write for the given encoded
|
// Returns the number of bytes to_texture will write for the given encoded
|
||||||
// QR buffer. Equivalent to size*size*4 where size = qrcode.get_size(qrcode_buf).
|
// QR buffer. Equivalent to size*size*4 where size = qrcode.get_size(qrcode_buf).
|
||||||
texture_size :: #force_inline proc(qrcode_buf: []u8) -> int {
|
texture_size :: #force_inline proc(qrcode_buf: []u8) -> int {
|
||||||
@@ -59,10 +55,6 @@ to_texture :: proc(
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Layer 2 — raw: pre-encoded QR buffer → registered GPU texture
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Allocates pixel buffer via temp_allocator, decodes qrcode_buf into it, and
|
// Allocates pixel buffer via temp_allocator, decodes qrcode_buf into it, and
|
||||||
// registers with the GPU. The pixel allocation is freed before return.
|
// registers with the GPU. The pixel allocation is freed before return.
|
||||||
//
|
//
|
||||||
@@ -91,10 +83,6 @@ register_texture_from_raw :: proc(
|
|||||||
return draw.register_texture(desc, pixels)
|
return draw.register_texture(desc, pixels)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Layer 3 — text → registered GPU texture
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Encodes text as a QR Code and registers the result as an RGBA texture.
|
// Encodes text as a QR Code and registers the result as an RGBA texture.
|
||||||
//
|
//
|
||||||
// Returns ok=false when:
|
// Returns ok=false when:
|
||||||
@@ -134,10 +122,6 @@ register_texture_from_text :: proc(
|
|||||||
return register_texture_from_raw(qrcode_buf, dark, light, temp_allocator)
|
return register_texture_from_raw(qrcode_buf, dark, light, temp_allocator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Layer 4 — binary → registered GPU texture
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Encodes arbitrary binary data as a QR Code and registers the result as an RGBA texture.
|
// Encodes arbitrary binary data as a QR Code and registers the result as an RGBA texture.
|
||||||
//
|
//
|
||||||
// Returns ok=false when:
|
// Returns ok=false when:
|
||||||
@@ -177,10 +161,6 @@ register_texture_from_binary :: proc(
|
|||||||
return register_texture_from_raw(qrcode_buf, dark, light, temp_allocator)
|
return register_texture_from_raw(qrcode_buf, dark, light, temp_allocator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Clay integration helper
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Default fit=.Fit preserves the QR's square aspect; override as needed.
|
// Default fit=.Fit preserves the QR's square aspect; override as needed.
|
||||||
clay_image :: #force_inline proc(
|
clay_image :: #force_inline proc(
|
||||||
texture: draw.Texture_Id,
|
texture: draw.Texture_Id,
|
||||||
|
|||||||
Reference in New Issue
Block a user