Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
cosmonaut | c0dbc791e6 | |
cosmonaut | 08ac44514e | |
cosmonaut | 8c32994d4f | |
cosmonaut | fe1f334223 | |
cosmonaut | 613fffcf6b | |
cosmonaut | 597d8628d7 | |
cosmonaut | 05ffce873b |
|
@ -10,13 +10,14 @@ steps:
|
||||||
- cd ./build
|
- cd ./build
|
||||||
- cmake -DCMAKE_C_COMPILER=/usr/bin/clang -S .. -B .
|
- cmake -DCMAKE_C_COMPILER=/usr/bin/clang -S .. -B .
|
||||||
- make
|
- make
|
||||||
|
- mv ./cramcli ./cramcli-linux-amd64
|
||||||
|
|
||||||
- name: build-windows
|
- name: build-windows
|
||||||
image: thatcosmonaut/moonworks-build
|
image: thatcosmonaut/moonworks-build
|
||||||
commands:
|
commands:
|
||||||
- cmake -E make_directory ./windows-build
|
- cmake -E make_directory ./windows-build
|
||||||
- cd ./windows-build
|
- cd ./windows-build
|
||||||
- mingw64-cmake -S .. -B .
|
- mingw64-cmake -DBUILD_SHARED_LIBS=OFF -S .. -B .
|
||||||
- make
|
- make
|
||||||
|
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
|
@ -26,7 +27,7 @@ steps:
|
||||||
api_key:
|
api_key:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
files:
|
files:
|
||||||
- ./build/cramcli
|
- ./build/cramcli-linux-amd64
|
||||||
- ./windows-build/cramcli.exe
|
- ./windows-build/cramcli.exe
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
|
|
|
@ -5,8 +5,8 @@ option(BUILD_CLI "Build command line executable" ON)
|
||||||
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
||||||
|
|
||||||
SET(LIB_MAJOR_VERSION "1")
|
SET(LIB_MAJOR_VERSION "1")
|
||||||
SET(LIB_MINOR_VERSION "0")
|
SET(LIB_MINOR_VERSION "1")
|
||||||
SET(LIB_REVISION "0")
|
SET(LIB_REVISION "1")
|
||||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
|
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
|
||||||
|
|
||||||
# Build Type
|
# Build Type
|
||||||
|
@ -56,6 +56,12 @@ if(BUILD_SHARED_LIBS)
|
||||||
set(LINKSTYLE PUBLIC)
|
set(LINKSTYLE PUBLIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_library(Cram SHARED ${SOURCE_FILES})
|
||||||
|
else()
|
||||||
|
add_library(Cram STATIC ${SOURCE_FILES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_CLI)
|
if(BUILD_CLI)
|
||||||
file(GLOB CLI_SOURCES
|
file(GLOB CLI_SOURCES
|
||||||
tools/cli/lib/stb_image_write.h
|
tools/cli/lib/stb_image_write.h
|
||||||
|
@ -80,11 +86,6 @@ if(BUILD_CLI)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
add_library(Cram SHARED ${SOURCE_FILES})
|
|
||||||
else()
|
|
||||||
add_library(Cram STATIC ${SOURCE_FILES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Build flags
|
# Build flags
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
|
|
@ -11,13 +11,15 @@ Cram ships with a default command line interface implemented in C, but if you wi
|
||||||
Command Line Usage
|
Command Line Usage
|
||||||
-----
|
-----
|
||||||
```sh
|
```sh
|
||||||
Usage: cramcli input_dir output_dir atlas_name [--padding padding_value] [--notrim] [--dimension max_dimension]
|
Usage: cramcli input_dir output_dir atlas_name [--padding padding_value] [--premultiply] [--notrim] [--dimension max_dimension]
|
||||||
```
|
```
|
||||||
|
|
||||||
Cram CLI expects input images to be in PNG format and will output a PNG and a JSON metadata file that you can use to properly display the images in your game. Cram will recursively walk all the subdirectories of `input_dir` to generate your texture atlas.
|
Cram CLI expects input images to be in PNG format and will output a PNG and a JSON metadata file that you can use to properly display the images in your game. Cram will recursively walk all the subdirectories of `input_dir` to generate your texture atlas.
|
||||||
|
|
||||||
Padding is set to 0 by default. If you need to use linear filtering, set padding to at least 1. If you need to use texture compression, set padding to at least 4.
|
Padding is set to 0 by default. If you need to use linear filtering, set padding to at least 1. If you need to use texture compression, set padding to at least 4.
|
||||||
|
|
||||||
|
Premultiply is off by default. If you will be using linear filtering on these images, you should turn this on or you will get strange artifacts.
|
||||||
|
|
||||||
Trimming is on by default. Use `--notrim` if for some weird reason you want it off.
|
Trimming is on by default. Use `--notrim` if for some weird reason you want it off.
|
||||||
|
|
||||||
Max dimension value is set to 8192 by default since that is a common max texture size for basically every GPU out there. Use `--dimension [max_dimension]` to override this maximum.
|
Max dimension value is set to 8192 by default since that is a common max texture size for basically every GPU out there. Use `--dimension [max_dimension]` to override this maximum.
|
||||||
|
|
|
@ -54,6 +54,10 @@
|
||||||
#define SEPARATOR '/'
|
#define SEPARATOR '/'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define SEPARATOR '/'
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,8 +72,8 @@ extern "C"
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#define CRAM_MAJOR_VERSION 1
|
#define CRAM_MAJOR_VERSION 1
|
||||||
#define CRAM_MINOR_VERSION 0
|
#define CRAM_MINOR_VERSION 1
|
||||||
#define CRAM_PATCH_VERSION 0
|
#define CRAM_PATCH_VERSION 1
|
||||||
|
|
||||||
#define CRAM_COMPILED_VERSION ( \
|
#define CRAM_COMPILED_VERSION ( \
|
||||||
(CRAM_MAJOR_VERSION * 100 * 100) + \
|
(CRAM_MAJOR_VERSION * 100 * 100) + \
|
||||||
|
|
|
@ -89,7 +89,7 @@ static void dirwalk(char *dir)
|
||||||
|
|
||||||
void print_help()
|
void print_help()
|
||||||
{
|
{
|
||||||
fprintf(stdout, "Usage: cram input_dir output_dir atlas_name [--padding padding_value] [--notrim] [--dimension max_dimension]");
|
fprintf(stdout, "Usage: cram input_dir output_dir atlas_name [--padding padding_value] [--premultiply] [--notrim] [--dimension max_dimension]");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t check_dir_exists(char *path)
|
uint8_t check_dir_exists(char *path)
|
||||||
|
@ -137,6 +137,8 @@ int main(int argc, char *argv[])
|
||||||
uint8_t *pixelData;
|
uint8_t *pixelData;
|
||||||
int32_t width;
|
int32_t width;
|
||||||
int32_t height;
|
int32_t height;
|
||||||
|
uint8_t premultiply;
|
||||||
|
uint8_t alpha;
|
||||||
char *arg;
|
char *arg;
|
||||||
char *inputDirPath = NULL;
|
char *inputDirPath = NULL;
|
||||||
char *outputDirPath = NULL;
|
char *outputDirPath = NULL;
|
||||||
|
@ -156,6 +158,7 @@ int main(int argc, char *argv[])
|
||||||
createInfo.trim = 1;
|
createInfo.trim = 1;
|
||||||
createInfo.maxDimension = 8192;
|
createInfo.maxDimension = 8192;
|
||||||
createInfo.name = NULL;
|
createInfo.name = NULL;
|
||||||
|
premultiply = 0;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
|
@ -177,6 +180,10 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp(arg, "--premultiply") == 0)
|
||||||
|
{
|
||||||
|
premultiply = 1;
|
||||||
|
}
|
||||||
else if (strcmp(arg, "--notrim") == 0)
|
else if (strcmp(arg, "--notrim") == 0)
|
||||||
{
|
{
|
||||||
createInfo.trim = 0;
|
createInfo.trim = 0;
|
||||||
|
@ -245,6 +252,19 @@ int main(int argc, char *argv[])
|
||||||
/* output pixel data */
|
/* output pixel data */
|
||||||
|
|
||||||
Cram_GetPixelData(context, &pixelData, &width, &height);
|
Cram_GetPixelData(context, &pixelData, &width, &height);
|
||||||
|
|
||||||
|
if (premultiply)
|
||||||
|
{
|
||||||
|
for (i = 0; i < width * height * 4; i += 4)
|
||||||
|
{
|
||||||
|
alpha = pixelData[i + 3];
|
||||||
|
|
||||||
|
pixelData[i + 0] = (uint8_t) (((uint32_t) (pixelData[i + 0]) * alpha) / 255);
|
||||||
|
pixelData[i + 1] = (uint8_t) (((uint32_t) (pixelData[i + 1]) * alpha) / 255);
|
||||||
|
pixelData[i + 2] = (uint8_t) (((uint32_t) (pixelData[i + 2]) * alpha) / 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
imageOutputFilename = malloc(strlen(outputDirPath) + strlen(createInfo.name) + 6);
|
imageOutputFilename = malloc(strlen(outputDirPath) + strlen(createInfo.name) + 6);
|
||||||
strcpy(imageOutputFilename, outputDirPath);
|
strcpy(imageOutputFilename, outputDirPath);
|
||||||
strcat(imageOutputFilename, separatorString);
|
strcat(imageOutputFilename, separatorString);
|
||||||
|
|
Loading…
Reference in New Issue