auto penger
This commit is contained in:
parent
362f83d4c7
commit
61bf9df50c
|
@ -1,2 +1,4 @@
|
|||
app.wasm
|
||||
app.wat
|
||||
png2c
|
||||
penger.c
|
||||
|
|
6
app.c
6
app.c
|
@ -79,9 +79,9 @@ void go(float dt)
|
|||
}
|
||||
|
||||
v2 penger_origin = {(float) width/2 - 32*scale()/2, (float) height/2 - 32*scale()/2};
|
||||
for (int i = 0; i < 32; i++) {
|
||||
for (int y = 0; y < 32; y++) {
|
||||
if (penger_img[i][y] == 0)
|
||||
for (int i = 0; i < penger_height; i++) {
|
||||
for (int y = 0; y < penger_width; y++) {
|
||||
if (penger_img[i][y] <= 0x00FFFFFF)
|
||||
continue;
|
||||
for (int s1 = 0; s1 < scale(); s1++) {
|
||||
for (int s2 = 0; s2 < scale(); s2++) {
|
||||
|
|
15
build.sh
15
build.sh
|
@ -6,8 +6,19 @@ for e in $export_sym; do
|
|||
export_cmd="$export_cmd -Wl,--export=$e";
|
||||
done;
|
||||
|
||||
f=$(echo $1 | sed "s/\..*$//g")
|
||||
if [[ "$1" == "" ]]; then
|
||||
f='app'
|
||||
e='app.c'
|
||||
else
|
||||
f=$(echo $1 | sed "s/\..*$//g")
|
||||
e=$1
|
||||
fi
|
||||
|
||||
clang -O2 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o $f.wasm $1
|
||||
set -xe
|
||||
|
||||
clang png2c.c -o png2c -lm
|
||||
./png2c "penger.png" > penger.c
|
||||
|
||||
clang -O2 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o $f.wasm $e
|
||||
|
||||
wasm2wat $f.wasm > $f.wat
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,36 @@
|
|||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stdout, "usage: %s <image path>\n", argv[0]);
|
||||
fprintf(stderr, "ERROR: no image provided\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *img_path = argv[1];
|
||||
|
||||
int width, height, n;
|
||||
unsigned int *data = (unsigned int*)stbi_load(img_path, &width, &height, &n, 4);
|
||||
|
||||
if (n != 4) {
|
||||
fprintf(stderr, "ERROR: n components is not 4\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("int penger_height = %d;\n", height);
|
||||
printf("int penger_width = %d;\n", width);
|
||||
printf("unsigned int penger_img[%d][%d] = {\n", height, width);
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
printf(" ");
|
||||
for (int i = 0; i < width; i++) {
|
||||
printf("0x%08X,", data[y*height + i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue