Skip to content

Commit

Permalink
Merge pull request #17 from learn-more/SDL3
Browse files Browse the repository at this point in the history
Add megasource support for SDL3
  • Loading branch information
slime73 authored Apr 18, 2024
2 parents 2c85430 + d62935c commit 3ead449
Show file tree
Hide file tree
Showing 1,775 changed files with 811,681 additions and 7 deletions.
29 changes: 22 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ project(megasource)

set(MEGA TRUE)

option(LOVE_USE_SDL3 "Use SDL3 instead of SDL2" OFF)

set (CMAKE_CXX_STANDARD 11)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down Expand Up @@ -222,6 +224,7 @@ set(MEGA_LIBVORBIS_VER "1.3.5")
set(MEGA_LIBTHEORA_VER "1.1.1")
set(MEGA_FREETYPE_VER "2.13.2")
set(MEGA_SDL2_VER "2.28.5")
set(MEGA_SDL3_VER "3.1.1-preview")
set(MEGA_OPENAL_VER "1.23.1-bc7cb17")
set(MEGA_MODPLUG_VER "0.8.8.4")

Expand Down Expand Up @@ -277,18 +280,29 @@ message(STATUS "-----------------------------------------------------")
add_subdirectory("libs/harfbuzz" ${CMAKE_BINARY_DIR}/harfbuzz)
set(MEGA_HARFBUZZ harfbuzz)

message(STATUS "-----------------------------------------------------")
message(STATUS "Configuring: SDL2 ${MEGA_SDL2_VER}")
message(STATUS "-----------------------------------------------------")
if(WIN32 AND MEGA_ARM64)
# In Windows, SDL always tries to open OpenGL32.dll, which is not available in Windows ARM64.
# This will cause error later on which makes love.window.setMode unhappy even when
# LOVE_GRAPHICS_USE_OPENGLES is set, so disable OpenGL backend.
set(SDL_OPENGL OFF CACHE BOOL "(SDL) Enable OpenGL Backend" FORCE)
endif()
add_subdirectory("libs/SDL2" ${CMAKE_BINARY_DIR}/SDL2)
set(MEGA_SDL2 SDL2)
set(MEGA_SDL2MAIN SDL2main)
if (LOVE_USE_SDL3)
message(STATUS "-----------------------------------------------------")
message(STATUS "Configuring: SDL3 ${MEGA_SDL3_VER}")
message(STATUS "-----------------------------------------------------")
add_subdirectory("libs/SDL3" ${CMAKE_BINARY_DIR}/SDL3)
set(MEGA_SDL3 SDL3-shared)
set(MEGA_SDL2 )
set(MEGA_SDL2MAIN )
else()
message(STATUS "-----------------------------------------------------")
message(STATUS "Configuring: SDL2 ${MEGA_SDL2_VER}")
message(STATUS "-----------------------------------------------------")
add_subdirectory("libs/SDL2" ${CMAKE_BINARY_DIR}/SDL2)
set(MEGA_SDL2 SDL2)
set(MEGA_SDL2MAIN SDL2main)
set(MEGA_SDL3 )
endif()

