mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-21 08:30:55 +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:
parent
5b35e2294e
commit
8146687110
@ -74,6 +74,7 @@ vm_screen_set_logical_coords(vm_screen *screen, int xcoords, int ycoords)
|
|||||||
int
|
int
|
||||||
vm_screen_add_window(vm_screen *screen, int width, int height)
|
vm_screen_add_window(vm_screen *screen, int width, int height)
|
||||||
{
|
{
|
||||||
|
#ifndef HEADLESS
|
||||||
SDL_CreateWindowAndRenderer(
|
SDL_CreateWindowAndRenderer(
|
||||||
width, height, 0, &screen->window, &screen->render);
|
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());
|
log_critical("Could not create window: %s", SDL_GetError());
|
||||||
return ERR_GFXINIT;
|
return ERR_GFXINIT;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// We plan to draw onto a surface that is xcoords x ycoords in area,
|
// We plan to draw onto a surface that is xcoords x ycoords in area,
|
||||||
// regardless of the actual size of the window.
|
// regardless of the actual size of the window.
|
||||||
@ -150,7 +152,9 @@ vm_screen_set_color(vm_screen *screen,
|
|||||||
uint8_t blue,
|
uint8_t blue,
|
||||||
uint8_t alpha)
|
uint8_t alpha)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(screen->render, red, green, blue, alpha);
|
if (screen->render) {
|
||||||
|
SDL_SetRenderDrawColor(screen->render, red, green, blue, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4,6 +4,8 @@ project(erc-test)
|
|||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHEADLESS")
|
||||||
|
|
||||||
if(DEFINED ENV{STATIC_ANALYSIS})
|
if(DEFINED ENV{STATIC_ANALYSIS})
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze")
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user