]> O.S.I.I.S - jp/vkvg.git/commitdiff
vkvg_rectangle
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 10 Apr 2018 06:22:21 +0000 (08:22 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 10 Apr 2018 06:22:21 +0000 (08:22 +0200)
include/vkvg.h
src/vkvg_context.c
tests/test1.c

index 2c86cbf99dee7f058ba87a678aaa7948497905f5..c5d8f32ed8d5410518500452ea34c332e9c2ff36 100644 (file)
@@ -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);
index 45bc9a1d8ddc0812ee148e2a7ce05b5f6aeeffe9..9569b73d1e9969c33f716297398ffa130600109e 100644 (file)
@@ -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);
index b9499d2f70cab5d803d3d3018ed3f900b2b91c93..5c10b57cc6e7583b9aa450bf8f9ec650ee56dd59 100644 (file)
@@ -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);