Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c062679
some formatting
AlemSnyder Oct 1, 2025
7d05ad5
Create User Interface
AlemSnyder Nov 29, 2025
c99359f
widget data and shader
AlemSnyder Nov 30, 2025
d47a3e4
Frame borders
AlemSnyder Nov 30, 2025
6dd7194
Read and write byte image
AlemSnyder Dec 1, 2025
f0e211c
read m int texture
AlemSnyder Dec 3, 2025
c47d578
correct frame render
AlemSnyder Dec 6, 2025
a714584
splash screen
AlemSnyder Dec 10, 2025
64dc5ad
write graphics main function
AlemSnyder Dec 10, 2025
3f3a771
switch around graphics entrypoint
AlemSnyder Dec 10, 2025
3957aee
refactoring
AlemSnyder Dec 13, 2025
cb14f29
frame searching
AlemSnyder Dec 13, 2025
ff7338d
click position
AlemSnyder Dec 14, 2025
c9946a0
two windows, and I can click them
AlemSnyder Dec 14, 2025
95b0ab7
fix bugs with clicking position
AlemSnyder Dec 15, 2025
cebf178
fix uniforms in fragment shader
AlemSnyder Dec 15, 2025
483a50e
differentiate widget and frame
AlemSnyder Dec 19, 2025
a5c0242
fix widget rendering
AlemSnyder Dec 19, 2025
28742f5
change to visitor pattern
AlemSnyder Dec 19, 2025
a95b817
load texture from file
AlemSnyder Dec 21, 2025
6d01690
button widget
AlemSnyder Dec 21, 2025
d6a8b62
some fixes to framed rendering
AlemSnyder Dec 21, 2025
c19702e
refactoring
AlemSnyder Dec 22, 2025
d3389d4
almost working texture loading
AlemSnyder Dec 23, 2025
d7001c7
writing fonts works
AlemSnyder Dec 24, 2025
15e53ea
write text render shader
AlemSnyder Dec 29, 2025
aab95cb
add frame size uniform
AlemSnyder Dec 29, 2025
6a36324
add ui scale
AlemSnyder Dec 29, 2025
d794184
generate text spacing
AlemSnyder Dec 30, 2025
2205028
fix image orientation
AlemSnyder Dec 31, 2025
ac139e5
transpose data for gpu
AlemSnyder Jan 7, 2026
ec7a610
remove write image call and refactor
AlemSnyder Jan 8, 2026
3d02847
fixes to memory errors
AlemSnyder Jan 11, 2026
6010b0d
fixed some memory errors
AlemSnyder Jan 12, 2026
699d70b
Render Multiple characters in text
AlemSnyder Jan 24, 2026
4dc2432
text placement instructions
AlemSnyder Jan 24, 2026
1f96a6d
Add space to font
AlemSnyder Jan 31, 2026
3f7c5ec
Line wrapping in text widget.
AlemSnyder Jan 31, 2026
358a723
sizes are positive
AlemSnyder Feb 6, 2026
e171f03
save font sizes
AlemSnyder Feb 6, 2026
96c318f
copy fonts to release
AlemSnyder Feb 6, 2026
441608c
Merge branch 'main' into GUI/UI
AlemSnyder Feb 6, 2026
d3ef02a
Merge branch 'main' into GUI/UI
AlemSnyder Feb 6, 2026
23241f7
add freetype package
AlemSnyder Feb 20, 2026
afd1106
Include expected to fix clang error
AlemSnyder Feb 25, 2026
0785fdd
maybe this will fix clang
AlemSnyder Feb 27, 2026
118d3ae
formatting
AlemSnyder Feb 28, 2026
b34fa99
more formatting, and light changes
AlemSnyder Feb 28, 2026
44b32d5
Merge branch 'GUI/UI' of https://github.com/AlemSnyder/Fun-Game into …
AlemSnyder Feb 28, 2026
219bf6d
Revert "maybe this will fix clang"
AlemSnyder Feb 28, 2026
68f8f4b
maybe clang 19
AlemSnyder Mar 3, 2026
6b993fa
apt install
AlemSnyder Mar 3, 2026
2fbd532
Set Color with uniform
AlemSnyder Mar 3, 2026
886d59a
comments
AlemSnyder Mar 7, 2026
fb88da7
fixed ascender height
AlemSnyder May 20, 2026
a31cc12
todos and warnings
AlemSnyder May 20, 2026
e518e58
Merge branch 'main' into GUI/UI
AlemSnyder Jun 1, 2026
5a5d09d
formatting and comments
AlemSnyder Jun 6, 2026
cccc931
comment for button widget
AlemSnyder Jun 6, 2026
3cafaf6
formatting
AlemSnyder Jun 6, 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
3 changes: 2 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
libglew-dev \
libglm-dev \
libomp-17-dev \
libpng-dev
libpng-dev \
libfreetype-dev


