Compare commits

..

2 Commits

Author SHA1 Message Date
Eigen Lenk
83f1fc24fa
Merge 9fe588ace6 into 766325c395 2025-02-20 09:34:39 +13:00
Eigen Lenk
9fe588ace6 [Renderers/Allegro4] Add Allegro 4.x renderer and demo 2025-02-17 10:28:30 +02:00
4 changed files with 54 additions and 4 deletions

View File

@ -9,6 +9,7 @@ option(CLAY_INCLUDE_CPP_EXAMPLE "Build C++ example" OFF)
option(CLAY_INCLUDE_RAYLIB_EXAMPLES "Build raylib examples" OFF)
option(CLAY_INCLUDE_SDL2_EXAMPLES "Build SDL 2 examples" OFF)
option(CLAY_INCLUDE_SDL3_EXAMPLES "Build SDL 3 examples" OFF)
option(CLAY_INCLUDE_ALLEGRO4_EXAMPLE "Build Allegro 4.x example" OFF)
message(STATUS "CLAY_INCLUDE_DEMOS: ${CLAY_INCLUDE_DEMOS}")
@ -33,6 +34,9 @@ endif ()
if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_SDL2_EXAMPLES)
add_subdirectory("examples/SDL2-video-demo")
endif ()
if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_ALLEGRO4_EXAMPLE)
add_subdirectory("examples/allegro4-demo")
endif ()
if(NOT MSVC AND (CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_SDL3_EXAMPLES))
add_subdirectory("examples/SDL3-simple-demo")
endif()

View File

@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.27)
project(allegro4_demo C)
set(CMAKE_C_STANDARD 99)
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
# Fetch pre-built MinGW binaries
FetchContent_Declare(
allegro4
URL https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/A443Deluxe.7z
)
FetchContent_MakeAvailable(allegro4)
link_directories(${allegro4_SOURCE_DIR}/lib/)
add_executable(allegro4_demo main.c ../../renderers/alleg4/alleg4.c)
target_compile_options(allegro4_demo PUBLIC)
target_include_directories(allegro4_demo PUBLIC . ${CMAKE_SOURCE_DIR} ${allegro4_SOURCE_DIR}/include/)
# All global variables Allegro makes available are lost when linking statically,
# at least not when extern-ing all over the place.
target_link_libraries(allegro4_demo PUBLIC alleg44.dll.a)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
add_custom_command(TARGET allegro4_demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${allegro4_SOURCE_DIR}/bin/dlls/alleg44.dll"
$<TARGET_FILE_DIR:allegro4_demo>
)
add_custom_command(
TARGET allegro4_demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/res
${CMAKE_CURRENT_BINARY_DIR}/res)

View File

@ -1,3 +0,0 @@
# Allegro 4 demo
To build this demo on your system of choice, include all source files in this directory, as well as in "renderers/alleg4" and link with a 4.x version of Allegro. It's probably easiest to go with a pre-built binary.

View File

@ -483,4 +483,13 @@ int main(int argc, char *argv[]) {
return 0;
}
END_OF_MAIN()
#ifdef _WIN32
#include <WinDef.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
return main(__argc, __argv);
}
#endif