fix use of stbrp_coord if no stb_rect_pack;

fix a few assert()s that weren't STBTT_asserts();
fix missing cast for C++
fix typo in C++ test compilation that prevented it from trying to compile stb_truetype
pull/49/merge
Sean Barrett 2014-12-10 00:27:11 -08:00
parent 34eec7cc5d
commit 26439254e8
3 changed files with 15 additions and 8 deletions

View File

@ -2062,6 +2062,8 @@ void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_inde
#define STBTT__NOTUSED(v) (void)sizeof(v)
#endif
typedef int stbrp_coord;
////////////////////////////////////////////////////////////////////////////////////
// //
// //
@ -2086,7 +2088,8 @@ typedef struct
typedef struct
{
int id,w,h,x,y,was_packed;
stbrp_coord x,y;
int id,w,h,was_packed;
} stbrp_rect;
static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
@ -2167,8 +2170,8 @@ void stbtt_PackEnd (stbtt_pack_context *spc)
void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
{
assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
if (h_oversample <= STBTT_MAX_OVERSAMPLE)
spc->h_oversample = h_oversample;
if (v_oversample <= STBTT_MAX_OVERSAMPLE)
@ -2222,7 +2225,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i
}
for (; i < w; ++i) {
assert(pixels[i] == 0);
STBTT_assert(pixels[i] == 0);
total -= buffer[i & STBTT__OVER_MASK];
pixels[i] = (unsigned char) (total / kernel_width);
}
@ -2276,7 +2279,7 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i
}
for (; i < h; ++i) {
assert(pixels[i*stride_in_bytes] == 0);
STBTT_assert(pixels[i*stride_in_bytes] == 0);
total -= buffer[i & STBTT__OVER_MASK];
pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
}
@ -2320,7 +2323,7 @@ int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int f
for (i=0; i < num_ranges; ++i)
n += ranges[i].num_chars_in_range;
rects = STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
if (rects == NULL)
return 0;

View File

@ -1,3 +1,7 @@
// check that stb_truetype compiles with no stb_rect_pack.h
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h"
#include "stretchy_buffer.h"
#include <assert.h>

View File

@ -1,4 +1,4 @@
#define STB_TRUETYPE_IMPLEMENTATIOn
#define STB_TRUETYPE_IMPLEMENTATION
#define STB_PERLIN_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define STB_DXT_IMPLEMENATION
@ -8,6 +8,7 @@
#define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#include "stb_rect_pack.h"
#include "stb_truetype.h"
#include "stb_image_write.h"
#include "stb_perlin.h"
@ -16,7 +17,6 @@
#include "stb_divide.h"
#include "stb_image.h"
#include "stb_herringbone_wang_tile.h"
#include "stb_rect_pack.h"
#define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0)
#define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0)