add basic blit tests (visual only)
This commit is contained in:
parent
4e05c7735d
commit
b3f10ef272
|
@ -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})
|
||||
|
|
52
test/test_blit.c
Normal file
52
test/test_blit.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include <stdio.h>
|
||||
#include "vm/vm.h"
|
||||
#include <fbgfx/surface.h>
|
||||
#include <vm/vm_window.h>
|
||||
|
||||
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;
|
||||
}
|
Reference in a new issue