BITMAP. BLITTED

This commit is contained in:
mehbark 2023-12-22 00:40:33 -05:00
parent f345c6f88d
commit b331907fa0
3 changed files with 96 additions and 8 deletions

View file

@ -16,12 +16,12 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1702780907, "lastModified": 1703068421,
"narHash": "sha256-blbrBBXjjZt6OKTcYX1jpe9SRof2P9ZYWPzq22tzXAA=", "narHash": "sha256-WSw5Faqlw75McIflnl5v7qVD/B3S2sLh+968bpOGrWA=",
"rev": "1e2e384c5b7c50dbf8e9c441a9e58d85f408b01f", "rev": "d65bceaee0fb1e64363f7871bc43dc1c6ecad99f",
"revCount": 553366, "revCount": 553492,
"type": "tarball", "type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.553366%2Brev-1e2e384c5b7c50dbf8e9c441a9e58d85f408b01f/018c7bfd-11b9-73fc-856e-ffc78346f98e/source.tar.gz" "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.553492%2Brev-d65bceaee0fb1e64363f7871bc43dc1c6ecad99f/018c8bd1-00df-7455-9e45-7867e2da314a/source.tar.gz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",

66
main.c
View file

@ -21,3 +21,69 @@ int main() {
return 0; return 0;
} }
void a(const char* path) {
printf("%s\n", path);
printf("%s\n", path);
}
Image b(const char* path) {
printf("%s\n", path);
Image img = LoadImage(path);
printf("%s\n", path);
return img;
}
const char *id(const char* str) {
return str;
}
FILE* fopen_wrapper(const char* path) {
FILE* file = fopen(path, "rb");
printf("file = %p and NULL = %p\n", file, NULL);
return file;
}
void println(const char* str) {
if (str == NULL) {
printf("got a null str :(\n");
return;
}
printf("%c\n", str[0]);
printf("%c\n", str[1]);
printf("%p\n", str);
printf("%c\n", str[0]);
printf("%c\n", str[1]);
printf("%c\n", str[2]);
printf("%c\n", str[3]);
printf("%c\n", str[4]);
printf("%c\n", str[5]);
printf("%s\n", str);
printf("%s\n", str);
}
// doesn't work. nice!
Image load_image(const char* path) {
// YES! the string is empty
// but why?
printf("%p: '%s'\n", path, path);
printf("'%c'\n", path[0]);
printf("'%c'\n", path[1]);
printf("'%c'\n", path[2]);
printf("'%c'\n", path[3]);
printf("'%c'\n", path[4]);
return LoadImage(path);
}
Image load_image2(const char* str) {
// YES! the string is empty
// but why?
printf("%s\n", str);
//printf("%p: '%s'\n", str, str);
/* printf("'%c'\n", str[0]); */
/* printf("'%c'\n", str[1]); */
/* printf("'%c'\n", str[2]); */
/* printf("'%c'\n", str[3]); */
/* printf("'%c'\n", str[4]); */
return LoadImage(str);
}

View file

@ -95,6 +95,7 @@
; texture ; texture
; shouldn't really need to use these structs, just pass them around ; shouldn't really need to use these structs, just pass them around
; which is what we could use void* for... oops.
(define-ftype Image (define-ftype Image
(struct (struct
[data void*] [data void*]
@ -151,11 +152,32 @@
(set-vector2-y! vec2 y) (set-vector2-y! vec2 y)
vec2) vec2)
; adapted from https://github.com/Yunoinsky/chez-raylib/blob/main/src/raylib.sls
(define load-image (define load-image
(foreign-procedure #f "LoadImage" (string) (* Image))) (let ([f (foreign-procedure #f "LoadImage"
(string)
(& Image))])
(case-lambda
[(file-name)
(let ([ret (make-ftype-pointer
Image
(foreign-alloc (ftype-sizeof Image)))])
(f ret file-name)
ret)]
[(struct file-name) (f struct file-name) struct])))
(define load-texture (define load-texture
(foreign-procedure #f "LoadTexture" (string) (* Texture2D))) (let ([f (foreign-procedure #f "LoadTexture"
(string)
(& Texture))])
(case-lambda
[(file-name)
(let ([ret (make-ftype-pointer
Texture
(foreign-alloc (ftype-sizeof Texture)))])
(f ret file-name)
ret)]
[(struct file-name) (f struct file-name) struct])))
(define unload-texture (define unload-texture
(foreign-procedure #f "UnloadTexture" ((& Texture2D)) void)) (foreign-procedure #f "UnloadTexture" ((& Texture2D)) void))
@ -225,5 +247,5 @@
(unload-texture skin) (unload-texture skin)
(close-window))) (close-window)))
;; (main) (main)