Skip to content

Commit

Permalink
Merge branch 'master' into psector
Browse files Browse the repository at this point in the history
# Conflicts:
#	include/allegro5/internal/aintern_wjoydxnu.h
  • Loading branch information
arganoid committed May 19, 2021
2 parents 906a645 + 9de1840 commit 13a77c6
Show file tree
Hide file tree
Showing 98 changed files with 5,295 additions and 201 deletions.
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif(ANDROID)
option(ALLEGRO_SDL "Build using the SDL backend (experimental)" OFF)
option(WANT_STATIC_RUNTIME "Whether or not to link the C and C++ runtimes statically (currently only implemented on Windows)" OFF)

set(ALLEGRO_VERSION 5.2.7)
set(ALLEGRO_VERSION 5.2.8)
string(REGEX MATCH "^[0-9]+[.][0-9]+" ALLEGRO_SOVERSION ${ALLEGRO_VERSION})
string(REPLACE "." "" ALLEGRO_DLL_SHORTVER ${ALLEGRO_SOVERSION})

Expand Down Expand Up @@ -204,6 +204,12 @@ option(WANT_EXAMPLES "Build example programs" on)
option(WANT_POPUP_EXAMPLES "Use popups instead of printf for fatal errors" on)
option(WANT_TESTS "Build test programs" on)

option(WANT_WAIT_EVENT_SLEEP "Use sleep instead of threads in al_wait_for_event (only useful for emscripten without web workers)" off)

if(WANT_WAIT_EVENT_SLEEP)
set(ALLEGRO_WAIT_EVENT_SLEEP 1)
endif()

#-----------------------------------------------------------------------------#
#
# Set up compilers
Expand Down Expand Up @@ -418,6 +424,10 @@ if(COMPILER_GCC_OR_CLANG)
endif()
if(COMPILER_MSVC)
set(WFLAGS "/W3 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
# Clang is more strict than MSVC's compiler here.
set(WFLAGS "${WFLAGS} -Wno-c++11-narrowing")
endif()
endif(COMPILER_MSVC)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WFLAGS} ${WFLAGS_C_ONLY}")
Expand Down Expand Up @@ -903,8 +913,10 @@ if(MACOSX)
list(APPEND LIBRARY_SOURCES ${ALLEGRO_SRC_MACOSX_FILES})
find_library(APPKIT_LIBRARY AppKit)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREVIDEO_LIBRARY CoreVideo)
list(APPEND PLATFORM_LIBS ${APPKIT_LIBRARY})
list(APPEND PLATFORM_LIBS ${IOKIT_LIBRARY})
list(APPEND PLATFORM_LIBS ${COREVIDEO_LIBRARY})
endif(MACOSX)

if(IPHONE)
Expand Down Expand Up @@ -1075,6 +1087,7 @@ if(NOT MSVC80 AND WANT_DEMO) # XXX disabled because it breaks MSVC's intellisens
add_subdirectory(demos/cosmic_protector)
add_subdirectory(demos/speed)
add_subdirectory(demos/skater)
add_subdirectory(demos/shooter)
endif(NOT MSVC80 AND WANT_DEMO)

#-----------------------------------------------------------------------------#
Expand Down
122 changes: 122 additions & 0 deletions README_sdl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
SDL
===

This is an experimental port which uses SDL2 to create the Allegro
window and OpenGL context.


Dependencies
------------

SDL2 is required.


Building
--------

Pass -D ALLEGRO_SDL=on to cmake to enable building for SDL2.


Limitations
-----------

SDL2 requires calling SDL_PumpEvents() from the main thread regularly to
generate events. Currently Allegro5 makes those calls from the timer
subsystem - so as long as you have any timers running things will work
fine. If your Allegro 5 program uses no timers it may get stuck because
no SDL2 events can be received.


Emscripten
----------

One reason the SDL2 port is useful is that it allows running Allegro on
platforms not supported directly by Allegro, such as Emscripten. This is
even more experimental but here are some example steps that will compile
most of the examples for running in a web browser:

