|
|
|
@@ -16,7 +16,6 @@ draw_font_t *draw_font = NULL;
|
|
|
|
|
int draw_font_size;
|
|
|
|
|
gpu_texture_t *_draw_current = NULL;
|
|
|
|
|
|
|
|
|
|
static iron_matrix4x4_t draw_projection_matrix;
|
|
|
|
|
static iron_matrix3x3_t draw_transform;
|
|
|
|
|
static bool draw_bilinear_filter = true;
|
|
|
|
|
static uint32_t draw_color = 0;
|
|
|
|
@@ -32,7 +31,7 @@ static gpu_shader_t image_vert_shader;
|
|
|
|
|
static gpu_shader_t image_frag_shader;
|
|
|
|
|
static gpu_pipeline_t image_pipeline;
|
|
|
|
|
static int image_tex_unit;
|
|
|
|
|
static int image_p_loc;
|
|
|
|
|
static int image_w_loc;
|
|
|
|
|
static int image_pos_loc;
|
|
|
|
|
static int image_tex_loc;
|
|
|
|
|
static int image_col_loc;
|
|
|
|
@@ -40,14 +39,14 @@ static int image_col_loc;
|
|
|
|
|
static gpu_shader_t rect_vert_shader;
|
|
|
|
|
static gpu_shader_t rect_frag_shader;
|
|
|
|
|
static gpu_pipeline_t rect_pipeline;
|
|
|
|
|
static int rect_p_loc;
|
|
|
|
|
static int rect_w_loc;
|
|
|
|
|
static int rect_pos_loc;
|
|
|
|
|
static int rect_col_loc;
|
|
|
|
|
|
|
|
|
|
static gpu_shader_t tris_vert_shader;
|
|
|
|
|
static gpu_shader_t tris_frag_shader;
|
|
|
|
|
static gpu_pipeline_t tris_pipeline;
|
|
|
|
|
static int tris_p_loc;
|
|
|
|
|
static int tris_w_loc;
|
|
|
|
|
static int tris_pos0_loc;
|
|
|
|
|
static int tris_pos1_loc;
|
|
|
|
|
static int tris_pos2_loc;
|
|
|
|
@@ -58,7 +57,7 @@ static gpu_shader_t text_frag_shader;
|
|
|
|
|
static gpu_pipeline_t text_pipeline;
|
|
|
|
|
static gpu_pipeline_t text_pipeline_rt;
|
|
|
|
|
static int text_tex_unit;
|
|
|
|
|
static int text_p_loc;
|
|
|
|
|
static int text_w_loc;
|
|
|
|
|
static int text_pos_loc;
|
|
|
|
|
static int text_tex_loc;
|
|
|
|
|
static int text_col_loc;
|
|
|
|
@@ -161,10 +160,10 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert,
|
|
|
|
|
draw_pipeline_init(&image_pipeline, &image_vert_shader, &image_frag_shader);
|
|
|
|
|
gpu_pipeline_compile(&image_pipeline);
|
|
|
|
|
image_tex_unit = 0;
|
|
|
|
|
image_p_loc = 0;
|
|
|
|
|
image_pos_loc = 64;
|
|
|
|
|
image_tex_loc = 80;
|
|
|
|
|
image_col_loc = 96;
|
|
|
|
|
image_w_loc = 0;
|
|
|
|
|
image_pos_loc = 48;
|
|
|
|
|
image_tex_loc = 64;
|
|
|
|
|
image_col_loc = 80;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rect painter
|
|
|
|
@@ -174,9 +173,9 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert,
|
|
|
|
|
draw_pipeline_init(&rect_pipeline, &rect_vert_shader, &rect_frag_shader);
|
|
|
|
|
rect_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA;
|
|
|
|
|
gpu_pipeline_compile(&rect_pipeline);
|
|
|
|
|
rect_p_loc = 0;
|
|
|
|
|
rect_pos_loc = 64;
|
|
|
|
|
rect_col_loc = 80;
|
|
|
|
|
rect_w_loc = 0;
|
|
|
|
|
rect_pos_loc = 48;
|
|
|
|
|
rect_col_loc = 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tris painter
|
|
|
|
@@ -186,11 +185,11 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert,
|
|
|
|
|
draw_pipeline_init(&tris_pipeline, &tris_vert_shader, &tris_frag_shader);
|
|
|
|
|
tris_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA;
|
|
|
|
|
gpu_pipeline_compile(&tris_pipeline);
|
|
|
|
|
tris_p_loc = 0;
|
|
|
|
|
tris_pos0_loc = 64;
|
|
|
|
|
tris_pos1_loc = 72;
|
|
|
|
|
tris_pos2_loc = 80;
|
|
|
|
|
tris_col_loc = 96; // 88 with 16 align
|
|
|
|
|
tris_w_loc = 0;
|
|
|
|
|
tris_pos0_loc = 48;
|
|
|
|
|
tris_pos1_loc = 56;
|
|
|
|
|
tris_pos2_loc = 64;
|
|
|
|
|
tris_col_loc = 80; // 16 align
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Text painter
|
|
|
|
@@ -201,10 +200,10 @@ void draw_init(buffer_t *image_vert, buffer_t *image_frag, buffer_t *rect_vert,
|
|
|
|
|
text_pipeline.blend_source = GPU_BLEND_SOURCE_ALPHA;
|
|
|
|
|
gpu_pipeline_compile(&text_pipeline);
|
|
|
|
|
text_tex_unit = 0;
|
|
|
|
|
text_p_loc = 0;
|
|
|
|
|
text_pos_loc = 64;
|
|
|
|
|
text_tex_loc = 80;
|
|
|
|
|
text_col_loc = 96;
|
|
|
|
|
text_w_loc = 0;
|
|
|
|
|
text_pos_loc = 48;
|
|
|
|
|
text_tex_loc = 64;
|
|
|
|
|
text_col_loc = 80;
|
|
|
|
|
|
|
|
|
|
draw_pipeline_init(&text_pipeline_rt, &text_vert_shader, &text_frag_shader);
|
|
|
|
|
text_pipeline_rt.blend_source = GPU_BLEND_SOURCE_ALPHA;
|
|
|
|
@@ -232,7 +231,7 @@ void draw_scaled_sub_image(gpu_texture_t *tex, float sx, float sy, float sw, flo
|
|
|
|
|
gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &image_pipeline);
|
|
|
|
|
gpu_set_vertex_buffer(&rect_vertex_buffer);
|
|
|
|
|
gpu_set_index_buffer(&rect_index_buffer);
|
|
|
|
|
gpu_set_matrix4(image_p_loc, draw_projection_matrix);
|
|
|
|
|
gpu_set_matrix3(image_w_loc, draw_transform);
|
|
|
|
|
gpu_set_float4(image_pos_loc, dx / vw(), dy / vh(), dw / vw(), dh / vh());
|
|
|
|
|
gpu_set_float4(image_tex_loc, sx / tex->width, sy / tex->height, sw / tex->width, sh / tex->height);
|
|
|
|
|
gpu_set_float4(image_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0);
|
|
|
|
@@ -256,7 +255,7 @@ void draw_filled_triangle(float x0, float y0, float x1, float y1, float x2, floa
|
|
|
|
|
gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &tris_pipeline);
|
|
|
|
|
gpu_set_vertex_buffer(&tris_vertex_buffer);
|
|
|
|
|
gpu_set_index_buffer(&tris_index_buffer);
|
|
|
|
|
gpu_set_matrix4(tris_p_loc, draw_projection_matrix);
|
|
|
|
|
gpu_set_matrix3(tris_w_loc, draw_transform);
|
|
|
|
|
gpu_set_float2(tris_pos0_loc, x0 / vw(), y0 / vh());
|
|
|
|
|
gpu_set_float2(tris_pos1_loc, x1 / vw(), y1 / vh());
|
|
|
|
|
gpu_set_float2(tris_pos2_loc, x2 / vw(), y2 / vh());
|
|
|
|
@@ -268,7 +267,7 @@ void draw_filled_rect(float x, float y, float width, float height) {
|
|
|
|
|
gpu_set_pipeline(draw_custom_pipeline != NULL ? draw_custom_pipeline : &rect_pipeline);
|
|
|
|
|
gpu_set_vertex_buffer(&rect_vertex_buffer);
|
|
|
|
|
gpu_set_index_buffer(&rect_index_buffer);
|
|
|
|
|
gpu_set_matrix4(rect_p_loc, draw_projection_matrix);
|
|
|
|
|
gpu_set_matrix3(rect_w_loc, draw_transform);
|
|
|
|
|
gpu_set_float4(rect_pos_loc, x / vw(), y / vh(), width / vw(), height / vh());
|
|
|
|
|
gpu_set_float4(rect_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0);
|
|
|
|
|
gpu_draw();
|
|
|
|
@@ -530,7 +529,7 @@ void draw_string(const char *text, float x, float y) {
|
|
|
|
|
xpos += q.xadvance;
|
|
|
|
|
gpu_set_float4(text_pos_loc, q.x0 / vw(), q.y0 / vh(), (q.x1 - q.x0) / vw(), (q.y1 - q.y0) / vh());
|
|
|
|
|
gpu_set_float4(text_tex_loc, q.s0, q.t0, q.s1 - q.s0, q.t1 - q.t0);
|
|
|
|
|
gpu_set_matrix4(text_p_loc, draw_projection_matrix);
|
|
|
|
|
gpu_set_matrix3(text_w_loc, draw_transform);
|
|
|
|
|
gpu_set_float4(text_col_loc, _draw_color_r(draw_color) / 255.0, _draw_color_g(draw_color) / 255.0, _draw_color_b(draw_color) / 255.0, _draw_color_a(draw_color) / 255.0);
|
|
|
|
|
gpu_draw();
|
|
|
|
|
}
|
|
|
|
|