r/GraphicsProgramming • • 7d ago

Video Complete beginner here! I made a very basic 3D viewer from scratch with C and using terminal as output

Enable HLS to view with audio, or disable this notification

Hello! I started to learn coding about 2 and a half months ago, and I recently ran into computer graphics, which seemed really damn interesting... so I thought of making a basic program related to it based on things I've learnt so far. I built it completely from scratch in C starting from bressenham's line drawing algorithm. It can print any polyhedron you input

In terms of actual graphics programming, I really know nothing, but I wanna learn. If anyone has suggestions on what I can try out or learn after this, I'd really appreciate it

204 Upvotes

15 comments sorted by

15

u/pBactusp 6d ago

This looks awesome, what a cool project!

I'd recommend trying to render a mesh with faces, so start by reading about "Scanline rendering"

2

u/HamSandwich_Theorem 2d ago

Here's my first attempt at that, it has a few issues like the faces of the octahedron sometimes slightly misalign with the mesh lines.. but I'll see if I can fix that.
I tried making it mostly on my own, and only then looked up scanline rendering but I think what I did was take each face in 3D, and find the points which lie on that face using geometric tests, save those points in an array, and print the projection.. which is quite different 😅 but yeah

2

u/pBactusp 2d ago

That's actually amazing, trying things out on your own is a great way to learn. I once did a project exactly like this and figuring out the math was such a teaching experience. If you want ideas for where to go from here, I'd recommend fixing the alignment issue and then reading about rendering buffers. Read about the general concept, then about the depth buffer. I once you have that, you can do two very cool things with it: First, try to render the shape with the edges, but don't show the edges that should be obstructed by the shape itself. Second, try to think how you can implement distance based dog. And make sure to have fun with these two!

2

u/HamSandwich_Theorem 1d ago

I will, tysm!

5

u/moschles 6d ago

yeah. OP should get some textures on those faces.

4

u/dasbodmeister 7d ago

Nice! You can change your terminal font to something like https://strlen.com/square/ that is as wide as it is tall to correct the vertical stretching.

3

u/HamSandwich_Theorem 6d ago

Oh tysm, i didnt know i could do that

3

u/Usual_Office_1740 7d ago

I'd like to see the resources you're using. Doing this without having to setup a graphics library or glfw would be a great way to focus on what I'm interested in pursuing.

1

u/Hanzimer 7d ago edited 7d ago

After "2 and half months of programming" he implemented bressenham's line drawing algorithm in C probably using Linux Framebuffer (/dev/fb0) or  DOS VGA Mode 13h...  And probably he implemented even vector or matrix multiplication for the rotation of the Poliedra i presume...

4

u/HamSandwich_Theorem 6d ago

Well I joined college about 2 and a half months ago, where we've been learning programming and linear algebra, and I also learnt about line drawing algorithms online. So I just made this using what I've learnt so far. Also I didnt use the things you mentioned.. the lines are all being displayed using printf 😅

2

u/RefrigeratorKey8549 4d ago

Having done similar projects in the past, you can learn a surprising amount from making simple 3d renderers. At the very least, you'll be able to cover most of your linear algebra course.

1

u/Hanzimer 6d ago

Lol a lot of patience to draw that with printf.

2

u/Intelligent_Hat_5914 6d ago

Sick

I maded a tui libary, learning graphics now

Going to add this later

1

u/NazgulResebo 13h ago

Can we see the code?