1. Make sure to set up the emscripten environment by running the

emsdk_env.sh

or equivalent as provided by emscripten.

2. Create a build folder.

mkdir build_emscripten
cd build_emscripten

3. The "--preload-file data" option below includes a folder named "data"
with each binary, so we make sure each example and demo has such a
folder:

mkdir -p demos/speed/data
demos/speed/data/nothing.txt

4. Configure CMake, using emcmake.

USE_FLAGS=(
-s USE_FREETYPE=1
-s USE_VORBIS=1
-s USE_OGG=1
-s USE_LIBJPEG=1
-s USE_SDL=2
-s USE_LIBPNG=1
-s FULL_ES2=1
-s ASYNCIFY
-s TOTAL_MEMORY=2147418112
-O3
)

emcmake cmake {path-to-allegro-source-folder}
-D CMAKE_BUILD_TYPE=Release
-D ALLEGRO_SDL=ON
-D SHARED=OFF
-D WANT_MONOLITH=ON
-D WANT_ALLOW_SSE=OFF
-D WANT_DOCS=OFF
-D WANT_TESTS=OFF
-D WANT_OPENAL=OFF
-D ALLEGRO_WAIT_EVENT_SLEEP=ON
# not sure why these are not found automatically with emcmake, so
# we use a hack - we manually specify the cache path, so cmake
# will fail on first run in the compile test but populate the cache
# (from the -s options) and on second run it all works
-D SDL2_INCLUDE_DIR=$EM_CACHE/sysroot/include
-D PNG_PNG_INCLUDE_DIR=$EM_CACHE/sysroot/include
-D PNG_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libpng.a
-D JPEG_INCLUDE_DIR=$EM_CACHE/sysroot/include
-D JPEG_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libjpeg.a
-D FREETYPE_INCLUDE_DIRS=$EM_CACHE/sysroot/include
-D FREETYPE_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libfreetype.a
-D VORBIS_INCLUDE_DIR=$EM_CACHE/sysroot/include/vorbis
-D VORBIS_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libvorbis.a
-D VORBISFILE_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libvorbis.a
-D OGG_INCLUDE_DIR=$EM_CACHE/sysroot/include
-D OGG_LIBRARY=$EM_CACHE/sysroot/lib/wasm32-emscripten/libogg.a
-D CMAKE_C_FLAGS="${USE_FLAGS}"
-D CMAKE_CXX_FLAGS="${USE_FLAGS}"
-D CMAKE_EXE_LINKER_FLAGS="${USE_FLAGS} --preload-file data"
-D CMAKE_EXECUTABLE_SUFFIX_CXX=".html"

Emscripten will take care of downloading the dependencies mentioned above via
its ports system.

To compile your own game adjust as necessary. You can use the
lib/liballegro_monolith-static.a library.

5. Compile the library and examples.

make

Since that can take awhile (a lot slower than regular compilation speed), you
may want to compile individual examples, e.g.

make ex_draw_bitmap

6. To run the examples, navigate to the examples folder. At this point it is
easiest to start a local webserver, and then navigate to the examples using a
web browser. E.g. you could use the Python's web server module which prints out
a URL you can open:

python3 -m http.server
22 changes: 22 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Security Policy

## Report a security issue

The Allegro project team welcomes security reports and is committed to
providing prompt attention to security issues. Security issues should be
reported privately by sending an email to
<[email protected]>.

## Version support

| Version | Supported |
| ------- | ------------------ |
| >= 5.2.x| Yes |
| < 5.2 | No |

## Security advisories

