Skip to content

Conversation

matt-meeks
Copy link

  • 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");
Copy link
Author

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");
Copy link
Author

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");
Copy link
Author

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;
Copy link
Author

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.

@matt-meeks matt-meeks marked this pull request as ready for review April 15, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants