Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
intelligide committed Sep 1, 2020
2 parents 26adf95 + 53ff69f commit ce2022f
Show file tree
Hide file tree
Showing 14 changed files with 165 additions and 96 deletions.
17 changes: 0 additions & 17 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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).
115 changes: 80 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<h1 align="center">
Crunch
Crunch 2
</h1>

<h4 align="center">An advanced DXTn texture compression library</h4>

<p align="center">
<a href="https://github.com/FrozenStormInteractive/crunch/releases"><img src="https://img.shields.io/github/v/release/FrozenStormInteractive/crunch?sort=semver" alt="Gitter"></a>
<a href="https://github.com/FrozenStormInteractive/crunch/stargazers"><img src="https://img.shields.io/github/stars/FrozenStormInteractive/crunch.svg"></a>
<a href="https://github.com/FrozenStormInteractive/crunch/issues"><img src="https://img.shields.io/github/issues/FrozenStormInteractive/crunch.svg"></a>
<a href="https://github.com/FrozenStormInteractive/crunch/pulls"><img src="https://img.shields.io/github/issues-pr/FrozenStormInteractive/crunch"></a>
<a href="https://github.com/FrozenStormInteractive/crunch/graphs/contributors"><img src="https://img.shields.io/github/contributors-anon/FrozenStormInteractive/crunch.svg"></a>
<a href="https://github.com/FrozenStormInteractive/crunch/issues"><img src="https://img.shields.io/badge/contributions-welcome-orange.svg"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/releases"><img src="https://img.shields.io/github/v/release/FrozenStormInteractive/Crunch2?sort=semver" alt="Gitter"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/stargazers"><img src="https://img.shields.io/github/stars/FrozenStormInteractive/Crunch2.svg"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/issues"><img src="https://img.shields.io/github/issues/FrozenStormInteractive/Crunch2.svg"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/pulls"><img src="https://img.shields.io/github/issues-pr/FrozenStormInteractive/Crunch2"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/graphs/contributors"><img src="https://img.shields.io/github/contributors-anon/FrozenStormInteractive/Crunch2.svg"></a>
<a href="https://github.com/FrozenStormInteractive/Crunch2/issues"><img src="https://img.shields.io/badge/contributions-welcome-orange.svg"></a>
<a href="License.md"><img src="https://img.shields.io/badge/license-Zlib-blue.svg"></a>
</p>

## Table of Contents

* [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)
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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).

<!-- urls -->

[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
16 changes: 8 additions & 8 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -17,9 +19,7 @@ class CrunchConan(ConanFile):
"fPIC": True,
"shared": False,
}
exports_sources = ["CMakeLists.txt", "crnlib/*", "crunch/*", "inc/*", "3rdparty/*"]
generators = "cmake"


_cmake = None

@property
Expand Down Expand Up @@ -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()

Expand Down
10 changes: 3 additions & 7 deletions crnlib/crn_core.cpp
Original file line number Diff line number Diff line change
@@ -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
20 changes: 16 additions & 4 deletions crunch/crunch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -189,7 +187,7 @@ class crunch
console::printf("-%s", pixel_format_helpers::get_pixel_format_string(fmt));
}

console::printf("\nFor bugs, support, or feedback: [email protected]");
console::printf("\nFor bugs, support, or feedback: https://github.com/FrozenStormInteractive/Crunch2");
}

bool convert(const char* pCommand_line)
Expand Down Expand Up @@ -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("");
}
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions examples/example1/example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions examples/example2/example2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion examples/example3/example3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions inc/crn_decomp.h
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions inc/crnlib.h
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit ce2022f

Please sign in to comment.