500 Lines or Less A 3D Modeller

(aosabook.org)

102 points | by myth_drannon 4 days ago ago

22 comments

  • forgotpwd16 2 days ago ago

    The entire "Architecture of Open Source Applications" is amazing, and among those "500 Lines or Less" is imo the most enjoyable. Many, that can perhaps be considered fundamental (e.g. databases, crawler, etc), projects from plan to implementation, Most in Python, but also CLisp, Clojure, JS, Julia.

  • omoikane 2 days ago ago

    The code appears to be here (about ~903 lines):

    https://github.com/aosabook/500lines/tree/master/modeller/co...

    • mathisfun123 2 days ago ago

      "one bite everyone knows the rules"

      • drsalt 2 days ago ago

        is that a saying? what does it mean

        • mathisfun123 2 days ago ago

          Just Google it you'll see

          • drsalt 2 days ago ago

            i duckduckgo'd it and nothing came up

            • mathisfun123 2 days ago ago

              Just Google it you'll see

            • 7bees a day ago ago

              Not sure why the other guy is trying to be so cute about this, but I gather:

              * It's a catch-phrase related to a guy from Barstool Sports that reviews pizza places, on a YouTube channel called One Bite Pizza Reviews

              * The idea is that you take one bite and review the pizza, and this is a "rule"

              * The catch-phrase is used ironically; you may say it and then take multiple bites

              * The guy you're replying to apparently thinks this is similar to "500 lines or less" being more than 500 lines, but can't just say this with words

              https://www.reddit.com/r/barstoolsports/comments/6szlym/one_...

              • mathisfun123 16 hours ago ago

                > Not sure why the other guy is trying to be so cute

                I'm not trying to be cute, I'm trying to remind people in 2026 that we have the technology to answer dumbass questions on your own.

  • knollimar 2 days ago ago

    Using a big library like OpenGL and then playing code golf seems at ends. Cool writeup but these always confuse me

    • yorwba 2 days ago ago

      The point of the "500 lines" book is to make programs small enough to be understood: https://aosabook.org/en/500L/introduction.html

      It's not about golfing as much functionality as possible into those lines, at the cost of rendering it incomprehensible.

    • forgotpwd16 2 days ago ago

      There isn't much attempt at code golf really, and OpenGL is a standard graphics API. Plus project is a 3D modeller, not renderer.

    • ablob 2 days ago ago

      so printf("%i", 42) is fine and dandy golfing, but glTriangle(x, y, z) is too much? The next thing you're gonna tell me is that a true golfer manually invokes syscalls.

    • swiftcoder 2 days ago ago

      OpenGL has a tiny API surface compared to the other 3D APIs. Of course, that means it has a painfully complicated state machine hiding under the hood...

  • jasonjmcghee 2 days ago ago

    Another great read is Daniel Hooper’s write up on his SDF 3D modeler ShapeUp.

    https://news.ycombinator.com/item?id=40239164

    It’s about 2k lines and was built in a week… but it uses raylib which is a fundamentally different task, but i still find it interesting.

  • Krei-se 2 days ago ago

    Beware brave traveler, this great read will make you think oh that's not so hard!

    In the jungle of 3000+ lines spaghetti renderer-code you will be tangled in RenderTargets and concatenated ShaderCode with your boots in quicksands of BindGroups.

    Only the noble get to see the light after fixing their struct alignment traps!! 10/10 though, can recommend to get caught up

    • vconnor 2 days ago ago

      You didn’t even read the article to notice they went for old-style fixed function OpenGL, you know, the one that doesn’t have shader or bind groups or render targets?

      What is the point of your sarcastic comment then?

  • nnevatie 2 days ago ago

    Is this released in 2026? It looks like it came from 20 years ago, to be quite honest.

  • bentt 2 days ago ago

    We must preserve pages and projects like this. In 5 years this will look like hand editing x86 ASM to most programmers.

  • mikevannelli 14 hours ago ago

    [flagged]

  • italiansolider 2 days ago ago

    Based legacy Open-GL enjoyer.