Remediation of security vulnerabilities is prioritized by the project team
based on the overall impact. The project team is committed to transparency in
the disclosure process. The Allegro team announces security issues Allegro
Release notes, as well as the Allegro website on a best-effort basis.
16 changes: 8 additions & 8 deletions addons/acodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ elseif(WANT_VORBIS)
find_package(Vorbis)
if(VORBIS_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
if(COMPILER_GCC_OR_CLANG)
if(MSVC)
set(CMAKE_REQUIRED_LIBRARIES "${VORBIS_LIBRARIES}")
else()
# libm is required when linking statically.
set(CMAKE_REQUIRED_LIBRARIES "${VORBIS_LIBRARIES};m")
else()
set(CMAKE_REQUIRED_LIBRARIES "${VORBIS_LIBRARIES}")
endif(COMPILER_GCC_OR_CLANG)
endif()
run_c_compile_test("
#include <vorbis/vorbisfile.h>
int main(void)
Expand Down Expand Up @@ -284,12 +284,12 @@ if(WANT_OPUS)
find_package(Opus)
if(OPUS_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OGG_INCLUDE_DIR} ${OPUS_INCLUDE_DIR})
if(COMPILER_GCC_OR_CLANG)
if(MSVC)
set(CMAKE_REQUIRED_LIBRARIES "${OPUS_LIBRARIES}")
else()
# libm is required when linking statically.
set(CMAKE_REQUIRED_LIBRARIES "${OPUS_LIBRARIES};m")
else()
set(CMAKE_REQUIRED_LIBRARIES "${OPUS_LIBRARIES}")
endif(COMPILER_GCC_OR_CLANG)
endif()
run_c_compile_test("
#include <opus/opusfile.h>
int main(void)
Expand Down
11 changes: 11 additions & 0 deletions addons/audio/sdl_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ static SDL_AudioFormat allegro_format_to_sdl(ALLEGRO_AUDIO_DEPTH d)
return AUDIO_F32;
}

static ALLEGRO_AUDIO_DEPTH sdl_format_to_allegro(SDL_AudioFormat d)
{
if (d == AUDIO_S8) return ALLEGRO_AUDIO_DEPTH_INT8;
if (d == AUDIO_U8) return ALLEGRO_AUDIO_DEPTH_UINT8;
if (d == AUDIO_S16) return ALLEGRO_AUDIO_DEPTH_INT16;
if (d == AUDIO_U16) return ALLEGRO_AUDIO_DEPTH_UINT16;
return ALLEGRO_AUDIO_DEPTH_FLOAT32;
}

static int sdl_allocate_voice(ALLEGRO_VOICE *voice)
{
SDL_VOICE *sv = al_malloc(sizeof *sv);
Expand All @@ -73,6 +82,8 @@ static int sdl_allocate_voice(ALLEGRO_VOICE *voice)

voice->extra = sv;
sv->voice = voice;
// we allow format change above so need to update here
voice->depth = sdl_format_to_allegro(sv->spec.format);

return 0;
}
Expand Down
24 changes: 12 additions & 12 deletions addons/primitives/high_primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ void al_draw_pieslice(float cx, float cy, float r, float start_theta,
}

if (thickness <= 0) {
num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf(r));
num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * r));

if (num_segments < 2)
num_segments = 2;
Expand Down Expand Up @@ -566,7 +566,7 @@ void al_draw_pieslice(float cx, float cy, float r, float start_theta,
vertex_cache[0].x = cx + (r - thickness / 2) * cosf(central_start_angle);
vertex_cache[0].y = cy + (r - thickness / 2) * sinf(central_start_angle);

num_segments = (inner_side_angle + outer_side_angle) / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf(r + ht);
num_segments = (inner_side_angle + outer_side_angle) / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * (r + ht));

if (num_segments < 2)
num_segments = 2;
Expand Down Expand Up @@ -620,7 +620,7 @@ void al_draw_pieslice(float cx, float cy, float r, float start_theta,
/* Apex: 2 vertices if the apex is blunt) */
int extra_vtx = blunt_tip ? 2 : 1;

num_segments = (2 * outer_side_angle) / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf(r + ht);
num_segments = (2 * outer_side_angle) / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * (r + ht));

