aboutsummaryrefslogtreecommitdiffstats
path: root/vexnc.c
diff options
context:
space:
mode:
author1024x22024-07-16 02:03:54 +0100
committer1024x22024-07-16 02:25:00 +0100
commit2283a9e345f63b9298f3f5af3d912837294f6074 (patch)
treef73e830b7cb1b4970318ce53f966fad0ea441ed3 /vexnc.c
Initial kermit
Diffstat (limited to 'vexnc.c')
-rw-r--r--vexnc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/vexnc.c b/vexnc.c
new file mode 100644
index 0000000..51cd483
--- /dev/null
+++ b/vexnc.c
@@ -0,0 +1,33 @@
+// gcc -O2 -march=native -o vexnc vexnc.c -lvncserver -lm
+
+#include <rfb/rfb.h>
+
+#define STB_IMAGE_IMPLEMENTATION
+#include "stb_image.h"
+
+int main(int argc, char const *argv[]) {
+ if (argc < 3) {
+ printf("usage: %s IMAGEFILE TITLE\n", argv[0]);
+ return 0;
+ }
+
+ int imx, imy, imc;
+ unsigned char *im = stbi_load(argv[1], &imx, &imy, &imc, 4);
+ if (im == NULL) {
+ printf("bad image: %s\n", stbi_failure_reason());
+ return 1;
+ }
+
+ rfbScreenInfoPtr rfbScreen = rfbGetScreen(NULL, NULL, imx, imy, 8, 3, 4);
+ rfbScreen->desktopName = argv[2] ? argv[2] : "";
+ rfbScreen->frameBuffer = (char*)im;
+ rfbScreen->alwaysShared = TRUE;
+
+ rfbInitServer(rfbScreen);
+ rfbRunEventLoop(rfbScreen, -1, FALSE);
+
+ stbi_image_free(im);
+ rfbScreenCleanup(rfbScreen);
+
+ return 0;
+}