Added assert to check for 16-bit index overflow
This commit is contained in:
parent
f228e73f37
commit
299446aeca
25749
src/nuklear.h
25749
src/nuklear.h
File diff suppressed because it is too large
Load Diff
|
@ -109,7 +109,7 @@ nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state,
|
|||
}
|
||||
|
||||
/* draw cursor */
|
||||
if (background->type == NK_STYLE_ITEM_COLOR) {
|
||||
if (cursor->type == NK_STYLE_ITEM_COLOR) {
|
||||
nk_fill_rect(out, *scroll, style->rounding_cursor, cursor->data.color);
|
||||
nk_stroke_rect(out, *scroll, style->rounding_cursor, style->border_cursor, style->cursor_border_color);
|
||||
} else nk_draw_image(out, *scroll, &cursor->data.image, nk_white);
|
||||
|
|
|
@ -223,6 +223,18 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
|
|||
list->config.vertex_size*count, list->config.vertex_alignment);
|
||||
if (!vtx) return 0;
|
||||
list->vertex_count += (unsigned int)count;
|
||||
|
||||
/* This assert triggers because your are drawing a lot of stuff and nuklear
|
||||
* defined `nk_draw_index` as `nk_ushort` to safe space be default.
|
||||
*
|
||||
* So you reached the maximum number of indicies or rather vertexes.
|
||||
* To solve this issue please change typdef `nk_draw_index` to `nk_uint`
|
||||
* and don't forget to specify the new element size in your drawing
|
||||
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
|
||||
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
|
||||
* Sorry for the inconvenience. */
|
||||
NK_ASSERT((sizeof(nk_draw_index) == 2 && list->vertex_count < NK_USHORT_MAX &&
|
||||
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem");
|
||||
return vtx;
|
||||
}
|
||||
NK_INTERN nk_draw_index*
|
||||
|
|
Loading…
Reference in New Issue