diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-04-10 08:22:21 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-04-10 08:22:21 +0200 |
| commit | e9f311def74bf9f4e124ca0d73a70e40bdbd3cfb (patch) | |
| tree | 3d31429ee9a39fbcefce8833321a9ccf51d0bc28 | |
| parent | 88996c4e1f4844e183189eb578eff70d3bf09384 (diff) | |
vkvg_rectangle
| -rw-r--r-- | include/vkvg.h | 3 | ||||
| -rw-r--r-- | src/vkvg_context.c | 18 | ||||
| -rw-r--r-- | tests/test1.c | 12 |
3 files changed, 21 insertions, 12 deletions
diff --git a/include/vkvg.h b/include/vkvg.h index 2c86cbf..c5d8f32 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -4,7 +4,7 @@ #include <vulkan/vulkan.h> #include <math.h> -#define VKVG_SAMPLES VK_SAMPLE_COUNT_4_BIT +#define VKVG_SAMPLES 4 typedef enum _vkvg_direction { VKVG_HORIZONTAL = 0, @@ -81,6 +81,7 @@ void vkvg_line_to (VkvgContext ctx, float x, float y); void vkvg_move_to (VkvgContext ctx, float x, float y); void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, float a2); void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3); +void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h); void vkvg_stroke (VkvgContext ctx); void vkvg_stroke_preserve (VkvgContext ctx); void vkvg_fill (VkvgContext ctx); diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 45bc9a1..9569b73 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -202,11 +202,27 @@ void vkvg_move_to (VkvgContext ctx, float x, float y) ctx->curPos.x = x; ctx->curPos.y = y; } - void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) { _bezier (ctx, ctx->curPos.x, ctx->curPos.y, x1, y1, x2, y2, x3, y3); } +void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){ + _finish_path (ctx); + + //set start to current idx in point array + ctx->pathes[ctx->pathPtr] = ctx->pointCount; + _check_pathes_array(ctx); + ctx->pathPtr++; + + _add_point (ctx, x, y); + _add_point (ctx, x + w, y); + _add_point (ctx, x + w, y + h); + _add_point (ctx, x, y + h); + + vkvg_close_path (ctx); + ctx->curPos.x = x; + ctx->curPos.y = y; +} void vkvg_clip_preserve (VkvgContext ctx){ vkCmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineClipping); vkvg_fill_preserve(ctx); diff --git a/tests/test1.c b/tests/test1.c index b9499d2..5c10b57 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -473,14 +473,6 @@ void vkvg_test_curves (VkvgContext ctx) { vkvg_stroke (ctx); } -void vkvg_rectangle(VkvgContext ctx, float x, float y, float width, float height){ - vkvg_move_to(ctx,x,y); - vkvg_line_to(ctx,x+width,y); - vkvg_line_to(ctx,x+width,y+height); - vkvg_line_to(ctx,x,y+height); - vkvg_close_path(ctx); -} - void vkvg_test_stroke(VkvgContext ctx){ vkvg_set_linewidth(ctx, 2); vkvg_set_rgba(ctx,1,0,0,1); @@ -633,9 +625,9 @@ int main(int argc, char *argv[]) { VkvgSurface surf2 = vkvg_surface_create (device,1024,800);; VkvgContext ctx = vkvg_create(surf); - vkvg_set_rgba(ctx,0.01,0.01,0.1,1); + vkvg_set_rgba(ctx,0.02,0.02,0.1,1); //vkvg_paint(ctx); - vkvg_rectangle(ctx,0,0,1024,800); + vkvg_rectangle (ctx,0,0,1024,800); vkvg_fill (ctx); vkvg_test_fill(ctx); |