2D Lines And Shapes - Amateur OS Dev (in C)

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=j01tciXbryM



Duration: 2:22:29
1,220 views
31


A tired post-fever mumbler implements a few basic graphics primitives including: a pixel, lines, triangles, rectangles, polygons, circles, and ellipses. And how to fill these with a solid color. These could be used to develop a "paint" program or games or gui things, refactoring for performance if needed. Drawing curves might be in the future, did not get to them yet.

Playlist for this series:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX

Git Repos:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros

Source code as of the end of this video:
https://git.sr.ht/~queso_fuego/amateur_os_video_sources/tree/master/item/33_2d_gfx_primitives

Miscellaneous notes:
- "$_" in the unix shell can reference the last argument in the previous command entered. I want to try using this more to save time like in "mkdir foo && cd $_" or other situations.
- In vim, I used lowercase "f" to search for something within the current line. Then ";" and "," can go forward/backward to each spot
- I did not update the editor/calculator file sizes in fileTable.asm, so they did not work at the end of this. These are updated now in the OS repo and the source code repo so everything should be working normally.
- I don't like not really explaining how things work, I need to brush up on math.

Wikipedia page on Bresenham's line algorithm, I used the last code example at the bottom for line drawing:
https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm

PDF/book used for circle and ellipse drawing algorithms: "Computer Graphics Principles and Practice in C 2nd Edition"
I'm not providing a link here in case that's not allowed, but it should be online somewhere.

Next OS Dev video(s) might be:
Viewers choice, or fixing up the text/bin editor, more graphics things like gradients, a paint application, some C standard library functions, or something else

Outline:
0:00 - Intro/overview
1:13 - Add color input to clear_screen() & create 2d_gfx.h
7:29 - Reduce makefile output & echo asm binary sizes
11:36 - Start gfxtst command, Point struct
16:42 - draw_pixel()
24:33 - draw_line()
47:25 - draw_triangle()
55:07 - draw_rect()
1:05:12 - draw_polygon()
1:14:30 - draw_circle()
1:27:22 - draw_ellipse()
1:43:28 - boundary_fill()
1:50:31 - fill_triangle_solid()
1:58:09 - fill_rect_solid()
2:03:09 - fill_polygon_solid()
2:11:40 - fill_circle_solid()
2:16:13 - fill_ellipse_solid()
2:21:25 - Outro

Updates for this series and other things will be on twitter, if I remember (unlikely). I'll probably use the YT channel community tab if it becomes available.
----------------------------------------------------------------------------------------------------------------------------------------

Software used for this video:
VMware Workstation Player - https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html
openBSD - https://www.openbsd.org/
qemu - https://www.qemu.org/
vim - https://www.vim.org/
fasm - https://flatassembler.net/
clang - https://clang.llvm.org/
davinci resolve - https://www.blackmagicdesign.com/products/davinciresolve/
OBS Studio - https://obsproject.com/

Contact:
email - fuegoqueso@gmail.com
twitter - @Queso_Fuego

Thoughts/Notes/Suggestions/Other - Drop a message in the video comments, by twitter, or by email

Twitch:
Like Streamers or games? Follow & catch me live (whenever that is...) https://www.twitch.tv/queso_fuego
Stream archive channel - https://www.youtube.com/channel/UCxi12g3jdQMFiFTA5GVcGMA

If you want to see anything specific on stream, let me know through youtube comments, twitter, email, or twitch DMs

Credits:
Music from https://incompetech.com:
"Your Call" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/

The blue title tags:
#osdev #cprogramming #graphics







Tags:
c programming
graphics
graphics primitives
shapes
low level
os dev
osdev
os dev in c
queso fuego
2d shapes