[HN Gopher] Rendering like it's 1996 - Baby's first pixel
___________________________________________________________________
Rendering like it's 1996 - Baby's first pixel
Author : homarp
Score : 77 points
Date : 2023-01-15 20:13 UTC (1 days ago)
(HTM) web link (marioslab.io)
(TXT) w3m dump (marioslab.io)
| homarp wrote:
| see also https://news.ycombinator.com/item?id=34391963
| kleiba wrote:
| Alternatively, watch the first couple of videos of Handmade Hero.
| [deleted]
| royjacobs wrote:
| There's nothing that makes you feel old more quickly than seeing
| someone trying to rebuild the sort of technology you implemented
| in the era that they were actually modern.
| 082349872349872 wrote:
| War story: ca. 1980, before PC meant IBM, there were many teams
| rolling their own personal computers. In one of which I'm
| aware, the hardware people attempted to play a practical joke
| on the software people by swapping the leads on the CRT yokes
| every once in a while.
|
| It didn't pay off though: the software people quickly had a
| flag in their driver, and just absent-mindedly flipped it
| whenever they came in and their screen was displaying upside
| down, then carried on working as if nothing untoward had
| happened.
| abraxas wrote:
| There is a bit of irony in how many steps it took to render a few
| pixels on the screen. I was a teen in 1990 and remember this
| being one or two lines in Turbo Pascal for DOS.
| qbasic_forever wrote:
| Your modern OS and graphics hardware is way more complex. In
| DOS you wrote something that took over exclusive access to all
| the PC hardware and didn't have to multitask or share it with
| any other apps or code (more or less). You could directly write
| to hardware memory with no need to have some intermediate
| layers arbitrating access like today. The hardware itself was
| extremely simple and just a buffer of bytes that represented
| pixel colors, not like modern GPUs that are entirely distinct
| computers themselves that you have to pass messages and
| cooperate with for rendering even basic pixels.
|
| Check out a modern library like raylib, it makes blasting out
| pixels on modern hardware easy: https://www.raylib.com/
| rep_lodsb wrote:
| I'm not an expert, but can't modern GPUs just take a
| "texture" in shared memory that is e.g. 640x480 and render it
| to some window? Having your code write directly to that
| memory wouldn't interfere with anything else.
|
| Would obviously require some setup, but that functionality
| could come standard with the OS instead of requiring
| countless libraries.
|
| Also half the article is about setting up a build system.
| legosexmagic wrote:
| thats how it works. its called a swapchain and its usually
| more than one texture. to avoid artifacts.
| einr wrote:
| First set mode 13h (320x200, 256 colors): asm
| mov ax,0013h int 10h end;
|
| ...then plot pixel with palette index c at coordinate (x,y) --
| mem[] is a built in array of bytes representing memory, 0xA000
| is where the VGA framebuffer starts:
| mem[$a000:x+(y*320)] := c;
|
| So yes, it's a oneliner, assuming you've already set the
| correct video mode!
| lelanthran wrote:
| I remember printing out something called (I think) Ralph
| Browns Interrupt List on the university line-printer, because
| I just learned how to embed asm into Turbo C and wanted
| graphics faster than BGI could do[1].
|
| [1] The BGI library was insanely slow, because, IIRC, it used
| BIOS interrupts to draw. Could be wrong, I was very young
| then.
| Koshkin wrote:
| https://en.wikipedia.org/wiki/Ralf_Brown's_Interrupt_List
| carapace wrote:
| Oh my, the nostalgia...
|
| I remember pecking out Wu anti-aliased line drawing routines
| in asm in DOS Debug from out of the Black Book on a PCjr.
| Those were the days. (Just kidding. _These_ are the days.)
|
| https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
|
| https://en.wikipedia.org/wiki/Dos_debug
|
| https://www.jagregory.com/abrash-black-book/
|
| https://en.wikipedia.org/wiki/IBM_PCjr
| corysama wrote:
| "How to just put pixels on the screen?" is a common enough
| question on r/GraphicsProgramming that I made a little gist
| that uses SDL
|
| https://gist.github.com/CoryBloyd/6725bb78323bb1157ff8d4175d...
| ravi-delia wrote:
| If you don't want a build system and are willing to use a
| higher level language, it's still pretty easy. This
| automatically builds the same demo for the web- something you
| can do without.
| intelVISA wrote:
| CMake is already obtuse, I can't imagine how the author can
| cope with a "CMakePresets.json" on-top.
|
| That said, most of this seems to be Emscripten related
| kludge... seems kinda backward to use a portable language
| like C and compile to support one format (web).
| flohofwoe wrote:
| Apart from the CMake setup, cmake presets also simplify
| integration with IDEs (like in this case: VSCode) - AFAIK
| that was actually the main motivation behind the feature.
| antod wrote:
| Heh, coming from 8bit BASIC I remember how complicated it
| seemed setting some pixels in TurboPascal for DOS :)
___________________________________________________________________
(page generated 2023-01-16 23:01 UTC)