Compare commits
	
		
			No commits in common. "main" and "1.0.0" have entirely different histories. 
		
	
	
		| 
						 | 
				
			
			@ -10,14 +10,13 @@ steps:
 | 
			
		|||
    - cd ./build
 | 
			
		||||
    - cmake -DCMAKE_C_COMPILER=/usr/bin/clang -S .. -B .
 | 
			
		||||
    - make
 | 
			
		||||
    - mv ./cramcli ./cramcli-linux-amd64
 | 
			
		||||
 | 
			
		||||
- name: build-windows
 | 
			
		||||
  image: thatcosmonaut/moonworks-build
 | 
			
		||||
  commands:
 | 
			
		||||
    - cmake -E make_directory ./windows-build
 | 
			
		||||
    - cd ./windows-build
 | 
			
		||||
    - mingw64-cmake -DBUILD_SHARED_LIBS=OFF -S .. -B .
 | 
			
		||||
    - mingw64-cmake -S .. -B .
 | 
			
		||||
    - make
 | 
			
		||||
 | 
			
		||||
- name: gitea_release
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +26,7 @@ steps:
 | 
			
		|||
    api_key:
 | 
			
		||||
      from_secret: gitea_token
 | 
			
		||||
    files:
 | 
			
		||||
      - ./build/cramcli-linux-amd64
 | 
			
		||||
      - ./build/cramcli
 | 
			
		||||
      - ./windows-build/cramcli.exe
 | 
			
		||||
  when:
 | 
			
		||||
    event: tag
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,8 +5,8 @@ option(BUILD_CLI "Build command line executable" ON)
 | 
			
		|||
option(BUILD_SHARED_LIBS "Build shared library" OFF)
 | 
			
		||||
 | 
			
		||||
SET(LIB_MAJOR_VERSION "1")
 | 
			
		||||
SET(LIB_MINOR_VERSION "1")
 | 
			
		||||
SET(LIB_REVISION "1")
 | 
			
		||||
SET(LIB_MINOR_VERSION "0")
 | 
			
		||||
SET(LIB_REVISION "0")
 | 
			
		||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
 | 
			
		||||
 | 
			
		||||
# Build Type
 | 
			
		||||
| 
						 | 
				
			
			@ -56,12 +56,6 @@ if(BUILD_SHARED_LIBS)
 | 
			
		|||
	set(LINKSTYLE PUBLIC)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_SHARED_LIBS)
 | 
			
		||||
	add_library(Cram SHARED ${SOURCE_FILES})
 | 
			
		||||
else()
 | 
			
		||||
	add_library(Cram STATIC ${SOURCE_FILES})
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_CLI)
 | 
			
		||||
	file(GLOB CLI_SOURCES
 | 
			
		||||
		tools/cli/lib/stb_image_write.h
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +80,11 @@ if(BUILD_CLI)
 | 
			
		|||
	endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(BUILD_SHARED_LIBS)
 | 
			
		||||
	add_library(Cram SHARED ${SOURCE_FILES})
 | 
			
		||||
else()
 | 
			
		||||
	add_library(Cram STATIC ${SOURCE_FILES})
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# Build flags
 | 
			
		||||
if(NOT MSVC)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,15 +11,13 @@ Cram ships with a default command line interface implemented in C, but if you wi
 | 
			
		|||
Command Line Usage
 | 
			
		||||
-----
 | 
			
		||||
```sh
 | 
			
		||||
Usage: cramcli input_dir output_dir atlas_name [--padding padding_value] [--premultiply] [--notrim] [--dimension max_dimension]
 | 
			
		||||
Usage: cramcli input_dir output_dir atlas_name [--padding padding_value] [--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.
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
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,10 +54,6 @@
 | 
			
		|||
#define SEPARATOR '/'
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __APPLE__
 | 
			
		||||
#define SEPARATOR '/'
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef max
 | 
			
		||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -72,8 +68,8 @@ extern "C"
 | 
			
		|||
#endif /* __cplusplus */
 | 
			
		||||
 | 
			
		||||
#define CRAM_MAJOR_VERSION 1
 | 
			
		||||
#define CRAM_MINOR_VERSION 1
 | 
			
		||||
#define CRAM_PATCH_VERSION 1
 | 
			
		||||
#define CRAM_MINOR_VERSION 0
 | 
			
		||||
#define CRAM_PATCH_VERSION 0
 | 
			
		||||
 | 
			
		||||
#define CRAM_COMPILED_VERSION ( \
 | 
			
		||||
	(CRAM_MAJOR_VERSION * 100 * 100) + \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ static void dirwalk(char *dir)
 | 
			
		|||
 | 
			
		||||
void print_help()
 | 
			
		||||
{
 | 
			
		||||
	fprintf(stdout, "Usage: cram input_dir output_dir atlas_name [--padding padding_value] [--premultiply] [--notrim] [--dimension max_dimension]");
 | 
			
		||||
	fprintf(stdout, "Usage: cram input_dir output_dir atlas_name [--padding padding_value] [--notrim] [--dimension max_dimension]");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t check_dir_exists(char *path)
 | 
			
		||||
| 
						 | 
				
			
			@ -137,8 +137,6 @@ int main(int argc, char *argv[])
 | 
			
		|||
	uint8_t *pixelData;
 | 
			
		||||
	int32_t width;
 | 
			
		||||
	int32_t height;
 | 
			
		||||
	uint8_t premultiply;
 | 
			
		||||
	uint8_t alpha;
 | 
			
		||||
	char *arg;
 | 
			
		||||
	char *inputDirPath = NULL;
 | 
			
		||||
	char *outputDirPath = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +156,6 @@ int main(int argc, char *argv[])
 | 
			
		|||
	createInfo.trim = 1;
 | 
			
		||||
	createInfo.maxDimension = 8192;
 | 
			
		||||
	createInfo.name = NULL;
 | 
			
		||||
	premultiply = 0;
 | 
			
		||||
 | 
			
		||||
	if (argc < 2)
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -180,10 +177,6 @@ int main(int argc, char *argv[])
 | 
			
		|||
				return 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else if (strcmp(arg, "--premultiply") == 0)
 | 
			
		||||
		{
 | 
			
		||||
			premultiply = 1;
 | 
			
		||||
		}
 | 
			
		||||
		else if (strcmp(arg, "--notrim") == 0)
 | 
			
		||||
		{
 | 
			
		||||
			createInfo.trim = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -252,19 +245,6 @@ int main(int argc, char *argv[])
 | 
			
		|||
	/* output pixel data */
 | 
			
		||||
 | 
			
		||||
	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);
 | 
			
		||||
	strcpy(imageOutputFilename, outputDirPath);
 | 
			
		||||
	strcat(imageOutputFilename, separatorString);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue