fix stbi_shiftsigned to be shifting a value that's unsigned
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 f1417ef · Browse files · 2 files·+10 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+10 added−4 removed
- tests:+7 added−2 removed
- other:+3 added−2 removed
Provenance
- Commit
84e42c2- Tree
9519d01- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent
f1417ef
2 files changed+10 added−4 removed
modified:tests/caveview/cave_mesher.c+7 added-2 removed
35 unmodified lines36 //#define FANCY_LEAVES // nearly 2x the triangles when enabled (if underground is filled)37 #define FAST_CHUNK38 #define IN_PLACE39 40+#define SKIP_TERRAIN 040-#define SKIP_TERRAIN 48 // use to avoid building underground stuff41+//#define SKIP_TERRAIN 48 // use to avoid building underground stuff42 // allows you to see what perf would be like if underground was efficiently culled,43 // or if you were making a game without underground44 45 enum85 unmodified lines131 { C_solid, 8,8,8,8,9,10 },132 { C_solid, 35,35,35,35,4,4, },133 134 // 48134- { C_solid, 36,36,36,36,36,36 },135+ //{ C_solid, 36,36,36,36,36,36 },136+ { C_force, 36,36,36,36,36,36 },137 { C_solid, 37,37,37,37,37,37 },138 { C_cross, 80,80,80,80,80,80 }, // torch139 { C_empty }, // fire140 { C_trans, 65,65,65,65,65,65 },2 unmodified lines143 { C_empty }, // redstone144 145 // 56146 { C_solid, 50,50,50,50,50,50 },147+ //{ C_force, 50,50,50,50,50,50 },148 { C_solid, 26,26,26,26,26,26 },149 { C_solid, 60,59,59,59,43,43 },150 { C_cross, 95,95,95,95 },151 { C_solid, 2,2,2,2,86,2 },681 unmodified lines833 minecraft_color_for_blocktype[18][i] = 39 | 64; // green834 minecraft_color_for_blocktype[161][i] = 37 | 64; // green835 minecraft_color_for_blocktype[10][i] = 63; // emissive lava836 minecraft_color_for_blocktype[11][i] = 63; // emissive837+ //minecraft_color_for_blocktype[56][i] = 63; // emissive diamond838+ minecraft_color_for_blocktype[48][i] = 63; // emissive dungeon839 }840 841 #ifdef VHEIGHT_TEST842 effective_blocktype[168] = 168;91 unmodified linesmodified:stb_image.h+3 added-2 removed
4958 unmodified lines4959 a = (a + (a >> 16)); // max 32 per 8 bits4960 return a & 0xff;4961 }4962 4963-static int stbi__shiftsigned(int v, int shift, int bits)4963+static unsigned int stbi__shiftsigned(unsigned int v, int shift, int bits)4964 {4965 int result;4966 int z=0;4967 4968 if (shift < 0) v <<= -shift;4969 else v >>= shift;4970 result = v;4971 4972+ // replicate the high bits to the low bits4973 z = bits;4974 while (z < 8) {4975 result += v >> z;4976 z += bits;208 unmodified lines5185 } else {5186 int bpp = info.bpp;5187 for (i=0; i < (int) s->img_x; ++i) {5188 stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s));5188- int a;5189+ unsigned int a;5190 out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount));5191 out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount));5192 out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount));5193 a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255);1985 unmodified lines