message(STATUS "-----------------------------------------------------")
message(STATUS "Configuring: openal-soft ${MEGA_OPENAL_VER}")
Expand Down Expand Up @@ -390,6 +404,7 @@ set(MEGA_3P
${MEGA_LIBVORBISFILE}
${MEGA_LIBTHEORA}
${MEGA_FREETYPE}
${MEGA_SDL3}
${MEGA_SDL2}
${MEGA_SDL2MAIN}
${MEGA_OPENAL}
Expand Down Expand Up @@ -423,6 +438,6 @@ link_directories(${SDL_LINK_DIR})
add_executable(megatest src/test.cpp)
target_link_libraries(megatest ${MEGA_3P})

add_move_dll(megatest ${MEGA_SDL2})
add_move_dll(megatest ${MEGA_SDL2} ${MEGA_SDL3})
add_move_dll(megatest ${MEGA_OPENAL})
add_move_dll(megatest ${MEGA_LUA51})
91 changes: 91 additions & 0 deletions libs/SDL3/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine

# Custom brace breaking
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeElse: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true

# Make the closing brace of container literals go to a new line
Cpp11BracedListStyle: false

# Never format includes
IncludeBlocks: Preserve
# clang-format version 4.0 through 12.0:
#SortIncludes: false
# clang-format version 13.0+:
#SortIncludes: Never

# No length limit, in case it breaks macros, you can
# disable it with /* clang-format off/on */ comments
ColumnLimit: 0

IndentWidth: 4
ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: NoIndent

PointerAlignment: Right
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false

UseCRLF: false
UseTab: Never

ForEachMacros:
[
"spa_list_for_each",
"spa_list_for_each_safe",
"wl_list_for_each",
"wl_list_for_each_safe",
"wl_array_for_each",
"udev_list_entry_foreach",
]

---

59 changes: 59 additions & 0 deletions libs/SDL3/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
Checks: >
-*,
bugprone-assert-side-effect,
bugprone-assignment-in-if-condition,
bugprone-bool-pointer-implicit-conversion,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-not-null-terminated-result,
bugprone-posix-return,
bugprone-redundant-branch-condition,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-memset-usage,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-too-small-loop-variable,
bugprone-unused-return-value,
cert-err33-c,
clang-analyzer-core.*,
clang-analyzer-valist.*,
clang-analyzer-unix.Malloc,
clang-diagnostic-*,
google-readability-casting,
misc-misleading-bidirectional,
misc-misleading-identifier,
misc-misplaced-const,
misc-redundant-expression,
objc-*,
performance-type-promotion-in-math-fn,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
readability-duplicate-include,
readability-inconsistent-declaration-parameter-name,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-preprocessor,
readability-simplify-boolean-expr
CheckOptions:
- key: bugprone-assert-side-effect.AssertMacros
value: "SDL_assert, SDL_assert_release, SDL_assert_paranoid, SDL_assert_always, SDL_COMPILE_TIME_ASSERT"
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: true
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
value: false # Do not recommend _s functions

FormatStyle: "file"
HeaderFilterRegex: "*.h$"
WarningsAsErrors: ""
69 changes: 69 additions & 0 deletions libs/SDL3/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# For format see editorconfig.org
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: Zlib

root = true

[*.{c,cc,cg,cpp,gradle,h,java,m,metal,pl,py,S,sh,txt}]
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{html,js,json,m4,yml,yaml,vcxproj,vcxproj.filters}]
indent_size = 2
indent_style = space
trim_tailing_whitespace = true

[*.xml]
indent_size = 4
indent_style = space

[{CMakeLists.txt,cmake/*.cmake}]
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{cmake/cmake_uninstall.cmake.in,test/CMakeLists.txt,cmake/SDL3Config.cmake.in}]
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{Makefile.*,*.mk,*.sln,*.pbxproj,*.plist}]
indent_size = 8
indent_style = tab
tab_width = 8

[src/joystick/controller_type.*]
indent_style = tab

[src/joystick/hidapi/steam/*.h]
indent_style = tab

[src/libm/*.c]
indent_style = tab

[src/test/SDL_test_{crc32,md5,random}.c]
indent_size = 2
indent_style = space

[src/video/yuv2rgb/*.{c,h}]
indent_style = tab

[wayland-protocols/*.xml]
indent_size = 2
indent_style = space

[*.{markdown,md}]
indent_size = 4
indent_style = space
# Markdown syntax treats tabs as 4 spaces
tab_width = 4

[{*.bat,*.rc}]
end_of_line = crlf

[*.cocci]'
insert_final_newline = true
1 change: 1 addition & 0 deletions libs/SDL3/.git-hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17d4f8d6990d2bd92d6a8be4b23c4dc1626fb923
19 changes: 19 additions & 0 deletions libs/SDL3/.wikiheaders-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
projectfullname = SDL
projectshortname = SDL
incsubdir = include/SDL3
wikisubdir =
readmesubdir = docs
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
mainincludefname = SDL3/SDL.h
versionfname = include/SDL3/SDL_version.h
versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z
versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z
selectheaderregex = \ASDL.*?\.h\Z
projecturl = https://libsdl.org/
wikiurl = https://wiki.libsdl.org
bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new
warn_about_missing = 0
wikipreamble = (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!)
wikiheaderfiletext = Defined in [%fname%](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/%fname%), but apps should _only_ `#include <SDL3/SDL.h>`!
manpageheaderfiletext = Defined in %fname%, but apps should only #include <SDL3/SDL.h>!
Loading

0 comments on commit 3ead449

Please sign in to comment.