mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-22 08:25:45 -07:00
Add draw_polygon_fallback() for platforms without a native polygon fill.
This adds a portable, scanline-based polygon filling algorithm, which fills a polygon by drawing a collection of adjacent horizontal lines. This change is motivated by the Rockbox port's current lack of a true polygon fill capability. Until now, it attempted to approximate a polygon fill by performing a series of triangle fills, but this worked reliably only for convex polygons. I originally considered making this new rasterizer part of the Rockbox front end itself, but I ultimately decided that it made more sense to include it here, in the Puzzles distribution, where other platforms may benefit from it in the future. No in-tree front ends use this new function quite yet, but I plan to follow this commit with a compile-time option to force front ends to use it for testing. This new polygon drawing code also comes with its own standalone driver code to test it out in isolation. This code currently relies on SDL 2.0 to present a GUI window to the user, which unfortunately adds a build-time dependency. To lessen the impact of this change, this program is gated behind a CMake build option. To use it, run: $ cmake -DBUILD_SDL_PROGRAMS=true
This commit is contained in:

committed by
Simon Tatham

parent
4149f2cb9c
commit
989df5d2bf
@ -7,6 +7,7 @@ set(build_cli_programs TRUE)
|
||||
set(build_gui_programs TRUE)
|
||||
set(build_icons FALSE)
|
||||
set(need_c_icons FALSE)
|
||||
option(BUILD_SDL_PROGRAMS "build test programs requiring SDL" FALSE)
|
||||
|
||||
# Don't disable assertions, even in release mode. Our assertions
|
||||
# generally aren't expensive and protect against more annoying crashes
|
||||
@ -148,7 +149,7 @@ endfunction()
|
||||
# a command-line helper tool.
|
||||
function(cliprogram NAME)
|
||||
cmake_parse_arguments(OPT
|
||||
"CORE_LIB" "" "COMPILE_DEFINITIONS" ${ARGN})
|
||||
"CORE_LIB;SDL2_LIB" "" "COMPILE_DEFINITIONS" ${ARGN})
|
||||
|
||||
if(OPT_CORE_LIB)
|
||||
set(lib core)
|
||||
@ -156,13 +157,18 @@ function(cliprogram NAME)
|
||||
set(lib common)
|
||||
endif()
|
||||
|
||||
if(build_cli_programs)
|
||||
if(build_cli_programs AND ((NOT OPT_SDL2_LIB) OR BUILD_SDL_PROGRAMS))
|
||||
add_executable(${NAME} ${CMAKE_SOURCE_DIR}/nullfe.c
|
||||
${OPT_UNPARSED_ARGUMENTS})
|
||||
target_link_libraries(${NAME} ${lib} ${platform_libs})
|
||||
if(OPT_COMPILE_DEFINITIONS)
|
||||
target_compile_definitions(${NAME} PRIVATE ${OPT_COMPILE_DEFINITIONS})
|
||||
endif()
|
||||
if(OPT_SDL2_LIB)
|
||||
find_package(SDL2 REQUIRED)
|
||||
include_directories(${NAME} ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(${NAME} ${SDL2_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
Reference in New Issue
Block a user