add color format visual verification test

This commit is contained in:
Gered 2015-01-19 00:16:58 -05:00
parent f25efe3d04
commit 4e05c7735d
2 changed files with 42 additions and 0 deletions

View file

@ -24,3 +24,6 @@ target_link_libraries("test_primitives" ${SDL2_LIBRARY})
add_executable("test_surfaces" "${TESTS_DIR}/test_surfaces.c" ${LIB_SRC_FILES})
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})

39
test/test_color_format.c Normal file
View file

@ -0,0 +1,39 @@
#include <stdio.h>
#include "vm/vm.h"
#include <fbgfx/surface.h>
int main(int argc, char **argv) {
log_init();
input_init();
WINDOW *window = window_init("test_color_format", 1024, 768, 320, 240);
if (!window)
return 1;
int step = 0;
while (step < 4) {
if (!window_do_events(window))
break;
if (input_is_key_down(KSYM_ESCAPE))
break;
if (input_is_key_pressed(KSYM_SPACE))
++step;
// obviously requiring visual confirmation that the color being rendered is
// the one specified in the code ...
switch (step) {
case 0: surface_clear(window->surface, color_create_rgb(0, 0, 0)); break;
case 1: surface_clear(window->surface, color_create_rgb(255, 0, 0)); break;
case 2: surface_clear(window->surface, color_create_rgb(0, 255, 0)); break;
case 3: surface_clear(window->surface, color_create_rgb(0, 0, 255)); break;
}
window_render(window);
}
window_destroy(window);
input_destroy();
log_end();
return 0;
}