Created
June 12, 2018 14:01
-
-
Save saitoha/068cbcaf2a71c9966af2149ae3f2b0bd to your computer and use it in GitHub Desktop.
sixelized output for ssloy/tinyrenderer (https://github.com/ssloy/tinyrenderer)
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
diff --git a/Makefile b/Makefile | |
index 0b0a469..5cbdce8 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -1,7 +1,7 @@ | |
SYSCONF_LINK = g++ | |
CPPFLAGS = -Wall -Wextra -Weffc++ -pedantic -std=c++98 | |
LDFLAGS = -O3 | |
-LIBS = -lm | |
+LIBS = -lm -lsixel | |
DESTDIR = ./ | |
TARGET = main | |
diff --git a/main.cpp b/main.cpp | |
index 8ce61dd..436c734 100644 | |
--- a/main.cpp | |
+++ b/main.cpp | |
@@ -1,6 +1,7 @@ | |
#include <vector> | |
#include <limits> | |
#include <iostream> | |
+#include <sixel.h> | |
#include "tgaimage.h" | |
#include "model.h" | |
#include "geometry.h" | |
@@ -86,8 +87,14 @@ int main(int argc, char** argv) { | |
delete model; | |
} | |
frame.flip_vertically(); // to place the origin in the bottom left corner of the image | |
- frame.write_tga_file("framebuffer.tga"); | |
- | |
+ sixel_encoder_t *encoder = NULL; | |
+ if (SIXEL_SUCCEEDED(sixel_encoder_new(&encoder, NULL))) { | |
+ if (SIXEL_FAILED(sixel_encoder_encode_bytes( | |
+ encoder, frame.buffer(), width, height, SIXEL_PIXELFORMAT_BGR888, NULL, (-1)))) { | |
+ std::cerr << "failed to output sixels.\n"; | |
+ } | |
+ sixel_encoder_unref(encoder); | |
+ } | |
delete [] zbuffer; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ make && ./main obj/african_head/.obj obj/.obj

This patch is in Public Domain. Have fun!