Update dependencies, refresh README.md, add build scripts for linux(& macos?)
This commit is contained in:
parent
3f1c523ad9
commit
faf42da522
12 changed files with 53 additions and 158 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "vendors/odin-aseprite"]
|
||||||
|
path = vendors/odin-aseprite
|
||||||
|
url = git@github.com:blob1807/odin-aseprite.git
|
||||||
31
.vscode/launch.json
vendored
31
.vscode/launch.json
vendored
|
|
@ -1,31 +0,0 @@
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "cppvsdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "Build Debug",
|
|
||||||
"name": "Debug",
|
|
||||||
"program": "${workspaceFolder}/build/game_debug.exe",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "cppvsdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "Build Release",
|
|
||||||
"name": "Release",
|
|
||||||
"program": "${workspaceFolder}/game_release.exe",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "cppvsdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Run File",
|
|
||||||
"program": "odin",
|
|
||||||
"args": ["run", "${fileBasename}", "-file"],
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"[odin]": {
|
|
||||||
"editor.formatOnSave": true,
|
|
||||||
"editor.tabSize": 4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
92
.vscode/tasks.json
vendored
92
.vscode/tasks.json
vendored
|
|
@ -1,92 +0,0 @@
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"command": "",
|
|
||||||
"args": [],
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "Build Debug",
|
|
||||||
"type": "shell",
|
|
||||||
"windows": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_debug.bat"
|
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_debug.sh"
|
|
||||||
},
|
|
||||||
"osx": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_debug.sh"
|
|
||||||
},
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Build Release",
|
|
||||||
"type": "shell",
|
|
||||||
"windows": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_release.bat"
|
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_release.sh"
|
|
||||||
},
|
|
||||||
"osx": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_release.sh"
|
|
||||||
},
|
|
||||||
"group": "build"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Clean build folder(s)",
|
|
||||||
"type": "shell",
|
|
||||||
"windows": {
|
|
||||||
"command": "cd ${workspaceFolder}\\build && rm game*; cd ${workspaceFolder} && rm aseprite_odin_generator*"
|
|
||||||
},
|
|
||||||
"group": "build"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Build Hot Reload",
|
|
||||||
"type": "shell",
|
|
||||||
"windows": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_hot_reload.bat; start game.exe"
|
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_hot_reload.sh"
|
|
||||||
},
|
|
||||||
"osx": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_hot_reload.sh"
|
|
||||||
},
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": false,
|
|
||||||
"panel": "dedicated",
|
|
||||||
"showReuseMessage": false,
|
|
||||||
"clear": true
|
|
||||||
},
|
|
||||||
"group": "build",
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Build&Run Atlas Generator Test",
|
|
||||||
"type": "shell",
|
|
||||||
"windows": {
|
|
||||||
"command": "${workspaceFolder}/scripts/build_generator_debug.bat && build_generator\\aseprite_odin_generator.exe -input-files:value_of_custom_arg -h"
|
|
||||||
},
|
|
||||||
"options": {
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
},
|
|
||||||
"presentation": {
|
|
||||||
"echo": true,
|
|
||||||
"reveal": "always",
|
|
||||||
"focus": false,
|
|
||||||
"panel": "dedicated",
|
|
||||||
"showReuseMessage": false,
|
|
||||||
"clear": true
|
|
||||||
},
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
31
README.md
31
README.md
|
|
@ -1,20 +1,29 @@
|
||||||
|
|
||||||
# YAAP
|
# YAAP
|
||||||
Yet-Another-Atlas-Packer by Stefan Stefanov
|
Yet-Another-Atlas-Packer by bersK (Stefan Stefanov)
|
||||||
|
|
||||||
|
## Usage & requirements
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> Pull this repo with `--recursive`, the `odin-aseprite` library is pulled in as a submodule.
|
||||||
|
|
||||||
|
* At least odin compiler version `dev-2025-07:204edd0fc`
|
||||||
|
* Build the `libtinyfiledialog` library in the `vendors/dialog` fold
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
> [!NOTE]
|
||||||
|
> Quite frankly if you want automatic atlas packing I would suggest using `stb_rect_pack` directly & an aseprite plugin for exporting your assets in a proper format for packing. Using this atlas packer in an automated fashion is not quite possible and slower as a workflow. I would only use it for experiment projects or places where having a built in atlas packer is not practical.
|
||||||
|
|
||||||
Simple atlas packer for .aseprite files. Generates metadata and potentially embeds in an output source file of your choosing.
|
Simple atlas packer for `.aseprite` files. Generates a packed png & metadata in the form of json and/or source files(cpp, odin, etc...).
|
||||||
|
> [!CAUTION]
|
||||||
|
> Does not handle palette files currently.
|
||||||
|
|
||||||
Uses `stb_rect_pack` from the `stb` family of header libraries & `raylib` for rendering/UI. Here's a quick preview on [youtube](https://youtu.be/4_dKq7G57Lw) of the application.
|
Uses `stb_rect_pack` for the image packing & `raylib` for the UI.
|
||||||
|
|
||||||
<a href="https://youtu.be/4_dKq7G57Lw">
|
A quick preview on [youtube](https://youtu.be/4_dKq7G57Lw).
|
||||||
<img src="https://raw.githubusercontent.com/bersK/yaap/master/repo_assets/image.png" />
|
|
||||||
<a/>
|
|
||||||
|
|
||||||
The goal of the tool is to take in multiple aseprite files and pack them into a single atlas, outputting metadata in the process in the form of
|
<img src="https://raw.githubusercontent.com/bersK/yaap/master/repo_assets/image.png" />
|
||||||
JSON and/or source files for direct use in odin (or other languages through a customization file).
|
|
||||||
|
|
||||||
I'm using a library for marshalling the aseprite files found [here](https://github.com/blob1807/odin-aseprite) on github.
|
## Dependencies
|
||||||
|
* odin-aseprite [github](https://github.com/blob1807/odin-aseprite)
|
||||||
Project template provided by Karl Zylinski found [here](https://github.com/karl-zylinski/odin-raylib-hot-reload-game-template) on github.
|
* raylib (`vendor/raylib`, [link](https://github.com/odin-lang/Odin/tree/master/vendor/raylib))
|
||||||
|
* stb_rect_pack (`vendor/stb/rect_pack`, [link](https://github.com/odin-lang/Odin/tree/master/vendor/stb/rect_pack))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import ase "../vendors/aseprite"
|
import ase "../../vendors/odin-aseprite"
|
||||||
import "core:encoding/json"
|
import "core:encoding/json"
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
|
|
|
||||||
5
scripts/build.sh
Normal file
5
scripts/build.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
FLAGS="-define:RAYLIB_SHARED=true -out:build/yaap -debug"
|
||||||
|
SRC=src/frontend
|
||||||
|
|
||||||
|
mkdir -p build
|
||||||
|
odin build ${SRC} ${FLAGS}
|
||||||
7
scripts/setup.sh
Normal file
7
scripts/setup.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pushd vendors/dialog
|
||||||
|
sh build.sh
|
||||||
|
popd
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package generator
|
package generator
|
||||||
|
|
||||||
import ase "../../vendors/aseprite"
|
import ase "../../vendors/odin-aseprite"
|
||||||
import "core:encoding/json"
|
import "core:encoding/json"
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:log"
|
import "core:log"
|
||||||
|
|
@ -115,7 +115,7 @@ unmarshall_aseprite_files :: proc(
|
||||||
if extension != ".aseprite" do continue
|
if extension != ".aseprite" do continue
|
||||||
|
|
||||||
log.infof("Unmarshalling file: ", file)
|
log.infof("Unmarshalling file: ", file)
|
||||||
ase.unmarshal_from_filename(file, &aseprite_document, alloc)
|
ase.unmarshal_from_filename(&aseprite_document, file)
|
||||||
atlas_entry := atlas_entry_from_compressed_cells(aseprite_document)
|
atlas_entry := atlas_entry_from_compressed_cells(aseprite_document)
|
||||||
atlas_entry.path = file
|
atlas_entry.path = file
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ atlas_entry_from_compressed_cells :: proc(document: ase.Document) -> (atlas_entr
|
||||||
|
|
||||||
cell := CellData {
|
cell := CellData {
|
||||||
img = rl.Image {
|
img = rl.Image {
|
||||||
data = rawptr(&cel_img.pixel[0]),
|
data = rawptr(&cel_img.pixels[0]),
|
||||||
width = auto_cast cel_img.width,
|
width = auto_cast cel_img.width,
|
||||||
height = auto_cast cel_img.height,
|
height = auto_cast cel_img.height,
|
||||||
format = .UNCOMPRESSED_R8G8B8A8,
|
format = .UNCOMPRESSED_R8G8B8A8,
|
||||||
|
|
@ -277,7 +277,7 @@ pack_atlas_entries :: proc(
|
||||||
}
|
}
|
||||||
cell_metadata := SpriteAtlasMetadata {
|
cell_metadata := SpriteAtlasMetadata {
|
||||||
name = cell_name,
|
name = cell_name,
|
||||||
location = {
|
location = {
|
||||||
auto_cast rect.x + auto_cast offset_x,
|
auto_cast rect.x + auto_cast offset_x,
|
||||||
auto_cast rect.y + auto_cast offset_y,
|
auto_cast rect.y + auto_cast offset_y,
|
||||||
},
|
},
|
||||||
|
|
@ -290,23 +290,23 @@ pack_atlas_entries :: proc(
|
||||||
}
|
}
|
||||||
|
|
||||||
odin_source_generator_metadata := SourceCodeGeneratorMetadata {
|
odin_source_generator_metadata := SourceCodeGeneratorMetadata {
|
||||||
file_defines = {
|
file_defines = {
|
||||||
top = "package atlas_bindings\n\n",
|
top = "package atlas_bindings\n\n",
|
||||||
bottom = "",
|
bottom = "",
|
||||||
file_name = "metadata",
|
file_name = "metadata",
|
||||||
file_extension = ".odin",
|
file_extension = ".odin",
|
||||||
},
|
},
|
||||||
custom_data_type = {
|
custom_data_type = {
|
||||||
name = "AtlasRect",
|
name = "AtlasRect",
|
||||||
type_declaration = "%v :: struct {{ x, y, w, h: i32 }}\n\n",
|
type_declaration = "%v :: struct {{ x, y, w, h: i32 }}\n\n",
|
||||||
},
|
},
|
||||||
enum_data = {
|
enum_data = {
|
||||||
name = "AtlasEnum",
|
name = "AtlasEnum",
|
||||||
begin_line = "%v :: enum {{\n",
|
begin_line = "%v :: enum {{\n",
|
||||||
entry_line = "\t%s,\n",
|
entry_line = "\t%s,\n",
|
||||||
end_line = "}\n\n",
|
end_line = "}\n\n",
|
||||||
},
|
},
|
||||||
array_data = {
|
array_data = {
|
||||||
name = "ATLAS_SPRITES",
|
name = "ATLAS_SPRITES",
|
||||||
type = "[]AtlasRect",
|
type = "[]AtlasRect",
|
||||||
begin_line = "%v := %v {{\n",
|
begin_line = "%v := %v {{\n",
|
||||||
|
|
@ -318,23 +318,23 @@ odin_source_generator_metadata := SourceCodeGeneratorMetadata {
|
||||||
|
|
||||||
|
|
||||||
cpp_source_generator_metadata := SourceCodeGeneratorMetadata {
|
cpp_source_generator_metadata := SourceCodeGeneratorMetadata {
|
||||||
file_defines = {
|
file_defines = {
|
||||||
top = "#include <iostream>\n\n",
|
top = "#include <iostream>\n\n",
|
||||||
bottom = "",
|
bottom = "",
|
||||||
file_name = "metadata",
|
file_name = "metadata",
|
||||||
file_extension = ".hpp",
|
file_extension = ".hpp",
|
||||||
},
|
},
|
||||||
custom_data_type = {
|
custom_data_type = {
|
||||||
name = "AtlasRect",
|
name = "AtlasRect",
|
||||||
type_declaration = "struct %v {{\n\tint x;\n\tint y;\n\tint w;\n\tint h;\n}};\n\n",
|
type_declaration = "struct %v {{\n\tint x;\n\tint y;\n\tint w;\n\tint h;\n}};\n\n",
|
||||||
},
|
},
|
||||||
enum_data = {
|
enum_data = {
|
||||||
name = "AtlasEnum",
|
name = "AtlasEnum",
|
||||||
begin_line = "enum %v {{\n",
|
begin_line = "enum %v {{\n",
|
||||||
entry_line = "\t%s,\n",
|
entry_line = "\t%s,\n",
|
||||||
end_line = "\n\tCOUNT\n}\n\n",
|
end_line = "\n\tCOUNT\n}\n\n",
|
||||||
},
|
},
|
||||||
array_data = {
|
array_data = {
|
||||||
name = "ATLAS_SPRITES",
|
name = "ATLAS_SPRITES",
|
||||||
type = "AtlasRect[size_t(AtlasEnum::COUNT)-1]",
|
type = "AtlasRect[size_t(AtlasEnum::COUNT)-1]",
|
||||||
begin_line = "{1} {0} = {{\n",
|
begin_line = "{1} {0} = {{\n",
|
||||||
|
|
@ -516,7 +516,7 @@ save_metadata_simple :: proc(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata, ok := atlas_metadata.([dynamic]SpriteAtlasMetadata);if !ok {
|
metadata, ok := atlas_metadata.([dynamic]SpriteAtlasMetadata); if !ok {
|
||||||
log.error("No metadata to export!")
|
log.error("No metadata to export!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,7 +542,7 @@ save_metadata_simple :: proc(
|
||||||
|
|
||||||
source_metadata := strings.to_string(sb)
|
source_metadata := strings.to_string(sb)
|
||||||
source_output_path := strings.concatenate(
|
source_output_path := strings.concatenate(
|
||||||
{
|
{
|
||||||
output_path,
|
output_path,
|
||||||
OS_FILE_SEPARATOR,
|
OS_FILE_SEPARATOR,
|
||||||
codegen.file_defines.file_name,
|
codegen.file_defines.file_name,
|
||||||
|
|
@ -573,7 +573,7 @@ save_metadata :: proc(
|
||||||
atlas_entries: []AtlasEntry,
|
atlas_entries: []AtlasEntry,
|
||||||
atlas_metadata: []SpriteAtlasMetadata,
|
atlas_metadata: []SpriteAtlasMetadata,
|
||||||
) {
|
) {
|
||||||
metadata, ok := settings.metadata.(CLIMetadataSettings);if !ok do return
|
metadata, ok := settings.metadata.(CLIMetadataSettings); if !ok do return
|
||||||
|
|
||||||
if json_path, ok := metadata.json_path.(string); ok {
|
if json_path, ok := metadata.json_path.(string); ok {
|
||||||
json_bytes, jerr := json.marshal(atlas_metadata)
|
json_bytes, jerr := json.marshal(atlas_metadata)
|
||||||
|
|
|
||||||
1
vendors/aseprite
vendored
1
vendors/aseprite
vendored
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 628e655661d822fecae67cf238cbfa414912d943
|
|
||||||
2
vendors/dialog/build.sh
vendored
2
vendors/dialog/build.sh
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
gcc ./libtinyfiledialogs/tinyfiledialogs.c -c -o libtinyfiledialogs.o
|
gcc ./libtinyfiledialogs/tinyfiledialogs.c -c -o libtinyfiledialogs.o
|
||||||
|
|
||||||
|
|
|
||||||
1
vendors/odin-aseprite
vendored
Submodule
1
vendors/odin-aseprite
vendored
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 72ea2e8094a5f05074d4c4f2faafdba42e54673c
|
||||||
Loading…
Add table
Add a link
Reference in a new issue