mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Add support to compile with shared Allegro 4 library.
This commit is contained in:
parent
9c37384d3b
commit
c4c44bf7e2
@ -35,6 +35,7 @@ option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
|
||||
option(USE_SHARED_JPEGLIB "Use your installed copy of jpeglib" off)
|
||||
option(USE_SHARED_ZLIB "Use your installed copy of zlib" off)
|
||||
option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
|
||||
option(USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support)" off)
|
||||
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
|
||||
option(ENABLE_UPDATER "Enable automatic check for updates" on)
|
||||
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
||||
@ -80,8 +81,10 @@ set(TINYXML_DIR ${CMAKE_SOURCE_DIR}/third_party/tinyxml)
|
||||
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/zlib)
|
||||
|
||||
# Allegro header files
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/allegro/include)
|
||||
include_directories(${CMAKE_BINARY_DIR}/include)
|
||||
if(NOT USE_SHARED_ALLEGRO4)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/allegro/include)
|
||||
include_directories(${CMAKE_BINARY_DIR}/include)
|
||||
endif()
|
||||
|
||||
# Zlib generated zconf.h file
|
||||
include_directories(${CMAKE_BINARY_DIR}/third_party/zlib)
|
||||
|
@ -86,13 +86,38 @@ if(ENABLE_UPDATER)
|
||||
add_definitions(-DENABLE_UPDATER)
|
||||
endif()
|
||||
|
||||
if(USE_SHARED_ALLEGRO4)
|
||||
# Find the shared Allegro 4 library
|
||||
find_library(LIBALLEGRO4_LIBRARY alleg)
|
||||
find_path(LIBALLEGRO4_INCLUDE_DIR allegro.h)
|
||||
|
||||
if(NOT LIBALLEGRO4_LIBRARY)
|
||||
message(FATAL_ERROR "Allegro 4 not found")
|
||||
endif()
|
||||
|
||||
# Get flags to link programs using allegro-config program
|
||||
execute_process(COMMAND allegro-config --libs --shared
|
||||
OUTPUT_VARIABLE LIBALLEGRO4_LINK_FLAGS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
include_directories(${LIBALLEGRO4_INCLUDE_DIR})
|
||||
|
||||
# The config.c must be from the last implementation from 4.4 (the
|
||||
# 4.2 can have a broken override_config_file() impl).
|
||||
set(EXTRA_SOURCE_FILES allegro/src/config.c)
|
||||
else()
|
||||
# Use patched version of Allegro 4 (with window resize support).
|
||||
add_subdirectory(allegro)
|
||||
set(libs3rdparty ${libs3rdparty} allegro)
|
||||
add_definitions(-DALLEGRO4_WITH_RESIZE_PATCH)
|
||||
endif()
|
||||
|
||||
# All libraries for .exe files
|
||||
set(all_libs ${aseprite_libraries} ${libs3rdparty} allegro ${sys_libs})
|
||||
set(all_libs ${aseprite_libraries} ${libs3rdparty} ${sys_libs})
|
||||
|
||||
######################################################################
|
||||
# Sub-libraries
|
||||
# ASEPRITE libraries
|
||||
|
||||
add_subdirectory(allegro)
|
||||
add_subdirectory(base)
|
||||
add_subdirectory(filters)
|
||||
add_subdirectory(gfx)
|
||||
@ -103,10 +128,8 @@ if(ENABLE_UPDATER)
|
||||
add_subdirectory(updater)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# aseprite library
|
||||
|
||||
add_library(aseprite-library
|
||||
${EXTRA_SOURCE_FILES}
|
||||
app.cpp
|
||||
check_args.cpp
|
||||
console.cpp
|
||||
@ -350,7 +373,7 @@ add_library(aseprite-library
|
||||
widgets/toolbar.cpp)
|
||||
|
||||
######################################################################
|
||||
# aseprite application
|
||||
# ASEPRITE application
|
||||
|
||||
if(WIN32)
|
||||
set(win32_resources resources_win32.rc)
|
||||
@ -361,8 +384,11 @@ if(UNIX)
|
||||
endif(UNIX)
|
||||
|
||||
add_executable(aseprite WIN32 main.cpp ${win32_resources} ${x11_resources})
|
||||
|
||||
target_link_libraries(aseprite ${all_libs})
|
||||
if(LIBALLEGRO4_LINK_FLAGS)
|
||||
set_target_properties(aseprite
|
||||
PROPERTIES LINK_FLAGS ${LIBALLEGRO4_LINK_FLAGS})
|
||||
endif()
|
||||
|
||||
install(TARGETS aseprite
|
||||
RUNTIME DESTINATION bin)
|
||||
@ -389,8 +415,11 @@ function(find_unittests dir dependencies)
|
||||
get_filename_component(testname ${testsourcefile} NAME_WE)
|
||||
|
||||
add_executable(${testname} ${testsourcefile})
|
||||
|
||||
target_link_libraries(${testname} gtest ${ARGV})
|
||||
if(LIBALLEGRO4_LINK_FLAGS)
|
||||
set_target_properties(${testname}
|
||||
PROPERTIES LINK_FLAGS ${LIBALLEGRO4_LINK_FLAGS})
|
||||
endif()
|
||||
|
||||
add_custom_target(run_${testname}
|
||||
COMMAND ${testname}
|
||||
@ -403,7 +432,7 @@ endfunction()
|
||||
|
||||
find_unittests(base base-lib ${sys_libs})
|
||||
find_unittests(gfx gfx-lib base-lib ${sys_libs})
|
||||
find_unittests(gui gui-lib gfx-lib base-lib ${libs3rdparty} allegro ${sys_libs})
|
||||
find_unittests(gui gui-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
||||
find_unittests(app ${all_libs})
|
||||
find_unittests(. ${all_libs})
|
||||
|
||||
|
@ -176,6 +176,7 @@ static void display_switch_in_callback()
|
||||
|
||||
END_OF_STATIC_FUNCTION(display_switch_in_callback);
|
||||
|
||||
#ifdef ALLEGRO4_WITH_RESIZE_PATCH
|
||||
// Called when the window is resized
|
||||
static void resize_callback(RESIZE_DISPLAY_EVENT *ev)
|
||||
{
|
||||
@ -185,6 +186,7 @@ static void resize_callback(RESIZE_DISPLAY_EVENT *ev)
|
||||
}
|
||||
next_idle_flags |= SYSTEM_WINDOW_RESIZE;
|
||||
}
|
||||
#endif // ALLEGRO4_WITH_RESIZE_PATCH
|
||||
|
||||
// Initializes GUI.
|
||||
int init_module_gui()
|
||||
@ -299,8 +301,10 @@ gfx_done:;
|
||||
// Setup the GUI theme for all widgets
|
||||
CurrentTheme::set(ase_theme = new SkinTheme());
|
||||
|
||||
#ifdef ALLEGRO4_WITH_RESIZE_PATCH
|
||||
// Setup the handler for window-resize events
|
||||
set_resize_callback(resize_callback);
|
||||
#endif
|
||||
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
if (maximized) {
|
||||
@ -472,6 +476,7 @@ void gui_run()
|
||||
|
||||
void gui_feedback()
|
||||
{
|
||||
#ifdef ALLEGRO4_WITH_RESIZE_PATCH
|
||||
if (next_idle_flags & SYSTEM_WINDOW_RESIZE) {
|
||||
next_idle_flags ^= SYSTEM_WINDOW_RESIZE;
|
||||
|
||||
@ -482,6 +487,7 @@ void gui_feedback()
|
||||
app_get_top_window()->remap_window();
|
||||
jmanager_refresh_screen();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (next_idle_flags & REFRESH_FULL_SCREEN) {
|
||||
next_idle_flags ^= REFRESH_FULL_SCREEN;
|
||||
|
@ -145,7 +145,11 @@ void TransformHandles::drawHandles(Editor* editor, const gfx::Transformation& tr
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
BITMAP* gfx = theme->get_part(PART_PIVOT_HANDLE);
|
||||
|
||||
#if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION >= 4
|
||||
draw_sprite_ex(bmp, gfx, pivotBounds.x, pivotBounds.y, DRAW_SPRITE_TRANS, DRAW_SPRITE_NO_FLIP);
|
||||
#else
|
||||
draw_trans_sprite(bmp, gfx, pivotBounds.x, pivotBounds.y);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +187,11 @@ void TransformHandles::drawHandle(BITMAP* bmp, int x, int y, fixed angle)
|
||||
|
||||
adjustHandle(x, y, gfx->w, gfx->h, angle);
|
||||
|
||||
#if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION >= 4
|
||||
draw_sprite_ex(bmp, gfx, x, y, DRAW_SPRITE_TRANS, DRAW_SPRITE_NO_FLIP);
|
||||
#else
|
||||
draw_trans_sprite(bmp, gfx, x, y);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TransformHandles::adjustHandle(int& x, int& y, int handle_w, int handle_h, fixed angle)
|
||||
|
Loading…
x
Reference in New Issue
Block a user