Skip to content
Myr

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

2 files+10 added−4 removed

modified:tests/caveview/cave_mesher.c+7 added-2 removed
35 unmodified lines
36//#define FANCY_LEAVES // nearly 2x the triangles when enabled (if underground is filled)37#define FAST_CHUNK38#define IN_PLACE3940#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 underground4445enum
85 unmodified lines
131 { C_solid, 8,8,8,8,9,10 },132 { C_solid, 35,35,35,35,4,4, },133134 // 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 lines
143 { C_empty }, // redstone144145 // 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 lines
833 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 }840841 #ifdef VHEIGHT_TEST842 effective_blocktype[168] = 168;
91 unmodified lines
modified:stb_image.h+3 added-2 removed
4958 unmodified lines
4959 a = (a + (a >> 16)); // max 32 per 8 bits4960 return a & 0xff;4961}49624963static int stbi__shiftsigned(int v, int shift, int bits)4963static unsigned int stbi__shiftsigned(unsigned int v, int shift, int bits)4964{4965 int result;4966 int z=0;49674968 if (shift < 0) v <<= -shift;4969 else v >>= shift;4970 result = v;49714972 // replicate the high bits to the low bits4973 z = bits;4974 while (z < 8) {4975 result += v >> z;4976 z += bits;
208 unmodified lines
5185 } 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