Backface culling, basic lighting, terminal improvements#29
Open
matt-meeks wants to merge 3 commits intotsoding:masterfrom
Open
Backface culling, basic lighting, terminal improvements#29matt-meeks wants to merge 3 commits intotsoding:masterfrom
matt-meeks wants to merge 3 commits intotsoding:masterfrom
Conversation
matt-meeks
commented
Apr 15, 2023
- Backface culling (frontface also available)
- Simple dot product based lighting
- Double terminal "pixel" density by using half block character with both foreground and background colors
- Hide terminal cursor
- Early exit of row when no longer inside triangle
matt-meeks
commented
Apr 15, 2023
| int main(void) | ||
| { | ||
| signal(SIGINT, sig_handler); | ||
| printf("\033[?25l"); |
matt-meeks
commented
Apr 15, 2023
| void sig_handler(int signo) | ||
| { | ||
| if (signo == SIGINT) { | ||
| printf("\033[?25h"); |
matt-meeks
commented
Apr 15, 2023
demos/vc.c
Outdated
| for (size_t x = 0; x < vc_term_scaled_down_width; ++x) { | ||
| // TODO: explore the idea of figuring out aspect ratio of the character using escape ANSI codes of the terminal and rendering the image accordingly | ||
| printf("\033[48;5;%dm ", vc_term_char_canvas[y*vc_term_scaled_down_width + x]); | ||
| printf("\033[48;5;%dm\033[38;5;%dm%s", vc_term_char_canvas[y*vc_term_scaled_down_width + x], vc_term_char_canvas[y*vc_term_scaled_down_width + vc_term_scaled_down_width + x], "\u2584"); |
Author
There was a problem hiding this comment.
\u2584 is the lower half block: ▄
matt-meeks
commented
Apr 15, 2023
| } | ||
| } | ||
| } | ||
| } else if (has_entered) break; |
Author
There was a problem hiding this comment.
Exit early if the triangle was previously entered since it isn't possible to re-enter.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.