4 ms·
I loved this walk through back when it came out and even made a ham handed attempt to write the example code in Go https://github.com/radiofreejohn/gobinson htt
by codezero 8y ago
I loved this walk through back when it came out and even made a ham handed attempt to write the example code in Go https://github.com/radiofreejohn/gobinson https://github.com/radiofreejohn/gobinson
It is a bummer it ended with a to be continued that never happened, I remember checking up on it from time to time.
- emmanueloga_ 8y agoSo the blog post ends with a promise of sections about: * inline layout * text rendering. * networking. * scripting. LAYOUT I think here could be useful to take a look at something like Facebook's Yoga [1] although maybe not great to start. There's this little layout demo that could be interesting to investigate [2]. TEXT Regarding text probably the keyword to learn about is "rasterization". I found a few tutorials back in the day [3], [4]. In general rendering text is a PITA and you don't want to do it no matter what :-) The only lightweight solution I found was stb's truetype [3]. So if you want to render text yourself you'll need: - a parser for a font format format (e.g. TTF, PITA) to have a way to get the curve definitions for each font. - a rasterizer (could be a fun project for getting something reasonable and probably slow performant) - a curve filling algorithm and plugging it to your rasterizer, which will probably be able to do humble things like drawing filled triangles and other simple shapes (PITA! :-p) - a word and paragraph layout engine (PITA again :-) Overall I'm happy half understanding the steps involved and not having to deal with all the messy steps in the middle. NETWORKING I'm super lazy in this area, and I would rather learn something like ZeroMQ to posix sockets... back in the day I followed Beej's tutorial which was nice. [6] Then you can connect your sockets to some pre-existing HTTP parser which are a dime a dozen these days [7] and you are all set! :-p SCRIPTING Not much to say here... hundreds of languages available. Probably Lua is a nice alternative to JavaScript, but there are also plenty of lightweight JavaScript implementations these days (I think there is a nice little one called V7). If you want to learn how to actually implement an interpreter there are plenty of resources too. If I went this route I would start by implementing some version of lisp or scheme for simplicity. 1: https://yogalayout.com/ https://yogalayout.com/ 2: https://github.com/randrew/layout https://github.com/randrew/layout 3: https://github.com/NotCamelCase/RasterizationInOneWeekend https://github.com/NotCamelCase/RasterizationInOneWeekend 4: http://www.scratchapixel.com/index.php http://www.scratchapixel.com/index.php 5: https://github.com/nothings/stb/blob/master/stb_truetype.h https://github.com/nothings/stb/blob/master/stb_truetype.h 6: https://beej.us/guide/bgnet/ https://beej.us/guide/bgnet/ 7: https://github.com/search?q=http+parser&ref=opensearch https://github.com/search?q=http+parser&ref=opensearch
- krapp 8y ago>So if you want to render text yourself you'll need (...) Or possibly use SDL or a similar graphics library meant for game development. You would still probably have to write a lot of code but you would get a rasterizer, font loading, simple primitives and image rendering in a cross-platform compatible API.
- codezero 8y agoAmazing follow up. Thanks so much.
- wernsey 8y agoI feel the same way. I took a stab at reimplementing it in C https://github.com/wernsey/robinson-c https://github.com/wernsey/robinson-c My Readme.md contains a lot of TODOs, which I thought I'd be able to tackle on my own, but sadly never got around to.
- swiley 8y agoHonestly I feel like he covered the hardest and weirdest things (parsing html and CSS is just weird but not hard. Layout and painting is (IMO) pretty hard and there are a lot of places to get lost.) Scripting is mostly about hooking up a VM to the other stuff and there are a thousand and one articles on writing VMs. For networking you should just use libcurl. Now that the URL parser is part of the public API you’re better off with it anyway. Plus the networking should be done outside of the engine anyway.
- codezero 8y agoNo doubt. The author owes me nothing, it is a great series. I just felt like I was left hanging a bit by the conclusion. :)