Hey All, I made a header only C++ library where it's 1 line of code to init, then you can start writing to pixels on the screen.

I call it thirteen.h, as it is inspired by the simplicity of the 13h days.

Examples include a mandelbrot viewer and a playable mine sweeper game.

MIT licensed.

https://github.com/Atrix256/Thirteen

There are some really cool path tracing renders using this lib over on bsky. Two of em attached.
https://bsky.app/profile/hikey.org/post/3mes7ko7f6s22

@demofox Cool stuff! I used to use SDL to draw to screen from CPU, but this feels much easier for someone to start.

DX12 means it won't be easy to use on Linux, though

@lesley @demofox i thought proton took care of that...?
@JamesWidman @lesley someone should implement the api with vulkan on the backend maybe.
@demofox my god the naming alone is beyond genius
@compassing im telling my wife, who was less impressed ๐Ÿ˜‚
@demofox sounds cool! I used to use this library for those purposes about 20 years ago, but it hasnโ€™t been updated for several years https://github.com/thedmd/pixeltoaster
GitHub - thedmd/pixeltoaster: PixelToaster is a framebuffer library for C++

PixelToaster is a framebuffer library for C++. Contribute to thedmd/pixeltoaster development by creating an account on GitHub.

GitHub
@bnut @demofox Good old PixelToaster. I used to use its predecessor PTC (Prometheus Truecolor) too. My university final project ray tracer used it for the rendering display.
@kojack oh yeah, Iโ€™d forgotten about that, I think I used this one: https://sourceforge.net/projects/tinyptc/
TinyPTC

Download TinyPTC for free. A small and easy to use framebuffer graphics library

SourceForge
@demofox excellent! Very reminiscent of the minifb Rust crate by @daniel_collin
@demofox mmm windows, I wonder, what about a linux framebuffer version.. hmmm...
@RueNahcMohr @lisyarus is thinking about making a Linux friendly backend!
@demofox I find it a bit funny that like myself, everybody else seems to have checked the platform compatibility first =)
@sol_hsa you canโ€™t post a Windows only solution to the demoscene without people starting to port it all over the place. Fingers crossed!

@root42 SDL backend ought to be pretty easy to make. Would defeat the purpose though, but at least would make things portable =)

I love the concept. Keeping it simple will be a struggle, though.

@sol_hsa @root42 where it matters it's easy to get SDL installed or you already have it, and the library can dlopen it if you want to keep it at exactly zero compiler flags needed. Probably not worth it but keeping it pure is possible!
@radgeRayden @root42 Not a problem for someone who can use SDL, but a problem for a newbie using it to learn things.
@demofox now we need this with a Vulkan and Metal backend.
@demofox Years since I saw Three.js, but so cool to see them grow up to be Thirteen.h ๐Ÿ‘

@demofox oh this is marvelous, great work!

How's the performance overhead? I imagine it's not too bad since this seems to mostly be a fancy data serialization wrapper for DX12 so probably the heaviest part of this is the user iterating over the pixel array (I'm pretty new to graphics programming myself so I might be off-base here).
Also any plans to port the library to C?

@LunaticDancer its real fast, no overhead in the library.
The pixel values persist across frames, so you could do "dirty rectangles" instead of updating every pixels every frame. If you knew which pixels were updated each frame, you could copy just those regions.
The examples run like pixel shaders as well and iterate overall pixels, but you could blit rectangles instead.
But its real fast. These demos are like 0.3ms per frame on my machine in release.
@demofox okay yeah, that is one sexy frame budget. I guess it's really on library's user not to squander the performance lol
@demofox ohhhh love this, was just looking for something similar and found good old tinyptc dead in the water. This looks great!

@demofox Looks great, love the name. :D

I was going to say wouldn't this make sense to have as just a single .h _and_ a single .cpp, but I guess a huge use case is just getting up and running very quickly and then you might not have a build system anyway.

@demofox It's super cool, but appears to be Windows-only. If anyone knows an alternative that works on Linux let me know.
@fell someone said they like this:
https://github.com/emoon/minifb
GitHub - emoon/minifb: MiniFB is a small cross platform library to create a frame buffer that you can draw pixels in

MiniFB is a small cross platform library to create a frame buffer that you can draw pixels in - emoon/minifb

GitHub
@fell @demofox win32 is the most stablie linux ABI anyway (half serious)
@demofox thank you very much.
@demofox Kudos! Wonderful idea. And great API :)
@demofox (Superintendent Chalmers voice) Hmmh, and you call it thirteen, when it clearly takes more after VESA?

@demofox

flagging @robertcarlson for possible interest...

@demofox
Maybe start out by saying that it's Win32.

You are posting on a social network popular mong people who are leaving the big Facebook/Twitter/Microsoft/Google behind.

@leeloo professors want mac or linux as well. Im a AAA game developer so have that PC bias :P

Something neat though, a mac (metal) PR is waiting for me to review it, and a linux backend is in progress apparently.

So soon not windows only :)

GitHub - jezen/is-thirteen: Check if a number is equal to 13.

Check if a number is equal to 13. Contribute to jezen/is-thirteen development by creating an account on GitHub.

GitHub

@malwareminigun
13h is (a.k.a. 0x13 in a maybe more common notation, i.e. hexadecimal number with digits 1 and 3) is 19 decimal, though, so is it really thirteen? ๐Ÿค”

https://en.wikipedia.org/wiki/Mode_13h#Notation

@demofox

Mode 13h - Wikipedia

@das_g in a universe where โ€œB is 13 written closerโ€ I argue yes :)
@das_g @malwareminigun the h is still there as the file extension (a silly thing)

@demofox I built something like this but for macOS many moons ago for a friend who wanted to get his kid interested in programming! It was great, I was able to make a demo Pong game in about 100 LOC using my lib.

Note: It did NOT interest his kid in programming

@demofox I was excited to see this and then saw the DirectX limitation. I wanted to use this on my Pi displays.
@doofus_canadensis there's a pr for mac (metal) support, and someone else is working on linux support. You are not alone on that!

@demofox may I say I love you?

Some years ago I made this https://github.com/feiss/zero which aimed to something very similar, and tried (without success, got distracted) to port it to many languages and platforms (under a similar API)

So I can say I love this!!! Long life 13h mode!

(And also indexed modes!
https://github.com/feiss/indexed )

GitHub - feiss/zero: Draw pixels anywhere

Draw pixels anywhere. Contribute to feiss/zero development by creating an account on GitHub.

GitHub

@demofox Cool library! For compilation on macOS one can use (maybe you want to add this to the readme file, could be useful for some people):

clang++ main.cpp -framework Metal -framework Cocoa

@sol_prog Thanks Paul, added!
@demofox That's really awesome! Looking forward to the Linux support!

@demofox this is wonderful, thank you! n.b. on macOS I also had to add the flags

-std=c++11 -DTARGET_OS_OSX

@dave ill add that to the docs, thanks!
@demofox thank you! That is exactly what I was looking for for quite a while now!
@demofox I'll try to introduce the kid to that. Are you open to an fps target functionality?
@pkhuong what's that?

@demofox like enforce a specific (low) fps instead of just vsync.

I'm also looking at the missing key input on linux