diff --git a/src/vm_screen.c b/src/vm_screen.c index 63ea86e..5495d3d 100644 --- a/src/vm_screen.c +++ b/src/vm_screen.c @@ -74,6 +74,7 @@ vm_screen_set_logical_coords(vm_screen *screen, int xcoords, int ycoords) int vm_screen_add_window(vm_screen *screen, int width, int height) { +#ifndef HEADLESS SDL_CreateWindowAndRenderer( width, height, 0, &screen->window, &screen->render); @@ -81,6 +82,7 @@ vm_screen_add_window(vm_screen *screen, int width, int height) log_critical("Could not create window: %s", SDL_GetError()); return ERR_GFXINIT; } +#endif // We plan to draw onto a surface that is xcoords x ycoords in area, // regardless of the actual size of the window. @@ -150,7 +152,9 @@ vm_screen_set_color(vm_screen *screen, uint8_t blue, uint8_t alpha) { - SDL_SetRenderDrawColor(screen->render, red, green, blue, alpha); + if (screen->render) { + SDL_SetRenderDrawColor(screen->render, red, green, blue, alpha); + } } /* diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f740453..dae0332 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,8 @@ project(erc-test) set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHEADLESS") + if(DEFINED ENV{STATIC_ANALYSIS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze") endif()