-
Notifications
You must be signed in to change notification settings - Fork 0
Many things for widget system #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlemSnyder
wants to merge
60
commits into
main
Choose a base branch
from
GUI/UI
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
c062679
some formatting
AlemSnyder 7d05ad5
Create User Interface
AlemSnyder c99359f
widget data and shader
AlemSnyder d47a3e4
Frame borders
AlemSnyder 6dd7194
Read and write byte image
AlemSnyder f0e211c
read m int texture
AlemSnyder c47d578
correct frame render
AlemSnyder a714584
splash screen
AlemSnyder 64dc5ad
write graphics main function
AlemSnyder 3f3a771
switch around graphics entrypoint
AlemSnyder 3957aee
refactoring
AlemSnyder cb14f29
frame searching
AlemSnyder ff7338d
click position
AlemSnyder c9946a0
two windows, and I can click them
AlemSnyder 95b0ab7
fix bugs with clicking position
AlemSnyder cebf178
fix uniforms in fragment shader
AlemSnyder 483a50e
differentiate widget and frame
AlemSnyder a5c0242
fix widget rendering
AlemSnyder 28742f5
change to visitor pattern
AlemSnyder a95b817
load texture from file
AlemSnyder 6d01690
button widget
AlemSnyder d6a8b62
some fixes to framed rendering
AlemSnyder c19702e
refactoring
AlemSnyder d3389d4
almost working texture loading
AlemSnyder d7001c7
writing fonts works
AlemSnyder 15e53ea
write text render shader
AlemSnyder aab95cb
add frame size uniform
AlemSnyder 6a36324
add ui scale
AlemSnyder d794184
generate text spacing
AlemSnyder 2205028
fix image orientation
AlemSnyder ac139e5
transpose data for gpu
AlemSnyder ec7a610
remove write image call and refactor
AlemSnyder 3d02847
fixes to memory errors
AlemSnyder 6010b0d
fixed some memory errors
AlemSnyder 699d70b
Render Multiple characters in text
AlemSnyder 4dc2432
text placement instructions
AlemSnyder 1f96a6d
Add space to font
AlemSnyder 3f7c5ec
Line wrapping in text widget.
AlemSnyder 358a723
sizes are positive
AlemSnyder e171f03
save font sizes
AlemSnyder 96c318f
copy fonts to release
AlemSnyder 441608c
Merge branch 'main' into GUI/UI
AlemSnyder d3ef02a
Merge branch 'main' into GUI/UI
AlemSnyder 23241f7
add freetype package
AlemSnyder afd1106
Include expected to fix clang error
AlemSnyder 0785fdd
maybe this will fix clang
AlemSnyder 118d3ae
formatting
AlemSnyder b34fa99
more formatting, and light changes
AlemSnyder 44b32d5
Merge branch 'GUI/UI' of https://github.com/AlemSnyder/Fun-Game into …
AlemSnyder 219bf6d
Revert "maybe this will fix clang"
AlemSnyder 68f8f4b
maybe clang 19
AlemSnyder 6b993fa
apt install
AlemSnyder 2fbd532
Set Color with uniform
AlemSnyder 886d59a
comments
AlemSnyder fb88da7
fixed ascender height
AlemSnyder a31cc12
todos and warnings
AlemSnyder e518e58
Merge branch 'main' into GUI/UI
AlemSnyder 5a5d09d
formatting and comments
AlemSnyder cccc931
comment for button widget
AlemSnyder 3cafaf6
formatting
AlemSnyder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
|
AlemSnyder marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
|
AlemSnyder marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
|
AlemSnyder marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ] | ||
| ] | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
|
AlemSnyder marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ] | ||
| ] | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
|
AlemSnyder marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ] | ||
| ] | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.