Fix memory issues because of pointer to item in dynamic array, add clang-cl, add address sanitizer stuff
This commit is contained in:
@@ -46,7 +46,10 @@ Atlas CreateAtlas(Allocator allocator, Vec2I size) {
|
||||
}
|
||||
}
|
||||
|
||||
result.white_texture_bounding_box = {2.f * result.inverse_size.x, 2.f / (float)result.size.y, 14.f * result.inverse_size.x, 14.f / (float)result.size.y};
|
||||
result.white_texture_bounding_box = {
|
||||
{ 2.f * result.inverse_size.x, 2.f / (float)result.size.y},
|
||||
{14.f * result.inverse_size.x, 14.f / (float)result.size.y}
|
||||
};
|
||||
result.xcursor += 16;
|
||||
result.biggest_height += 16;
|
||||
return result;
|
||||
@@ -90,10 +93,12 @@ Rect2 PackBitmap(Atlas *atlas, uint8_t *bitmap, int width, int height) {
|
||||
}
|
||||
|
||||
Font CreateFont(Atlas *atlas, int32_t size, String path) {
|
||||
Scratch scratch;
|
||||
Font result = {};
|
||||
Allocator allocator = GetSystemAllocator();
|
||||
Scratch scratch;
|
||||
|
||||
String file = ReadFile(scratch, path);
|
||||
Font result = {};
|
||||
result.glyphs.allocator = allocator;
|
||||
String file = ReadFile(allocator, path);
|
||||
if (file.len == 0) {
|
||||
return result;
|
||||
}
|
||||
@@ -104,8 +109,8 @@ Font CreateFont(Atlas *atlas, int32_t size, String path) {
|
||||
return result;
|
||||
}
|
||||
|
||||
float scale = stbtt_ScaleForPixelHeight(&stb_font, (float)size);
|
||||
float em_scale = stbtt_ScaleForMappingEmToPixels(&stb_font, (float)size);
|
||||
float scale = stbtt_ScaleForPixelHeight(&stb_font, (float)size);
|
||||
// float em_scale = stbtt_ScaleForMappingEmToPixels(&stb_font, (float)size);
|
||||
|
||||
int ascent, descent, line_gap;
|
||||
stbtt_GetFontVMetrics(&stb_font, &ascent, &descent, &line_gap);
|
||||
@@ -117,6 +122,9 @@ Font CreateFont(Atlas *atlas, int32_t size, String path) {
|
||||
result.last_char = '~';
|
||||
result.white_texture_bounding_box = atlas->white_texture_bounding_box;
|
||||
|
||||
int glyph_count = result.last_char - result.first_char + 1; // + 1 because it's '<=' not '<'
|
||||
Reserve(&result.glyphs, glyph_count);
|
||||
|
||||
for (uint32_t ascii_symbol = result.first_char; ascii_symbol <= result.last_char; ascii_symbol++) {
|
||||
int width, height, xoff, yoff;
|
||||
uint8_t *bitmap = (uint8_t *)stbtt_GetCodepointBitmap(&stb_font, 0, scale, ascii_symbol, &width, &height, &xoff, &yoff);
|
||||
|
||||
@@ -74,8 +74,8 @@ void EndFrameRender(Color color) {
|
||||
Rect2 rect = it->scissor;
|
||||
GLint x = (GLint)rect.min.x;
|
||||
GLint y = (GLint)rect.min.y;
|
||||
GLsizei w = (GLsizei)(rect.max.x - rect.min.x);
|
||||
GLsizei h = (GLsizei)(rect.max.y - rect.min.y);
|
||||
GLsizei w = (GLsizei)(rect.max.x - x);
|
||||
GLsizei h = (GLsizei)(rect.max.y - y);
|
||||
glScissor(x, (GLint)WindowSize.y - (GLint)rect.max.y, w, h);
|
||||
glNamedBufferSubData(VBO, 0, it->count * sizeof(Vertex2D), it->vertices);
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
Reference in New Issue
Block a user