Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9a8c60e
Add SDL3 and an initial sample window
dertseha Jul 25, 2026
00f40d2
Add libxcursor-dev for SDL3 on 32bit machine
dertseha Jul 25, 2026
6fa07e1
Disable xcursor dependency. Fails on i686 build, yet may be because o…
dertseha Jul 25, 2026
5c64ba9
Add more dependencies as per SDL3 documentation
dertseha Jul 25, 2026
42e90e9
Specify libraries for 32bit more explicitly, add one as per solution …
dertseha Jul 25, 2026
9fb283a
Remove unknown package again
dertseha Jul 25, 2026
b3f016b
Make all libraries :i386
dertseha Jul 25, 2026
6768ec3
Remove :i386 specifier again for package group
dertseha Jul 25, 2026
de689f1
mesa-utils also don't come in :i386. back to hand-picking libraries t…
dertseha Jul 25, 2026
f2badc4
Exclude GoogleTest from installation package
dertseha Jul 25, 2026
88b4bc4
Disable screensaver support; attempt to re-enable xcursor dependency
dertseha Jul 25, 2026
3f02bb0
Include MinGW libraries in distribution package if needed
dertseha Jul 25, 2026
c191bc3
xcursor dependency seems to work now; removing xtest dependency
dertseha Jul 25, 2026
c51b37f
Make release build under MS Windows a non-console application
dertseha Jul 25, 2026
cda5bb5
Ignore directory of JetBrains IDE
dertseha Jul 25, 2026
d54a965
Move application sources into separate folder, like libraries
dertseha Jul 25, 2026
0a1c27b
Add icon resource for MS Windows
dertseha Jul 25, 2026
e2b7705
Move resources for MS Windows into "mswin" folder. is now more consis…
dertseha Jul 25, 2026
7ac5ef1
Disable various SDL features probably not necessary
dertseha Jul 25, 2026
9486409
re-enable things that otherwise break builds for msdos and macos
dertseha Jul 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
arch: i686
runner: ubuntu-24.04
toolchain_file: 'i686-gcc.cmake'
extra_packages: 'gcc-multilib g++-multilib mesa-utils mesa-common-dev:i386 xorg-dev libxrandr-dev'
extra_packages: 'gcc-multilib g++-multilib mesa-utils mesa-common-dev:i386 xorg-dev libxrandr-dev:i386 libxcursor-dev:i386 libxi-dev:i386'

# MS Windows builds
- os: mswin
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# JetBrains IDEs (CLion)
.idea
.junie
cmake-build-*
49 changes: 48 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,33 @@ if (NOT DOS)
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
OVERRIDE_FIND_PACKAGE
EXCLUDE_FROM_ALL
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
endif ()

FetchContent_Declare(
SDL
GIT_REPOSITORY https://github.com/libsdl-org/SDL
# This is a semi-random tag after 3.14.12, but before a release
# It includes MS DOS support.
GIT_TAG 855cbec702f246661ff00a0bce9e0683012840c2
EXCLUDE_FROM_ALL
)
set(SDL_SHARED OFF CACHE BOOL "Disabled SDL shared lib" FORCE)
set(SDL_STATIC ON CACHE BOOL "Enabled SDL static lib" FORCE)
set(SDL_TEST OFF CACHE BOOL "Disable SDL Test" FORCE)
set(SDL_INSTALL OFF CACHE BOOL "Disable SDL installation" FORCE)
set(SDL_DISKAUDIO OFF CACHE BOOL "Disable SDL support for disk audio" FORCE)
set(SDL_CAMERA OFF CACHE BOOL "Disable SDL support for camera" FORCE)
set(SDL_X11_XSCRNSAVER OFF CACHE BOOL "Disable SDL xscreensaver dependency" FORCE)
set(SDL_X11_XTEST OFF CACHE BOOL "Disable SDL xtest dependency" FORCE)
set(SDL_GPU_OPENXR OFF CACHE BOOL "Disable SDL OpenXR support" FORCE)
FetchContent_MakeAvailable(SDL)

