Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
bgem-linux-build-x64:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
distro:
- ubuntu:24.04
- fedora:43
- archlinux:latest
- opensuse/tumbleweed
container:
image: ${{ matrix.distro }}
steps:
- uses: actions/checkout@v6
- name: Bootstrap
run: ./bootstrap-bgem.sh
- name: Configure
run: cmake --preset debug
- name: Build
run: ninja -C build/debug

#
# There are no ARM runners of Linux for public GitHub repositories yet
#

# bgem-linux-build-arm:
# runs-on: ubuntu-24.04-arm
# strategy:
# fail-fast: true
# matrix:
# distro:
# - ubuntu:24.04
# - fedora:43
# - archlinux:latest
# - opensuse/tumbleweed
# container:
# image: ${{ matrix.distro }}
# steps:
# - uses: actions/checkout@v6
# - name: Bootstrap
# run: ./bootstrap-bgem.sh
# - name: Configure
# run: cmake --preset debug
# - name: Build
# run: ninja -C build/debug

bgem-windows-build:
runs-on: windows-2025-vs2026
strategy:
matrix:
arch:
- amd64
- amd64_arm64
steps:
- uses: actions/checkout@v6
- name: Setup MSVC environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
# The command has to be prefixed with "./" because it is
# written add executed under a PowerShell shell instance.
# I have to keep this in mind if I debug scripts.
- name: Bootstrap
run: .\bootstrap-bgem.cmd
- name: Configure
run: cmake --preset debug
- name: Build
run: ninja -C build/debug

bgem-macos-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Bootstrap
run: ./bootstrap-bgem.sh
- name: Configure
run: cmake --preset debug
- name: Build
run: ninja -C build/debug
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Project Bluegem main build generated by cmake
/build/
/include/bgem_version.h

# Down below is generated using gitignore.io for ignoring common files

Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28)

project(bgem LANGUAGES C CXX)
project(bgem VERSION 0.1.0 LANGUAGES C CXX)

if(APPLE)
enable_language(OBJC)
Expand All @@ -26,8 +26,16 @@ else ()
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND_EGL REQUIRED IMPORTED_TARGET wayland-egl)
endif ()
find_package(imgui CONFIG REQUIRED)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(compiler_options)
include(version)

configure_file(
include/bgem_version.h.in
${CMAKE_SOURCE_DIR}/include/bgem_version.h
@ONLY
)

add_subdirectory(source)
11 changes: 11 additions & 0 deletions assets/shaders/blit/fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#version 300 es

precision mediump float;

in vec2 vUV;
uniform sampler2D uTex;
out vec4 fragColor;

void main() {
fragColor = texture(uTex, vUV);
}
9 changes: 9 additions & 0 deletions assets/shaders/blit/vertex.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 300 es

in vec2 aPos;
out vec2 vUV;

void main() {
vUV = aPos * 0.5 + 0.5;
gl_Position = vec4(aPos, 0.0, 1.0);
}
8 changes: 6 additions & 2 deletions assets/shaders/testshader/fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#version 300 es

precision mediump float;

uniform float uTime;
varying vec2 vUV;
in vec2 vUV;

out vec4 fragColor;

void main()
{
float r = 0.5 + 0.5 * sin(uTime + vUV.x * 6.2831);
float g = 0.5 + 0.5 * sin(uTime + vUV.y * 6.2831);
float b = 0.5 + 0.5 * sin(uTime);

gl_FragColor = vec4(r, g, b, 1.0);
fragColor = vec4(r, g, b, 1.0);
}
8 changes: 5 additions & 3 deletions assets/shaders/testshader/vertex.glsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
attribute vec2 aPos;
varying vec2 vUV;
#version 300 es

in vec2 aPos;
out vec2 vUV;

void main()
{
vUV = aPos * 0.5 + 0.5; // map from [-1,1] → [0,1]
vUV = aPos * 0.5 + 0.5;
gl_Position = vec4(aPos, 0.0, 1.0);
}
27 changes: 16 additions & 11 deletions cmake/compiler_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ set_target_properties(compiler_options PROPERTIES
INTERFACE_C_STANDARD 23
INTERFACE_C_STANDARD_REQUIRED ON
INTERFACE_C_EXTENSIONS OFF
INTERFACE_COMPILE_WARNING_AS_ERROR ON
COMPILE_WARNING_AS_ERROR ON
)

if (WIN32)
target_compile_definitions(compiler_options INTERFACE UNICODE _UNICODE)
endif()

