1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-30 06:29:48 +00:00

Don't create a window when testing

We do this by creating the notion of a "headless" mode, and skip window
creation in SDL.
This commit is contained in:
Peter Evans 2017-12-26 17:06:08 -06:00
parent 5b35e2294e
commit 8146687110
2 changed files with 7 additions and 1 deletions

View File

@ -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,8 +152,10 @@ vm_screen_set_color(vm_screen *screen,
uint8_t blue,
uint8_t alpha)
{
if (screen->render) {
SDL_SetRenderDrawColor(screen->render, red, green, blue, alpha);
}
}
/*
* Draw a rectangle on the screen at a given x/y position, with a given

View File

@ -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()