diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index a6286af..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,17 +0,0 @@ -# Change Log - -## [0.1.4] - 2012-11-24 -### Added -* KTX file format -* Basic ETC1 support -* Simple makefile - -### Fixed -* Various DDS format fixes - -## [0.1.3] - 2012-04-26 -### Added -* Ported to Linux (tested on Ubuntu x86 w/Codeblocks). Note that a few features of the cmd line tool don't work yet (eg. -timestamp) - -[0.1.4]: https://github.com/BinomialLLC/crunch -[0.1.3]: https://github.com/BinomialLLC/crunch \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 507c6d0..be076b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(crunch VERSION "1.1.1") +project(Crunch2 VERSION "1.2.0") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake") diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..53917b9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing + +One of the easiest ways to contribute is to participate in discussions on GitHub issues. You can also contribute by +submitting pull requests with code changes. + +Please note we have a code of conduct, please follow it in all your interactions with the project. + +## General feedback, discussions, bugs and feature requests + +Start a discussion on the [issue tracker](https://github.com/FrozenStormInteractive/Crunch2/issues). + +## Pull Request Process + +Please first discuss the change you wish to make via issue, email, or any other method with the owners of this +repository before making a change. + +1. Ensure any install or build dependencies are removed before the end of the layer when doing a + build. +2. Update the README.md with details of changes to the interface, this includes new environment + variables, exposed ports, useful file locations and container parameters. +3. You may merge the Pull Request in once you have the sign-off of other developers, or if you + do not have permission to do that, you may request the second reviewer to merge it for you. + +## Code of Conduct + +This project has adopted the [Contributor Covenant Code of Conduct](https://github.com/FrozenStormInteractive/Code-of-Conduct/blob/master/CODE_OF_CONDUCT.md). diff --git a/README.md b/README.md index a2ed076..0fe6fdf 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@

- Crunch + Crunch 2

An advanced DXTn texture compression library

- Gitter - - - - - + Gitter + + + + +