if (num_segments < 2)
num_segments = 2;
Expand Down Expand Up @@ -669,7 +669,7 @@ void al_draw_filled_pieslice(float cx, float cy, float r, float start_theta,

ASSERT(r >= 0);

num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf(r));
num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * r));

if (num_segments < 2)
num_segments = 2;
Expand Down Expand Up @@ -701,7 +701,7 @@ void al_draw_ellipse(float cx, float cy, float rx, float ry,
ASSERT(ry >= 0);

if (thickness > 0) {
int num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f);
int num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f);
int ii;

/* In case rx and ry are both 0. */
Expand All @@ -720,7 +720,7 @@ void al_draw_ellipse(float cx, float cy, float rx, float ry,

al_draw_prim(vertex_cache, 0, 0, 0, 2 * num_segments, ALLEGRO_PRIM_TRIANGLE_STRIP);
} else {
int num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f);
int num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f);
int ii;

/* In case rx and ry are both 0. */
Expand Down Expand Up @@ -753,7 +753,7 @@ void al_draw_filled_ellipse(float cx, float cy, float rx, float ry,
ASSERT(rx >= 0);
ASSERT(ry >= 0);

num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f);
num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f);

/* In case rx and ry are both close to 0. If al_calculate_arc is passed
* 0 or 1 it will assert.
Expand Down Expand Up @@ -801,7 +801,7 @@ void al_draw_elliptical_arc(float cx, float cy, float rx, float ry, float start_

ASSERT(rx >= 0 && ry >= 0);
if (thickness > 0) {
int num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f));
int num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f));
int ii;

if (num_segments < 2)
Expand All @@ -820,7 +820,7 @@ void al_draw_elliptical_arc(float cx, float cy, float rx, float ry, float start_

al_draw_prim(vertex_cache, 0, 0, 0, 2 * num_segments, ALLEGRO_PRIM_TRIANGLE_STRIP);
} else {
int num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f));
int num_segments = fabs(delta_theta / (2 * ALLEGRO_PI) * ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f));
int ii;

if (num_segments < 2)
Expand Down Expand Up @@ -861,7 +861,7 @@ void al_draw_rounded_rectangle(float x1, float y1, float x2, float y2,
ASSERT(ry >= 0);

if (thickness > 0) {
int num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f) / 4;
int num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f) / 4;
int ii;

/* In case rx and ry are both 0. */
Expand Down Expand Up @@ -908,7 +908,7 @@ void al_draw_rounded_rectangle(float x1, float y1, float x2, float y2,

al_draw_prim(vertex_cache, 0, 0, 0, 8 * num_segments + 2, ALLEGRO_PRIM_TRIANGLE_STRIP);
} else {
int num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f) / 4;
int num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f) / 4;
int ii;

/* In case rx and ry are both 0. */
Expand Down Expand Up @@ -955,7 +955,7 @@ void al_draw_filled_rounded_rectangle(float x1, float y1, float x2, float y2,
LOCAL_VERTEX_CACHE;
int ii;
float scale = get_scale();
int num_segments = ALLEGRO_PRIM_QUALITY * scale * sqrtf((rx + ry) / 2.0f) / 4;
int num_segments = ALLEGRO_PRIM_QUALITY * sqrtf(scale * (rx + ry) / 2.0f) / 4;

ASSERT(rx >= 0);
ASSERT(ry >= 0);
Expand Down
7 changes: 7 additions & 0 deletions allegro5.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ config_selection=new
# card.
prim_d3d_legacy_detection=default

# For compatibility reasons, video bitmaps smaller than this size are
# backed by textures with this size. This is often no longer necessary
# on more modern systems, and should be set to < 16 if you're creating
# bitmaps smaller than this size. Note that on Android, this is ignored
# if smaller than 32.
min_bitmap_size=16

[audio]

# Driver can be 'default', 'openal', 'alsa', 'oss', 'pulseaudio' or 'directsound'
Expand Down
Loading

0 comments on commit 13a77c6

Please sign in to comment.