- name: Build
Expand Down
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
# find_package(OpenMP REQUIRED)

target_link_libraries(FunGame PRIVATE glfw)
target_link_libraries(FunGame PRIVATE OpenGL::GL)
target_link_libraries(FunGame PRIVATE GLEW::GLEW)
target_link_libraries(FunGame PRIVATE PNG::PNG)
# target_link_libraries(FunGame PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(FunGame PRIVATE Freetype::Freetype)

if(WIN32)
target_link_libraries(FunGame PRIVATE glm)
Expand Down Expand Up @@ -138,8 +139,17 @@ else()
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

add_custom_target(fonts
# maybe vendor is already made by something else?
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/vendor/fonts
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/vendor/fonts ${CMAKE_BINARY_DIR}/vendor/fonts
COMMENT " copying ${CMAKE_SOURCE_DIR}/vendor/fonts to ${CMAKE_BINARY_DIR}/vendor/fonts "
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

add_dependencies(FunGame resources)
add_dependencies(FunGame data)
add_dependencies(FunGame fonts)
endif()

configure_file(src/config.h.in config.h)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pacman -Su \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-glew \
mingw-w64-x86_64-glfw \
mingw-w64-x86_64-glm
mingw-w64-x86_64-glm \
mingw-w64-x86_64-freetype
```

## Building
Expand Down
87 changes: 87 additions & 0 deletions resources/shaders/overlay/FramedWindow.frag
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#version 450 core

// Ouput data
layout(location = 0) out vec3 color;

in vec2 UV; // in pixels
uniform ivec2 frame_size;
uniform usampler2D window_texture;
uniform int ui_scale;

// uniform
uniform ivec4 border_size;
uniform ivec4 side_lengths;
uniform ivec2 inner_pattern_size;
uniform ivec2 positions[9];

void
main(){
int width_2 = side_lengths[0];
int height_4 = side_lengths[1];
int width_5 = inner_pattern_size[0];
int height_5 = inner_pattern_size[1];
int height_6 = side_lengths[2];
int width_8 = side_lengths[3];

ivec2 pixel_position = ivec2(int(UV.x), int(UV.y));
ivec2 ui_position = pixel_position / ui_scale;
ivec2 frame_size_px = frame_size / ui_scale;

ivec2 texture_offset;

// The window is arranged like this
// 0 | 1 | 2
// ---+---+---
// 3 | 4 | 5
// ---+---+---
// 6 | 7 | 8
//
if (ui_position.y < border_size[1] && ui_position.x < border_size[0]) { // 0
ivec2 local_position = ivec2(ui_position.x, ui_position.y);
texture_offset = local_position + positions[0];
}
else if (ui_position.y < border_size[1] && frame_size_px.x - ui_position.x - 1 < border_size[2]) { // 2
ivec2 local_position = ivec2(ui_position.x - frame_size_px.x + border_size[2], ui_position.y);
texture_offset = local_position + positions[2];
}
else if ((frame_size_px.y - ui_position.y - 1 < border_size[3]) && ui_position.x < border_size[0]) { // 6
ivec2 local_position = ivec2(ui_position.x, ui_position.y - frame_size_px.y + border_size[3]);
texture_offset = local_position + positions[6];
}
else if ((frame_size_px.y - ui_position.y - 1 < border_size[3]) && (frame_size_px.x - ui_position.x - 1 < border_size[2])) { // 8
ivec2 local_position = ivec2(ui_position.x - frame_size_px.x + border_size[2], ui_position.y - frame_size_px.y + border_size[3]);
texture_offset = local_position + positions[8];
}
else if (ui_position.x < border_size[0]) { // 3
ivec2 local_position = ivec2(ui_position.x, ui_position.y - border_size[1]);
local_position.y = local_position.y % height_4;
texture_offset = local_position + positions[3];
}
else if (ui_position.y < border_size[1]) { // 1
ivec2 local_position = ivec2(ui_position.x, ui_position.y);
local_position.x = local_position.x % width_2;
texture_offset = local_position + positions[1];
}
else if ((frame_size_px.x - ui_position.x) <= border_size[3]) { // 5
ivec2 local_position = ivec2(border_size[2] - frame_size_px.x + ui_position.x, ui_position.y - border_size[3]);
local_position.y = local_position.y % height_6;
texture_offset = local_position + positions[5];
}
else if ((frame_size_px.y - ui_position.y) <= border_size[3]) { // 7
ivec2 local_position = ivec2(ui_position.x - border_size[2], ui_position.y - frame_size_px.y + border_size[3]);
local_position.x = local_position.x % width_8;
texture_offset = local_position + positions[7];
} else { // 4
ivec2 local_position = ivec2(ui_position.x - border_size[0], ui_position.y - border_size[1]);
local_position.x = local_position.x % width_5;
local_position.y = local_position.y % height_5;
texture_offset = positions[4] + local_position;
}

uvec4 color_int = texelFetch(window_texture, texture_offset, 0);
if (color_int.a == 0) {
discard;
}

color = vec3(color_int.rgb)/255.0;
}
23 changes: 23 additions & 0 deletions resources/shaders/overlay/TextWindow.frag
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 450 core


// Ouput data
layout(location = 0) out vec3 color;

uniform usampler2D font_texture;
// right now only using the rgb components
// may in the future use the alpha component
uniform vec4 font_color;

in vec2 UV;

void
main() {
uint alpha = texelFetch(font_texture, ivec2(UV), 0).r;

if (alpha > 0) {
color = font_color.rgb;
} else {
discard;
}
}
21 changes: 21 additions & 0 deletions resources/shaders/overlay/TextWindow.vert
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#version 450 core

// Screen and texture position of letter
layout(location = 0) in ivec4 pos;

// this is the size of the view
// then switch to division
uniform ivec2 frame_size;
uniform int ui_scale;

// Output data ; will be interpolated for each fragment.
out vec2 UV;

void
main() {

gl_Position = vec4(ui_scale * (vec2(pos.xy) / vec2(frame_size)) - 1, 1, 1);
UV = vec2(pos.w, pos.z);
//UV = vec2((pos.z - 304) * 20, pos.w * 2);
}

15 changes: 15 additions & 0 deletions resources/shaders/overlay/Widget.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 450 core

// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 pos;
layout(location = 1) in vec2 vertex_position_screenspace;

// Output data ; will be interpolated for each fragment.
out vec2 UV;

void
main() {
gl_Position = vec4(pos, 1);
UV = vertex_position_screenspace;
}

57 changes: 57 additions & 0 deletions resources/textures/GenericBorder.json
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"texture_file": "./GenericBorder.png",
"border_size": [
5,
5,
5,
5
],
"side_lengths": [
1,
1,
1,
1
],
"inner_pattern_size": [
1,
1
],
"texture_regions": [
[
0,
0
],
[
5,
0
],
[
6,
0
],
[
0,
5
],
[
5,
5
],
[
6,
5
],
[
0,
6
],
[
5,
6
],
[
6,
6
]
]
}
Binary file added resources/textures/GenericBorder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions resources/textures/GenericBorder_2.json
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"texture_file": "./GenericBorder_2.png",
"border_size": [
7,
7,
7,
7
],
"side_lengths": [
10,
10,
10,
10
],
"inner_pattern_size": [
10,
10
],
"texture_regions": [
[
0,
0
],
[
6,
0
],
[
15,
0
],
[
0,
6
],
[
6,
6
],
[
15,
6
],
[
0,
15
],
[
6,
15
],
[
15,
15
]
]
}
Binary file added resources/textures/GenericBorder_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions resources/textures/GenericButton.json
Comment thread
AlemSnyder marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"texture_file": "./GenericButton.png",
"border_size": [
5,
5,
5,
5
],
"side_lengths": [
1,
1,
1,
1
],
"inner_pattern_size": [
1,
1
],
"texture_regions": [
[
0,
0
],
[
5,
0
],
[
6,
0
],
[
0,
5
],
[
5,
5
],
[
6,
5
],
[
0,
6
],
[
5,
6
],
[
6,
6
]
]
}
Binary file added resources/textures/GenericButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
namespace exc {

class file_not_found_error : public std::runtime_error {
constexpr static std::string ERROR_PREFIX_ = "Could not open ";
constexpr static std::string_view ERROR_PREFIX_ = "Could not open ";

std::filesystem::path path_;

public:
file_not_found_error(std::filesystem::path path) :
runtime_error(ERROR_PREFIX_ + path.string()), path_(std::move(path)) {}
runtime_error(std::move(std::string(ERROR_PREFIX_) + path.string())),
path_(std::move(path)) {}

file_not_found_error(const file_not_found_error& other) noexcept = default;

Expand Down
Loading
Loading