Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions demos/dots3d.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"

float sqrtf(float x);
Expand Down
1 change: 1 addition & 0 deletions demos/model3d.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"

#define WIDTH 960
Expand Down
1 change: 1 addition & 0 deletions demos/squish.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"
#include "./assets/tsodinPog.c"

Expand Down
1 change: 1 addition & 0 deletions demos/triangle.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"

#define WIDTH 960
Expand Down
1 change: 1 addition & 0 deletions demos/triangle3d.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"

#define WIDTH 960
Expand Down
1 change: 1 addition & 0 deletions demos/triangle3dTex.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define VC_TERM_SCALE_DOWN_FACTOR 10
#define VC_TRUECOLOR
#include "vc.c"
#include "./assets/tsodinPog.c"
#include "./assets/oldstone.c"
Expand Down
1 change: 1 addition & 0 deletions demos/triangleTex.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define VC_TRUECOLOR
#include "vc.c"
#include "assets/tsodinPog.c"

Expand Down
13 changes: 13 additions & 0 deletions demos/vc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// // vc.c expectes render() to be defined and also supplies it's own entry point
// // if needed (some platforms like WASM_PLATFORM do not have the main()
// // entry point)
// add #define VC_TRUECOLOR for truecolor support
// #include "vc.c"
//
// #define WIDTH 800
Expand Down Expand Up @@ -531,19 +532,28 @@ static void vc_term_compress_pixels(Olivec_Canvas oc)
int g = OLIVEC_GREEN(cp);
int b = OLIVEC_BLUE(cp);
int a = OLIVEC_ALPHA(cp);
#ifndef VC_TRUECOLOR
r = a*r/255;
g = a*g/255;
b = a*b/255;
int h, s, l;
rgb_to_hsl(r, g, b, &h, &s, &l);
vc_term_char_canvas[y*vc_term_scaled_down_width + x] = find_ansi_index_by_hsl(h, s, l);
#else
printf("\033[48;2;%d;%d;%dm ", r, g, b);
#endif
}
#ifdef VC_TRUECOLOR
printf("\033[0m\n");
#endif
}
}

int main(void)
{
for (;;) {

#ifndef VC_TRUECOLOR
vc_term_compress_pixels(vc_render(1.f/60.f));
for (size_t y = 0; y < vc_term_scaled_down_height; ++y) {
for (size_t x = 0; x < vc_term_scaled_down_width; ++x) {
Expand All @@ -552,6 +562,9 @@ int main(void)
}
printf("\033[0m\n");
}
#else
vc_term_compress_pixels(vc_render(1.f/60.f));
#endif

usleep(1000*1000/60);
printf("\033[%zuA", vc_term_scaled_down_height);
Expand Down