file(GLOB_RECURSE LIB_CORE_SOURCES "${PROJECT_SOURCE_DIR}/core/main/source/*.c")
add_library(hacked-core STATIC ${LIB_CORE_SOURCES})
target_include_directories(hacked-core PUBLIC "${PROJECT_SOURCE_DIR}/core/main/include")
Expand All @@ -37,11 +57,38 @@ if (NOT DOS)
gtest_add_tests(TARGET hacked-core-test EXTRA_ARGS --gtest_shuffle)
endif ()

add_executable(hacked main.c)
if (WIN32)
enable_language(RC)
set(APP_GUI_WIN_RESOURCES app/mswin/hacked.rc)
endif ()
set(APP_GUI_SOURCES app/source/main.c ${APP_GUI_WIN_RESOURCES})
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_executable(hacked ${APP_GUI_SOURCES})
else ()
add_executable(hacked WIN32 ${APP_GUI_SOURCES})
endif ()
target_link_libraries(hacked
hacked-core
SDL3::SDL3-static
)

# Toolchains may define extra libraries that should be included in the distribution.
# This is primarily for MinGW, which needs some runtime libraries along with it.
if (DEFINED TOOLCHAIN_DLL_DEPENDENCIES)
foreach (DLL ${TOOLCHAIN_DLL_DEPENDENCIES})
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-file-name=${DLL}
OUTPUT_VARIABLE DLL_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (EXISTS "${DLL_PATH}" AND NOT "${DLL_PATH}" STREQUAL "${DLL}")
install(FILES "${DLL_PATH}" DESTINATION .)
else ()
message(WARNING "DLL '${DLL}' not resolved - it will be missing in the package")
endif ()
endforeach ()
endif ()

install(TARGETS hacked
RUNTIME DESTINATION .
)
Binary file added app/mswin/hacked.ico
Binary file not shown.
1 change: 1 addition & 0 deletions app/mswin/hacked.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100 ICON "hacked.ico"
55 changes: 55 additions & 0 deletions app/source/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#define SDL_MAIN_USE_CALLBACKS 1
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

static SDL_Window *window = NULL;
static SDL_Renderer *renderer = NULL;

SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
*appstate = NULL;

SDL_SetAppMetadata("InkyBlackness - HackEd", "1.0", "io.github.inkyblackness.hacked");
if (!SDL_Init(SDL_INIT_VIDEO))
{
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!SDL_CreateWindowAndRenderer("InkyBlackness - HackEd", 320, 200, SDL_WINDOW_RESIZABLE, &window, &renderer))
{
SDL_Log("Couldn't create window/renderer: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
SDL_SetRenderLogicalPresentation(renderer, 320, 200, SDL_LOGICAL_PRESENTATION_LETTERBOX);

return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT)
{
return SDL_APP_SUCCESS;
}
return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppIterate(void *appstate)
{
const double now = ((double)SDL_GetTicks()) / 1000.0;
/* choose the color for the frame we will draw. The sine wave trick makes it fade between colors smoothly. */
const float red = (float)(0.5 + 0.5 * SDL_sin(now));
const float green = (float)(0.5 + 0.5 * SDL_sin(now + SDL_PI_D * 2 / 3));
const float blue = (float)(0.5 + 0.5 * SDL_sin(now + SDL_PI_D * 4 / 3));
SDL_SetRenderDrawColorFloat(renderer, red, green, blue, SDL_ALPHA_OPAQUE_FLOAT); /* new color, full alpha. */

SDL_RenderClear(renderer);

SDL_RenderPresent(renderer);
return SDL_APP_CONTINUE;
}

void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
SDL_Log("Quitting");
}
2 changes: 2 additions & 0 deletions cmake/toolchains/i686-w64-mingw32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# CMake determines how to examine dependencies based on the *host* system, leading to
# a `file unknown error` unless the target platform is explicitly specified.
set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe")

set(TOOLCHAIN_DLL_DEPENDENCIES libgcc_s_dw2-1.dll)
13 changes: 0 additions & 13 deletions main.c

This file was deleted.