New Renderer - First Version. Finished.
This commit is contained in:
parent
efa1515121
commit
80b98e3b47
|
@ -161,7 +161,7 @@ struct Application_Links;
|
||||||
#define DRAW_STRING_SIG(n) Vec2 n(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta)
|
#define DRAW_STRING_SIG(n) Vec2 n(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta)
|
||||||
#define GET_STRING_ADVANCE_SIG(n) f32 n(Application_Links *app, Face_ID font_id, String_Const_u8 str)
|
#define GET_STRING_ADVANCE_SIG(n) f32 n(Application_Links *app, Face_ID font_id, String_Const_u8 str)
|
||||||
#define DRAW_RECTANGLE_SIG(n) void n(Application_Links *app, Rect_f32 rect, int_color color)
|
#define DRAW_RECTANGLE_SIG(n) void n(Application_Links *app, Rect_f32 rect, int_color color)
|
||||||
#define DRAW_RECTANGLE_OUTLINE_SIG(n) void n(Application_Links *app, f32_Rect rect, int_color color)
|
#define DRAW_RECTANGLE_OUTLINE_SIG(n) void n(Application_Links *app, Rect_f32 rect, int_color color)
|
||||||
#define DRAW_CLIP_PUSH_SIG(n) void n(Application_Links *app, Rect_f32 clip_box)
|
#define DRAW_CLIP_PUSH_SIG(n) void n(Application_Links *app, Rect_f32 clip_box)
|
||||||
#define DRAW_CLIP_POP_SIG(n) f32_Rect n(Application_Links *app)
|
#define DRAW_CLIP_POP_SIG(n) f32_Rect n(Application_Links *app)
|
||||||
#define DRAW_COORDINATE_CENTER_PUSH_SIG(n) void n(Application_Links *app, Vec2 point)
|
#define DRAW_COORDINATE_CENTER_PUSH_SIG(n) void n(Application_Links *app, Vec2 point)
|
||||||
|
@ -1069,7 +1069,7 @@ static Microsecond_Time_Stamp get_microseconds_timestamp(Application_Links *app)
|
||||||
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string(app, font_id, str, point, color, flags, delta));}
|
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string(app, font_id, str, point, color, flags, delta));}
|
||||||
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String_Const_u8 str){return(app->get_string_advance(app, font_id, str));}
|
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String_Const_u8 str){return(app->get_string_advance(app, font_id, str));}
|
||||||
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle(app, rect, color));}
|
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle(app, rect, color));}
|
||||||
static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline(app, rect, color));}
|
static void draw_rectangle_outline(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle_outline(app, rect, color));}
|
||||||
static void draw_clip_push(Application_Links *app, Rect_f32 clip_box){(app->draw_clip_push(app, clip_box));}
|
static void draw_clip_push(Application_Links *app, Rect_f32 clip_box){(app->draw_clip_push(app, clip_box));}
|
||||||
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop(app));}
|
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop(app));}
|
||||||
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push(app, point));}
|
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push(app, point));}
|
||||||
|
@ -1249,7 +1249,7 @@ static Microsecond_Time_Stamp get_microseconds_timestamp(Application_Links *app)
|
||||||
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string_(app, font_id, str, point, color, flags, delta));}
|
static Vec2 draw_string(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 point, int_color color, u32 flags, Vec2 delta){return(app->draw_string_(app, font_id, str, point, color, flags, delta));}
|
||||||
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String_Const_u8 str){return(app->get_string_advance_(app, font_id, str));}
|
static f32 get_string_advance(Application_Links *app, Face_ID font_id, String_Const_u8 str){return(app->get_string_advance_(app, font_id, str));}
|
||||||
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle_(app, rect, color));}
|
static void draw_rectangle(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle_(app, rect, color));}
|
||||||
static void draw_rectangle_outline(Application_Links *app, f32_Rect rect, int_color color){(app->draw_rectangle_outline_(app, rect, color));}
|
static void draw_rectangle_outline(Application_Links *app, Rect_f32 rect, int_color color){(app->draw_rectangle_outline_(app, rect, color));}
|
||||||
static void draw_clip_push(Application_Links *app, Rect_f32 clip_box){(app->draw_clip_push_(app, clip_box));}
|
static void draw_clip_push(Application_Links *app, Rect_f32 clip_box){(app->draw_clip_push_(app, clip_box));}
|
||||||
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop_(app));}
|
static f32_Rect draw_clip_pop(Application_Links *app){return(app->draw_clip_pop_(app));}
|
||||||
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push_(app, point));}
|
static void draw_coordinate_center_push(Application_Links *app, Vec2 point){(app->draw_coordinate_center_push_(app, point));}
|
||||||
|
|
|
@ -3621,15 +3621,16 @@ Draw_String(Application_Links *app, Face_ID font_id, String_Const_u8 str, Vec2 p
|
||||||
{
|
{
|
||||||
Vec2 result = point;
|
Vec2 result = point;
|
||||||
Models *models = (Models*)app->cmd_context;
|
Models *models = (Models*)app->cmd_context;
|
||||||
|
Face *face = font_set_face_from_id(&models->font_set, font_id);
|
||||||
if (models->target == 0){
|
if (models->target == 0){
|
||||||
f32 width = font_string_width(models->target, font_id, str);
|
f32 width = font_string_width(models->target, face, str);
|
||||||
result += delta*width;
|
result += delta*width;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Color_Table color_table = models->color_table;
|
Color_Table color_table = models->color_table;
|
||||||
point = draw_helper__models_space_to_screen_space(models, point);
|
point = draw_helper__models_space_to_screen_space(models, point);
|
||||||
u32 actual_color = finalize_color(color_table, color);
|
u32 actual_color = finalize_color(color_table, color);
|
||||||
f32 width = draw_string(models->target, font_id, str, point, actual_color, flags, delta);
|
f32 width = draw_string(models->target, face, str, point, actual_color, flags, delta);
|
||||||
result += delta*width;
|
result += delta*width;
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -3639,7 +3640,8 @@ API_EXPORT f32
|
||||||
Get_String_Advance(Application_Links *app, Face_ID font_id, String_Const_u8 str)
|
Get_String_Advance(Application_Links *app, Face_ID font_id, String_Const_u8 str)
|
||||||
{
|
{
|
||||||
Models *models = (Models*)app->cmd_context;
|
Models *models = (Models*)app->cmd_context;
|
||||||
return(font_string_width(models->target, font_id, str));
|
Face *face = font_set_face_from_id(&models->font_set, font_id);
|
||||||
|
return(font_string_width(models->target, face, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void
|
API_EXPORT void
|
||||||
|
@ -3654,7 +3656,7 @@ Draw_Rectangle(Application_Links *app, Rect_f32 rect, int_color color){
|
||||||
}
|
}
|
||||||
|
|
||||||
API_EXPORT void
|
API_EXPORT void
|
||||||
Draw_Rectangle_Outline(Application_Links *app, f32_Rect rect, int_color color)
|
Draw_Rectangle_Outline(Application_Links *app, Rect_f32 rect, int_color color)
|
||||||
{
|
{
|
||||||
Models *models = (Models*)app->cmd_context;
|
Models *models = (Models*)app->cmd_context;
|
||||||
if (models->in_render_mode){
|
if (models->in_render_mode){
|
||||||
|
|
|
@ -38,7 +38,11 @@ internal void
|
||||||
draw__write_vertices_in_current_group(Render_Target *target, Render_Vertex *vertices, i32 count){
|
draw__write_vertices_in_current_group(Render_Target *target, Render_Vertex *vertices, i32 count){
|
||||||
if (count > 0){
|
if (count > 0){
|
||||||
Render_Group *group = target->group_last;
|
Render_Group *group = target->group_last;
|
||||||
if (group != 0){
|
if (group == 0){
|
||||||
|
draw__begin_new_group(target);
|
||||||
|
group = target->group_last;
|
||||||
|
}
|
||||||
|
|
||||||
Render_Vertex_List *list = &group->vertex_list;
|
Render_Vertex_List *list = &group->vertex_list;
|
||||||
|
|
||||||
Render_Vertex_Array_Node *last = list->last;
|
Render_Vertex_Array_Node *last = list->last;
|
||||||
|
@ -69,7 +73,7 @@ draw__write_vertices_in_current_group(Render_Target *target, Render_Vertex *vert
|
||||||
memory->vertex_count += count_left_over;
|
memory->vertex_count += count_left_over;
|
||||||
list->vertex_count += count_left_over;
|
list->vertex_count += count_left_over;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +88,19 @@ draw__set_clip_box(Render_Target *target, Rect_i32 clip_box){
|
||||||
internal void
|
internal void
|
||||||
draw__set_face_id(Render_Target *target, Face_ID face_id){
|
draw__set_face_id(Render_Target *target, Face_ID face_id){
|
||||||
if (target->current_face_id != face_id){
|
if (target->current_face_id != face_id){
|
||||||
|
if (target->current_face_id != 0){
|
||||||
target->current_face_id = face_id;
|
target->current_face_id = face_id;
|
||||||
draw__begin_new_group(target);
|
draw__begin_new_group(target);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
target->current_face_id = face_id;
|
||||||
|
for (Render_Group *group = target->group_first;
|
||||||
|
group != 0;
|
||||||
|
group = group->next){
|
||||||
|
group->face_id = face_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -152,22 +166,6 @@ end_render_section(Render_Target *target, System_Functions *system){
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
#if 0
|
|
||||||
internal void
|
|
||||||
draw_font_glyph(Render_Target *target, Face_ID font_id, u32 codepoint, f32 x, f32 y, u32 color, u32 flags){
|
|
||||||
Render_Command_Glyph cmd = {};
|
|
||||||
CmdHeader(RenCom_Glyph);
|
|
||||||
cmd.pos.x = x;
|
|
||||||
cmd.pos.y = y;
|
|
||||||
cmd.color = color;
|
|
||||||
cmd.font_id = font_id;
|
|
||||||
cmd.codepoint = codepoint;
|
|
||||||
cmd.flags = flags;
|
|
||||||
void *h = render_begin_push(target, &cmd, cmd.header.size);
|
|
||||||
render_end_push(target, h);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
draw_rectangle(Render_Target *target, Rect_f32 rect, u32 color){
|
draw_rectangle(Render_Target *target, Rect_f32 rect, u32 color){
|
||||||
Render_Vertex vertices[6] = {};
|
Render_Vertex vertices[6] = {};
|
||||||
|
@ -205,7 +203,7 @@ draw_font_glyph(Render_Target *target, Face *face, u32 codepoint, f32 x, f32 y,
|
||||||
|
|
||||||
vertices[0].xy = V2(xy.x0, xy.y1); vertices[0].uvw = V3(uv.x0, uv.y1, bounds.w);
|
vertices[0].xy = V2(xy.x0, xy.y1); vertices[0].uvw = V3(uv.x0, uv.y1, bounds.w);
|
||||||
vertices[1].xy = V2(xy.x1, xy.y1); vertices[1].uvw = V3(uv.x1, uv.y1, bounds.w);
|
vertices[1].xy = V2(xy.x1, xy.y1); vertices[1].uvw = V3(uv.x1, uv.y1, bounds.w);
|
||||||
vertices[3].xy = V2(xy.x0, xy.y0); vertices[3].uvw = V3(uv.x0, uv.y0, bounds.w);
|
vertices[2].xy = V2(xy.x0, xy.y0); vertices[2].uvw = V3(uv.x0, uv.y0, bounds.w);
|
||||||
vertices[5].xy = V2(xy.x1, xy.y0); vertices[5].uvw = V3(uv.x1, uv.y0, bounds.w);
|
vertices[5].xy = V2(xy.x1, xy.y0); vertices[5].uvw = V3(uv.x1, uv.y0, bounds.w);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -214,17 +212,19 @@ draw_font_glyph(Render_Target *target, Face *face, u32 codepoint, f32 x, f32 y,
|
||||||
|
|
||||||
vertices[0].xy = V2(xy.x0, xy.y1); vertices[0].uvw = V3(uv.x1, uv.y1, bounds.w);
|
vertices[0].xy = V2(xy.x0, xy.y1); vertices[0].uvw = V3(uv.x1, uv.y1, bounds.w);
|
||||||
vertices[1].xy = V2(xy.x1, xy.y1); vertices[1].uvw = V3(uv.x1, uv.y0, bounds.w);
|
vertices[1].xy = V2(xy.x1, xy.y1); vertices[1].uvw = V3(uv.x1, uv.y0, bounds.w);
|
||||||
vertices[3].xy = V2(xy.x0, xy.y0); vertices[3].uvw = V3(uv.x0, uv.y1, bounds.w);
|
vertices[2].xy = V2(xy.x0, xy.y0); vertices[2].uvw = V3(uv.x0, uv.y1, bounds.w);
|
||||||
vertices[5].xy = V2(xy.x1, xy.y0); vertices[5].uvw = V3(uv.x0, uv.y0, bounds.w);
|
vertices[5].xy = V2(xy.x1, xy.y0); vertices[5].uvw = V3(uv.x0, uv.y0, bounds.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
vertices[2] = vertices[1];
|
vertices[3] = vertices[1];
|
||||||
vertices[3] = vertices[4];
|
vertices[4] = vertices[2];
|
||||||
|
|
||||||
Vec4 c = unpack_color4(color);
|
Vec4 c = unpack_color4(color);
|
||||||
for (i32 i = 0; i < 6; i += 1){
|
for (i32 i = 0; i < 6; i += 1){
|
||||||
vertices[0].color = c;
|
vertices[i].color = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw__write_vertices_in_current_group(target, vertices, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
@ -293,11 +293,8 @@ snap_point_to_boundary(Vec2 point){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
draw_string(Render_Target *target, Face_ID font_id, String_Const_u8 string, Vec2 point, u32 color, u32 flags, Vec2 delta){
|
draw_string(Render_Target *target, Face *face, String_Const_u8 string, Vec2 point, u32 color, u32 flags, Vec2 delta){
|
||||||
f32 total_delta = 0.f;
|
f32 total_delta = 0.f;
|
||||||
|
|
||||||
Face *face = 0;
|
|
||||||
|
|
||||||
if (face != 0){
|
if (face != 0){
|
||||||
point = snap_point_to_boundary(point);
|
point = snap_point_to_boundary(point);
|
||||||
|
|
||||||
|
@ -348,30 +345,30 @@ draw_string(Render_Target *target, Face_ID font_id, String_Const_u8 string, Vec2
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
draw_string(Render_Target *target, Face_ID font_id, String_Const_u8 string, Vec2 point, u32 color){
|
draw_string(Render_Target *target, Face *face, String_Const_u8 string, Vec2 point, u32 color){
|
||||||
return(draw_string(target, font_id, string, point, color, 0, V2(1.f, 0.f)));
|
return(draw_string(target, face, string, point, color, 0, V2(1.f, 0.f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
draw_string(Render_Target *target, Face_ID font_id, u8 *str, Vec2 point,
|
draw_string(Render_Target *target, Face *face, u8 *str, Vec2 point,
|
||||||
u32 color, u32 flags, Vec2 delta){
|
u32 color, u32 flags, Vec2 delta){
|
||||||
return(draw_string(target, font_id, SCu8(str), point, color, flags, delta));
|
return(draw_string(target, face, SCu8(str), point, color, flags, delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
draw_string(Render_Target *target, Face_ID font_id, u8 *str, Vec2 point,
|
draw_string(Render_Target *target, Face *face, u8 *str, Vec2 point,
|
||||||
u32 color){
|
u32 color){
|
||||||
return(draw_string(target, font_id, SCu8(str), point, color, 0, V2(1.f, 0.f)));
|
return(draw_string(target, face, SCu8(str), point, color, 0, V2(1.f, 0.f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
font_string_width(Render_Target *target, Face_ID font_id, String_Const_u8 str){
|
font_string_width(Render_Target *target, Face *face, String_Const_u8 str){
|
||||||
return(draw_string(target, font_id, str, V2(0, 0), 0, 0, V2(0, 0)));
|
return(draw_string(target, face, str, V2(0, 0), 0, 0, V2(0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal f32
|
internal f32
|
||||||
font_string_width(Render_Target *target, Face_ID font_id, u8 *str){
|
font_string_width(Render_Target *target, Face *face, u8 *str){
|
||||||
return(draw_string(target, font_id, SCu8(str), V2(0, 0), 0, 0, V2(0, 0)));
|
return(draw_string(target, face, SCu8(str), V2(0, 0), 0, 0, V2(0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
Loading…
Reference in New Issue