-
Notifications
You must be signed in to change notification settings - Fork 109
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
Backface culling, basic lighting, terminal improvements #29
base: master
Are you sure you want to change the base?
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
int main(void) | ||
{ | ||
signal(SIGINT, sig_handler); | ||
printf("\033[?25l"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hide cursor at start
void sig_handler(int signo) | ||
{ | ||
if (signo == SIGINT) { | ||
printf("\033[?25h"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show cursor when exiting
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\u2584 is the lower half block: ▄
@@ -109,7 +164,7 @@ Olivec_Canvas vc_render(float dt) | |||
olivec_blend_color(&OLIVEC_PIXEL(oc, x, y), (v<<(3*8))); | |||
} | |||
} | |||
} | |||
} else if (has_entered) break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit early if the triangle was previously entered since it isn't possible to re-enter.