From b3f10ef272b7c7d47b66718341681bc717c38641 Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 27 Jan 2015 18:08:36 -0500 Subject: [PATCH] add basic blit tests (visual only) --- CMakeLists.txt | 3 +++ test/test_blit.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/test_blit.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 99871c0..9c0c4e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,3 +27,6 @@ target_link_libraries("test_surfaces" ${SDL2_LIBRARY}) add_executable("test_color_format" "${TESTS_DIR}/test_color_format.c" ${LIB_SRC_FILES}) target_link_libraries("test_color_format" ${SDL2_LIBRARY}) + +add_executable("test_blit" "${TESTS_DIR}/test_blit.c" ${LIB_SRC_FILES}) +target_link_libraries("test_blit" ${SDL2_LIBRARY}) diff --git a/test/test_blit.c b/test/test_blit.c new file mode 100644 index 0000000..142119e --- /dev/null +++ b/test/test_blit.c @@ -0,0 +1,52 @@ +#include +#include "vm/vm.h" +#include +#include + +int main(int argc, char **argv) { + log_init(); + input_init(); + WINDOW *window = window_init("test_blit", 1024, 768, 640, 480); + if (!window) + return 1; + + // test surface we will render with the different blit functions + SURFACE *bmp = surface_create(64, 64, SURFACE_FORMAT_RGBA, SURFACE_FLAGS_NONE); + surface_clear(bmp, color_create_rgba(0, 0, 0, 0)); + surface_rect_filled(bmp, 16, 0, 47, 31, color_create_rgba(255, 96, 96, 255)); + surface_rect_filled(bmp, 0, 32, 31, 63, color_create_rgba(96, 255, 96, 192)); + surface_rect_filled(bmp, 32, 32, 63, 63, color_create_rgba(96, 96, 255, 64)); + + + surface_clear(window->surface, COLOR_DOS_GRAY); + + surface_blit(bmp, window->surface, 10, 10); + surface_blit_blend(bmp, window->surface, 84, 10); + surface_blit_trans(bmp, window->surface, 158, 10); + surface_blit_tint(bmp, window->surface, 232, 10, COLOR_RED); + surface_blit_blend_tint(bmp, window->surface, 306, 10, COLOR_RED); + + surface_blit_region(bmp, window->surface, 8, 8, 48, 48, 10, 84); + surface_blit_blend_region(bmp, window->surface, 8, 8, 48, 48, 84, 84); + surface_blit_trans_region(bmp, window->surface, 8, 8, 48, 48, 158, 84); + surface_blit_tint_region(bmp, window->surface, 8, 8, 48, 48, 232, 84, COLOR_RED); + surface_blit_blend_tint_region(bmp, window->surface, 8, 8, 48, 48, 306, 84, COLOR_RED); + + + while (true) { + if (!window_do_events(window)) + break; + if (input_is_key_down(KSYM_ESCAPE)) + break; + + window_render(window); + } + + surface_destroy(bmp); + + window_destroy(window); + input_destroy(); + log_end(); + + return 0; +}