static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
static VkPhysicalDeviceType preferedPhysicalDeviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
static vk_engine_t* e;
+static char* saveToPng = NULL;
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (action != GLFW_PRESS)
printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests.\n");
printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs.\n");
printf("\t-vsync:\t\tEnable VSync, disabled by default.\n");
+ printf("\t-w filepath:\t\twrite last image to png.\n");
printf("\t-h:\t\tThis help message.\n");
printf("\n");
exit(-1);
default:
_print_usage_and_exit();
}
- }
+ }else if (strcmp (argv[i], "-w\0") == 0) {
+ if (argc -1 < ++i)
+ _print_usage_and_exit();
+ saveToPng = argv[i];
+ }else
+ _print_usage_and_exit();
}
if (printTestDetailsAndExit) {
#ifdef DEBUG
vkDeviceWaitIdle(dev->dev);
+ if (saveToPng)
+ vkvg_surface_write_to_png (surf, saveToPng);
+
vkvg_surface_destroy (surf);
vkvg_device_destroy (device);
i++;
}
+ if (saveToPng)
+ vkvg_surface_write_to_png (surf, saveToPng);
+
_print_results (testName, argc, argv, i, run_total, run_time_values);
free (run_time_values);
vkvg_move_to(ctx, 10, penY);
vkvg_show_text (ctx,txt);
}
+void print_boxed(VkvgContext ctx, const char* text, float penX, float penY, uint32_t size) {
+ vkvg_set_font_size(ctx,size);
+ vkvg_text_extents_t te = {0};
+ vkvg_text_extents(ctx,text,&te);
+ vkvg_font_extents_t fe = {0};
+ vkvg_font_extents(ctx, &fe);
+
+ vkvg_move_to(ctx, penX, penY);
+ vkvg_rectangle(ctx, penX, penY -fe.ascent, te.width, fe.height);
+ vkvg_set_source_rgb(ctx,0.2f,0,0);
+ vkvg_fill(ctx);
+
+ vkvg_move_to(ctx, penX, penY);
+ vkvg_set_source_rgb(ctx,1,1,1);
+ vkvg_show_text (ctx,text);
+}
void test2() {
VkvgContext ctx = vkvg_create(surf);
}
vkvg_destroy(ctx);
}
+void simple_text () {
+ VkvgContext ctx = vkvg_create(surf);
+ vkvg_set_source_rgb (ctx, 0, 0, 0);
+ vkvg_paint (ctx);
+ vkvg_set_source_rgb (ctx, 1, 1, 1);
+ vkvg_select_font_face (ctx, "mono");
+ print_boxed (ctx, "This is a test string!", 50,20,12);
+ print_boxed (ctx, "This is a test string!", 50,50,20);
+ print_boxed (ctx, "ANOTHER ONE TO CHECK..", 50,80,20);
+ vkvg_destroy (ctx);
+}
void random_size () {
VkvgContext ctx = vkvg_create(surf);
vkvg_clear(ctx);
int main(int argc, char *argv[]) {
no_test_size = true;
//vkvg_log_level = VKVG_LOG_INFO;
+ PERFORM_TEST (simple_text, argc, argv);
PERFORM_TEST (single_font_and_size, argc, argv);
PERFORM_TEST (random_size, argc, argv);
PERFORM_TEST (random_font_and_size, argc, argv);