Skip to content
Myr

fix to new bc5 path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent def6a18 · Browse files · 1 file+6 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:stb_dxt.h+6 added-5 removed
1// stb_dxt.h - v1.05 - DXT1/DXT5 compressor - public domain1// stb_dxt.h - v1.06 - DXT1/DXT5 compressor - public domain2// original by fabian "ryg" giesen - ported to C by stb3// use '#define STB_DXT_IMPLEMENTATION' before including to create the implementation4//5// USAGE:
2 unmodified lines
8// A is ignored if you specify alpha=0; you can turn on dithering9// and "high quality" using mode.10//11// version history:12// v1.06 - (stb) fix to known-broken 1.0513// v1.05 - (stb) support bc5/3dc (Arvids Kokins), use extern "C" in C++ (Pavel Krajcevski)14// v1.04 - (ryg) default to no rounding bias for lerped colors (as per S3TC/DX10 spec);15// single color match fix (allow for inexact color interpolation);16// optimal DXT5 index finder; "high quality" mode that runs multiple refinement steps.
18 unmodified lines
35extern "C" {36#endif3738void stb_compress_dxt_block(unsigned char *dest, const unsigned char *src_rgba_four_bytes_per_pixel, int alpha, int mode);38void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel, int mode);39void stb_compress_bc5_block(unsigned char *dest, const unsigned char *src_rg_two_byte_per_pixel);4041#ifdef __cplusplus42}43#endif
509 unmodified lines
553 int i,dist,bias,dist4,dist2,bits,mask;554555 // find min/max color556 int mn,mx;556 mn = mx = src[3];557 mn = mx = src[0];558559 for (i=1;i<16;i++)560 {560 if (src[i*4+3] < mn) mn = src[i*4+3];561 else if (src[i*4+3] > mx) mx = src[i*4+3];561 if (src[i*stride] < mn) mn = src[i*stride];562 else if (src[i*stride] > mx) mx = src[i*stride];563 }564565 // encode them566 ((unsigned char *)dest)[0] = mx;
121 unmodified lines