Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of changes. Added support for Native images, TGA, Crunched DXT.
- Loading branch information
Brandon Jones
committed
Apr 29, 2012
1 parent
60a2a00
commit 17a0bf9
Showing
33 changed files
with
19,819 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
node requirejs/r.js -o name=requirejs/almond.js include=texture-util/export out=build/texture-util.js baseUrl=. wrap=true |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Crunch | ||
========= | ||
|
||
crn_decomp.h and crlib.h are part of the Crunch texture compression library by Rich Geldreich, (http://www-cs-students.stanford.edu/~eparker/files/crunch/decode_test.html) | ||
|
||
crn.cpp is a modification of the original emscripten wrapper code by Evan Parker, (http://www-cs-students.stanford.edu/~eparker/files/crunch/decode_test.html) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
lli=${LLVMINTERP-lli} | ||
exec $lli \ | ||
/var/folders/34/y7wmqjvx1zv89hn8sr16s1xc0000gn/T/tmp0Cf1nk/crn_decomp.bc ${1+"$@"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
rm ../texture-util/crn_decomp.js | ||
|
||
emcc \ | ||
-s EXPORTED_FUNCTIONS="['allocate', '_malloc', '_free', '_crn_get_width', '_crn_get_height', '_crn_get_levels', '_crn_get_dxt_format', '_crn_get_uncompressed_size', '_crn_decompress']" \ | ||
-O2 \ | ||
-o ../texture-util/crn_decomp.js \ | ||
crn.cpp && \ | ||
chmod -R a+rX . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#define PLATFORM_NACL | ||
|
||
#include <stddef.h> // For NULL, size_t | ||
#include <cstring> // for malloc etc | ||
|
||
#include "crn_decomp.h" | ||
|
||
extern "C" { | ||
unsigned int crn_get_width(void *src, unsigned int src_size); | ||
unsigned int crn_get_height(void *src, unsigned int src_size); | ||
unsigned int crn_get_levels(void *src, unsigned int src_size); | ||
unsigned int crn_get_dxt_format(void *src, unsigned int src_size); | ||
unsigned int crn_get_uncompressed_size(void *src, unsigned int src_size, unsigned int level_index); | ||
void crn_decompress(void *src, unsigned int src_size, void *dst, unsigned int dst_size, unsigned int level_index); | ||
} | ||
|
||
unsigned int crn_get_width(void *src, unsigned int src_size) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
return tex_info.m_width; | ||
} | ||
|
||
unsigned int crn_get_height(void *src, unsigned int src_size) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
return tex_info.m_height; | ||
} | ||
|
||
unsigned int crn_get_levels(void *src, unsigned int src_size) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
return tex_info.m_levels; | ||
} | ||
|
||
unsigned int crn_get_dxt_format(void *src, unsigned int src_size) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
return tex_info.m_format; | ||
} | ||
|
||
unsigned int crn_get_uncompressed_size(void *src, unsigned int src_size, unsigned int level_index) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
const crn_uint32 width = tex_info.m_width >> level_index; | ||
const crn_uint32 height = tex_info.m_height >> level_index; | ||
const crn_uint32 blocks_x = (width + 3) >> 2; | ||
const crn_uint32 blocks_y = (height + 3) >> 2; | ||
const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(tex_info.m_format); | ||
const crn_uint32 total_face_size = row_pitch * blocks_y; | ||
return total_face_size; | ||
} | ||
|
||
void crn_decompress(void *src, unsigned int src_size, void *dst, unsigned int dst_size, unsigned int level_index) { | ||
crnd::crn_texture_info tex_info; | ||
crnd::crnd_get_texture_info(static_cast<crn_uint8*>(src), src_size, &tex_info); | ||
const crn_uint32 width = tex_info.m_width >> level_index; | ||
const crn_uint32 height = tex_info.m_height >> level_index; | ||
const crn_uint32 blocks_x = (width + 3) >> 2; | ||
const crn_uint32 blocks_y = (height + 3) >> 2; | ||
const crn_uint32 row_pitch = blocks_x * crnd::crnd_get_bytes_per_dxt_block(tex_info.m_format); | ||
|
||
crnd::crnd_unpack_context pContext = | ||
crnd::crnd_unpack_begin(static_cast<crn_uint8*>(src), src_size); | ||
void *pDecomp_images[1]; | ||
pDecomp_images[0] = dst; | ||
crnd::crnd_unpack_level(pContext, pDecomp_images, dst_size, row_pitch, level_index); | ||
crnd::crnd_unpack_end(pContext); | ||
} |
Oops, something went wrong.