@@ -18,7 +18,8 @@ * [Built Status](#built-status) * [Overview](#overview) -* [Building](#building) +* [Crunch2 VS Crunch](#crunch2-vs-crunch) +* [Installation](#installation) * [Usage](#usage) * [Examples](#examples) * [Known Issues / Bugs](#known-issues--bugs) @@ -34,10 +35,11 @@ ## Overview -crnlib is a lossy texture compression library for developers that ship -content using the DXT1/5/N or 3DC compressed color/normal map/cubemap -mipmapped texture formats. It was written by the same author as the open -source [LZHAM compression library](http://code.google.com/p/lzham/). +Crunch2 is a fork of crunch, a lossy texture compression tool and +library for developers that ship content using the DXT1/5/N or 3DC +compressed color/normal map/cubemapmipmapped texture formats. It was +written by the same author as the open source +[LZHAM compression library](http://code.google.com/p/lzham/). It can compress mipmapped 2D textures, normal maps, and cubemaps to approx. 1-1.25 bits/texel, and normal maps to 1.75-2 bits/texel. The @@ -144,21 +146,60 @@ found that support .KTX are fairly (to very) buggy, or are limited to only a han of pixel formats, so there's no guarantee that the .KTX files written by crnlib can be reliably read by other tools. -## Building +## Crunch2 VS Crunch -```sh -cmake -S . -B build -DCRN_BUILD_SHARED_LIBS=ON -``` +Crunch2 is a fork of crunch, the lossy texture compression tool +written by Richard Geldreich, Jr. -### Compile to Javascript with Emscripten +Crunch2 provides some features to its predecessor: + - Updates and bug fixes + - Shared library + - Support for Linux and macOS + - CI pipeline + - Easy build with [CMake](https://cmake.org) + - Dependency management with [Conan](https://conan.io) -Download and install Emscripten: - http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html +Crunch2 isn't a rewrite of crunch, just an improvement. Our main goal is to keep +the compatibility with the old crnlib API. -From the root directory, run: -```sh -emcc -O3 emscripten/crunch_lib.cpp -I./inc -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_crn_get_width', '_crn_get_height', '_crn_get_levels', '_crn_get_dxt_format', '_crn_get_bytes_per_block', '_crn_get_uncompressed_size', '_crn_decompress']" -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 -o crunch.js -``` +## Installation + +### From binary + +Download Crunch2 binary from [GitHub releases page](https://github.com/FrozenStormInteractive/Crunch2/releases). Each release provides binaries for Windows, Linux and macOS. + +### Building from source + + 1. Install the prerequisites. + - [CMake](https://cmake.org) + + 2. Download Crunch2 sources from [GitHub](https://github.com/FrozenStormInteractive/Crunch2/releases) and unpack the distribution archive somewhere on disk. + + 3. Generate build files with [CMake](https://cmake.org). + ```sh + cmake -S . -B build -DCRN_BUILD_SHARED_LIBS=ON + ``` + + 4. Build crunch2 with the generated build files or use [CMake](https://cmake.org). + ```sh + cmake --build build + ``` + + 5. (Optional) Export distribution files with install target or use [CMake](https://cmake.org) (You must provide `CMAKE_INSTALL_PREFIX`). + ```sh + cmake --install build + ``` + +#### Compile to Javascript with Emscripten + + 1. Download and install [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) + + 2. Download Crunch2 sources from [GitHub](https://github.com/FrozenStormInteractive/Crunch2/releases) and unpack the distribution archive somewhere on disk. + + 3. From the root directory, run: + ```sh + emcc -O3 emscripten/crunch_lib.cpp -I./inc -s EXPORTED_FUNCTIONS="['_malloc', '_free', '_crn_get_width', '_crn_get_height', '_crn_get_levels', '_crn_get_dxt_format', '_crn_get_bytes_per_block', '_crn_get_uncompressed_size', '_crn_decompress']" -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 -o crunch.js + ``` ## Usage @@ -324,25 +365,29 @@ compression is supported when writing to ETC1, and .CRN does not support ETC1. ## Contributing -Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. +Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, +and the process for submitting pull requests to us. ## License -This project is licensed under the Zlib License - see the [LICENSE.md](LICENSE.md) file for details +This project is licensed under the Zlib License - see the [LICENSE.md](LICENSE.md) file for details. -Copyright (C) 2010-2017 Richard Geldreich, Jr. and Binomial LLC http://binomial.info +``` +Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet +``` Portions of this software make use of public domain code originally -written by Igor Pavlov (LZMA), RYG (crn_ryg_dxt*), and Sean Barrett (stb_image.c). +written by Igor Pavlov (LZMA), and Sean Barrett (stb) and Fabian "ryg" Giesen (stb_dxt). -[Build Status Master Windows]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/master?stage=Build&job=Windows "Build Status Master Windows" -[Build Status Master Linux]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/master?stage=Build&job=Linux "Build Status Master Linux" -[Build Status Master macOS]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/master?stage=Build&job=macOS "Build Status Master macOS" -[Build Status Develop Windows]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/develop?stage=Build&job=Windows "Build Status Develop Windows" -[Build Status Develop Linux]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/develop?stage=Build&job=Linux "Build Status Develop Linux" -[Build Status Develop macOS]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/7/develop?stage=Build&job=macOS "Build Status Develop macOS" +[Build Status Master Windows]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/master?stage=Build&job=Windows "Build Status Master Windows" +[Build Status Master Linux]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/master?stage=Build&job=Linux "Build Status Master Linux" +[Build Status Master macOS]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/master?stage=Build&job=macOS "Build Status Master macOS" +[Build Status Develop Windows]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/develop?stage=Build&job=Windows "Build Status Develop Windows" +[Build Status Develop Linux]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/develop?stage=Build&job=Linux "Build Status Develop Linux" +[Build Status Develop macOS]: https://img.shields.io/azure-devops/build/FrozenStormInteractive/0e954e31-9ab2-40af-908f-dede5858bfed/8/develop?stage=Build&job=macOS "Build Status Develop macOS" -[Latest Master Build]: https://dev.azure.com/FrozenStormInteractive/Crunch/_build/latest?definitionId=7&branchName=master -[Latest Develop Build]: https://dev.azure.com/FrozenStormInteractive/Crunch/_build/latest?definitionId=7&branchName=develop +[Latest Master Build]: https://dev.azure.com/FrozenStormInteractive/Crunch2/_build/latest?definitionId=8&branchName=master +[Latest Develop Build]: https://dev.azure.com/FrozenStormInteractive/Crunch2/_build/latest?definitionId=8&branchName=develop diff --git a/conanfile.py b/conanfile.py index 7fa8621..504ef2e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,14 +1,16 @@ import os from conans import ConanFile, CMake, tools -class CrunchConan(ConanFile): - name = "crunch" +class Crunch2Conan(ConanFile): + name = "crunch2" description = "Advanced DXTc texture compression and transcoding library" - homepage = "https://github.com/FrozenStormInteractive/Crunch" - url = "https://github.com/FrozenStormInteractive/Crunch" + homepage = "https://github.com/FrozenStormInteractive/Crunch2" + url = "https://github.com/FrozenStormInteractive/Crunch2" license = "Zlib" topics = ("conan", "crunch", "texture", "compression", "decompression", "transcoding") settings = "os", "compiler", "arch", "build_type" + exports_sources = ["CMakeLists.txt", "license.txt", "crnlib/*", "crunch/*", "inc/*", "3rdparty/*"] + generators = "cmake" options = { "fPIC": [True, False], "shared": [True, False], @@ -17,9 +19,7 @@ class CrunchConan(ConanFile): "fPIC": True, "shared": False, } - exports_sources = ["CMakeLists.txt", "crnlib/*", "crunch/*", "inc/*", "3rdparty/*"] - generators = "cmake" - + _cmake = None @property @@ -48,7 +48,7 @@ def build(self): cmake.build() def package(self): - self.copy("LICENSE", src=self.source_folder, dst="licenses") + self.copy("license.txt", src=self.source_folder, dst="licenses") cmake = self._configure_cmake() cmake.install() diff --git a/crnlib/crn_core.cpp b/crnlib/crn_core.cpp index 6a95692..17ced81 100644 --- a/crnlib/crn_core.cpp +++ b/crnlib/crn_core.cpp @@ -1,13 +1,9 @@ // File: crn_core.cpp // See Copyright Notice and license at the end of inc/crnlib.h -#include "crn_core.h" -#if CRNLIB_USE_WIN32_API -#include "crn_winhdr.h" -#endif +#include "crn_core.h" -namespace crnlib { -const char* g_copyright_str = "Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC"; -const char* g_sig_str = "C8cfRlaorj0wLtnMSxrBJxTC85rho2L9hUZKHcBL"; +namespace crnlib +{ } // namespace crnlib diff --git a/crunch/crunch.cpp b/crunch/crunch.cpp index 8e6cb41..bdf691e 100644 --- a/crunch/crunch.cpp +++ b/crunch/crunch.cpp @@ -88,8 +88,6 @@ class crunch console::printf("-file @list.txt - List of files to convert."); console::printf("Supported source file formats: dds,ktx,crn,tga,bmp,png,jpg/jpeg,psd"); console::printf("Note: Some file format variants are unsupported."); - console::printf("See the docs for stb_image.c: http://www.nothings.org/stb_image.c"); - console::printf("Progressive JPEG files are supported, see: http://code.google.com/p/jpeg-compressor/"); console::message("\nPath/file related parameters:"); console::printf("-out filename - Output filename"); @@ -189,7 +187,7 @@ class crunch console::printf("-%s", pixel_format_helpers::get_pixel_format_string(fmt)); } - console::printf("\nFor bugs, support, or feedback: info@binomial.info"); + console::printf("\nFor bugs, support, or feedback: https://github.com/FrozenStormInteractive/Crunch2"); } bool convert(const char* pCommand_line) @@ -1410,8 +1408,11 @@ static bool check_for_option(int argc, char* argv[], const char* pOption) static void print_title() { - console::printf("crunch: Advanced DXTn Texture Compressor - https://github.com/BinomialLLC/crunch"); + console::printf("crunch - Advanced DXTn Texture Compressor - https://github.com/FrozenStormInteractive/Crunch2"); + console::printf(""); console::printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC"); + console::printf("Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet"); + console::printf(""); console::printf("crnlib version %s %s Built %s, %s", crn_get_version(), crnlib_is_x64() ? "x64" : "x86", __DATE__, __TIME__); console::printf(""); } @@ -1432,6 +1433,17 @@ static int main_internal(int argc, char* argv[]) print_title(); + if (check_for_option(argc, argv, "version")) + { + return EXIT_SUCCESS; + } + + if (check_for_option(argc, argv, "help")) + { + crunch::print_usage(); + return EXIT_SUCCESS; + } + dynamic_string cmd_line; get_command_line_as_single_string(cmd_line, argc, argv); diff --git a/examples/example1/example1.cpp b/examples/example1/example1.cpp index ef91d14..8cc3bc6 100644 --- a/examples/example1/example1.cpp +++ b/examples/example1/example1.cpp @@ -37,6 +37,7 @@ const int cDefaultCRNQualityLevel = 128; static int print_usage() { printf("Description: Simple crnlib API example program.\n"); printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC\n"); + printf("Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet\n"); printf("Usage: example1 [mode: i/c/d] [source_file] [options]\n"); printf("\nModes:\n"); printf("c: Compress to .DDS or .CRN using the crn_compress() func. in crnlib.h\n"); diff --git a/examples/example2/example2.cpp b/examples/example2/example2.cpp index 84ae342..83d46ae 100644 --- a/examples/example2/example2.cpp +++ b/examples/example2/example2.cpp @@ -24,6 +24,7 @@ using namespace crnlib; static int print_usage() { printf("Description: Transcodes .CRN to .DDS files using crn_decomp.h.\n"); printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC\n"); + printf("Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet\n"); printf("Usage: example2 [source_file] [options]\n"); printf("\nOptions:\n"); printf("-out filename - Force output filename.\n"); diff --git a/examples/example3/example3.cpp b/examples/example3/example3.cpp index b4e5b20..864a08c 100644 --- a/examples/example3/example3.cpp +++ b/examples/example3/example3.cpp @@ -34,7 +34,8 @@ const unsigned int cDXTBlockSize = 4; static int print_usage() { printf("Description: Simple .DDS DXTn block compression using crnlib.\n"); - printf("Copyright (c) 2010-2016 Binomial LLC\n"); + printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC\n"); + printf("Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet\n"); printf("Usage: example3 [source_file] [options]\n"); printf("\n"); printf("Note: This simple example is not multithreaded, so it's not going to be\n"); diff --git a/inc/crn_decomp.h b/inc/crn_decomp.h index 02944e3..340ce5b 100644 --- a/inc/crn_decomp.h +++ b/inc/crn_decomp.h @@ -1,5 +1,6 @@ // File: crn_decomp.h - Fast CRN->DXTc texture transcoder header file library // Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +// Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet // See Copyright Notice and license at the end of this file. // // This single header file contains *all* of the code necessary to unpack .CRN files to raw DXTn bits. @@ -3813,6 +3814,7 @@ bool crnd_unpack_end(crnd_unpack_context pContext) { // http://opensource.org/licenses/Zlib // // Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +// Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages diff --git a/inc/crnlib.h b/inc/crnlib.h index f7dee77..bfbf9b0 100644 --- a/inc/crnlib.h +++ b/inc/crnlib.h @@ -1,5 +1,6 @@ // File: crnlib.h - Advanced DXTn texture compression library. // Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +// Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet // See copyright notice and license at the end of this file. // // This header file contains the public crnlib declarations for DXTn, @@ -630,6 +631,7 @@ CRN_EXPORT int crn_get_version_patch(); // http://opensource.org/licenses/Zlib // // Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +// Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages diff --git a/license.txt b/license.txt index 7ab882a..ddd487f 100644 --- a/license.txt +++ b/license.txt @@ -1,21 +1,22 @@ -zlib License - -Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - -3. This notice may not be removed or altered from any source distribution. +zlib License + +Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC +Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation or credits + is required. + +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 9d3a208..b86fd5e 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -12,6 +12,5 @@ def build(self): def test(self): if not tools.cross_building(self.settings, skip_x64_x86=True): - # TODO: Add help flag - # self.run("crunch", run_environment=True) + self.run("crunch -version", run_environment=True) self.run(os.path.join("bin", "test_package"), run_environment=True)