# Add Compiler Flags
target_compile_options(compiler_options INTERFACE
$<$<C_COMPILER_ID:MSVC>:
/W4
/Zc:preprocessor
/W4;
/Zc:preprocessor;
$<$<CONFIG:Debug>:/Zi>
>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>:
-Wall
-Wextra
-Wpedantic
-Wall;
-Wextra;
-Wpedantic;
$<$<C_COMPILER_ID:AppleClang>:-Wno-variadic-macro-arguments-omitted>;
$<$<CONFIG:Debug>:-g>
>
)
Expand All @@ -37,19 +42,19 @@ option(ENABLE_ASAN_UBSAN "Enable ASan + UBsan" OFF)
if (ENABLE_ASAN_UBSAN)
target_compile_options(compiler_options INTERFACE
$<$<C_COMPILER_ID:MSVC>:
/fsanitize=address
/fsanitize=address;
>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>:
-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=undefined
-fsanitize=address,undefined; -fno-omit-frame-pointer; -fno-sanitize-recover=undefined
>
)
target_link_options(compiler_options INTERFACE
$<$<C_COMPILER_ID:MSVC>:
/fsanitize=address
/incremental:no
/fsanitize=address;
/incremental:no;
>
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>:
-fsanitize=address,undefined
-fsanitize=address,undefined;
>
)
endif()
25 changes: 25 additions & 0 deletions cmake/macos/Info.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>@MACOSX_BUNDLE_BUNDLE_NAME@</string>
<key>CFBundleIdentifier</key>
<string>@MACOSX_BUNDLE_GUI_IDENTIFIER@</string>
<key>CFBundleVersion</key>
<string>@MACOSX_BUNDLE_BUNDLE_VERSION@</string>
<key>CFBundleShortVersionString</key>
<string>@MACOSX_BUNDLE_SHORT_VERSION_STRING@</string>
<key>CFBundleExecutable</key>
<string>@MACOSX_BUNDLE_EXECUTABLE_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSMultipleInstancesProhibited</key>
<true/>
</dict>
</plist>
23 changes: 23 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
find_package(Git QUIET)

if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE BGEM_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE BGEM_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
else()
set(BGEM_GIT_HASH "unknown")
set(BGEM_GIT_BRANCH "unknown")
endif()

set(BGEM_VERSION_LABEL "pre-alpha")
11 changes: 11 additions & 0 deletions include/app/app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* MIT License
* Copyright (c) 2026 Cătălin Gabriel Drăghiță
*/

#ifndef APP_H
#define APP_H

int bgem_app_init(void);

#endif // APP_H
15 changes: 15 additions & 0 deletions include/bgem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* MIT License
* Copyright (c) 2026 Cătălin Gabriel Drăghiță
*/

#ifndef BGEM_H
#define BGEM_H

#define BGEM__WIDE(s) L##s
#define BGEM_WIDE(s) BGEM__WIDE(s)

#define BGEM_APP_NAME "Project Bluegem"
#define BGEM_APP_NAME_W BGEM_WIDE(BGEM_APP_NAME)

#endif // BGEM_H
15 changes: 15 additions & 0 deletions include/bgem_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef BGEM_VERSION_H
#define BGEM_VERSION_H

#define BGEM_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define BGEM_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define BGEM_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define BGEM_VERSION_LABEL "@BGEM_VERSION_LABEL@"
#define BGEM_VERSION_GIT_HASH "@BGEM_GIT_HASH@"
#define BGEM_VERSION_GIT_BRANCH "@BGEM_GIT_BRANCH@"

#define BGEM_VERSION_STRING \
"@PROJECT_VERSION@-@BGEM_VERSION_LABEL@" \
" (" "@BGEM_GIT_BRANCH@" "@" "@BGEM_GIT_HASH@" ")"

#endif // BGEM_VERSION_H
16 changes: 16 additions & 0 deletions include/core/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define DEBUG_H

#include <stdio.h>
#include <SDL3/SDL.h>

/* Basic console debug line printing */
#ifdef DEBUG
Expand All @@ -15,4 +16,19 @@
#define DEBUG_PRINT(fmt, ...) do {} while (0)
#endif

#ifdef __cplusplus
extern "C" {
#endif

void bgem_debug_init(SDL_Window *window);
void bgem_debug_shutdown(void);
void bgem_debug_toggle(void);
void bgem_debug_newFrame(void);
void bgem_debug_render(void);
int bgem_debug_isActive(void);

#ifdef __cplusplus
}
#endif

#endif /* DEBUG_H */
23 changes: 23 additions & 0 deletions include/platform/platform_egl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* MIT License
* Copyright (c) 2026 Cătălin Gabriel Drăghiță
*/

/*
* Multiplatform abstraction
*/

#ifndef PLATFORM_EGL_H
#define PLATFORM_EGL_H

#include <SDL3/SDL.h>

typedef struct bgem_platform_windowContext bgem_platform_windowContext;

/* Create graphics context attached to SDL window */
bgem_platform_windowContext* bgem_platform_createContext(SDL_Window *window);
void bgem_platform_swapBuffers(bgem_platform_windowContext *platformContext);
void bgem_platform_waylandResizeSurface(bgem_platform_windowContext *platformContext, int w, int h);
void bgem_platform_destroyContext(bgem_platform_windowContext *platformContext);

#endif //PLATFORM_EGL_H
18 changes: 18 additions & 0 deletions include/platform/platform_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* MIT License
* Copyright (c) 2026 Cătălin Gabriel Drăghiță
*/

#ifndef PLATFORM_INIT_H
#define PLATFORM_INIT_H

typedef enum {
BGEM_INSTANCE_LOCK_OK,
BGEM_INSTANCE_LOCK_ALREADY_RUNNING,
BGEM_INSTANCE_LOCK_ERROR,
} bgem_instance_lockStatus;

bgem_instance_lockStatus bgem_platform_instanceLock(void);
void bgem_platform_instanceUnlock(void);

#endif // PLATFORM_INIT_H
Loading
Loading