Hacker News new | past | comments | ask | show | jobs | submit login
Raylib – A simple and easy-to-use library to enjoy video games programming (github.com/raysan5)
287 points by 6581 on July 6, 2023 | hide | past | favorite | 76 comments



One big problem holding devs back from enjoying gamedev is a lack of quality 3D assets. The engine can be wonderful, but mods were successful due to the availability of existing models and textures that they can poach from the parent game.

I’ve been trying to fix this. It’s not quite ready for showing, but whatever: https://github.com/shawwn/noh

I used to work on Heroes of Newerth, a dota clone. The parent company (S2 Games) sold it to Garena, who shut it down last year. In other words, there are ~80 unique characters with wonderful animations that no commercial entity cares about. I offer them to you.

The gamble is that no one will care; Garena is a massive entity focused on the bottom line, and they’re based outside of the US.

The main thing I’d like to do is to get together the names of all the artists that made these cool characters and promote their current work. HoN’s main strength was its graphics and fluidity, which even today some prefer over dota. That was thanks to an incredibly talented art team whose office was based in California, and I had the pleasure of watching them work for six months or so before the devs were relocated to Michigan. I miss them, and I should’ve spent more time learning the tricks of their trade.

I’ve been making a converter from the HoN format to collada, so hopefully this can be a drop-in addition to raylib. Then you can make your own games with characters and props from HoN.

EDIT: the author of raylib is here! https://news.ycombinator.com/item?id=36614060


Just glancing at it, it looks cool and it's clear you've put a lot of work into the project. I will say though, as a piece of feedback, I personally wouldn't want to build on top of it due to the provenance of the assets. They may not care about it, but they also (correct me if I'm wrong) have not approved of external parties using them or released the assets under any open source license. I have no way of verifying that they don't care, and should a project built with these assets become successful, I can imagine them going from not caring to caring very quickly.

I don't mean to put out a negative comment though, the project does look very cool. It's just a risk.


Me too! If I was an outsider, I know exactly how I’d feel. And that worry is entirely warranted. If you make a viral success with these assets, Garena might come knocking.

But that’s the thing. I fell in love with the engine during my time there. And the only reason was thanks to the assets. I didn’t want to make a million bucks, I just wanted to tinker and play with it.

My hope is that fellow tinkerers will find this useful. If nothing else, they can be stub assets till you’re able to swap them out for your own. And they certainly look gorgeous in comparison to most free models. More importantly, it’s a cohesive dataset —- the entire world is built from parts that all have the same style, which is quite hard to cobble together from random assets you find online.

If Garena ever does have an issue, I’m hoping I can get them on the phone and work out a deal. They want money, we make money, there are ways of transferring some money to Garena to make everyone happy. It’s also a way to reboot an otherwise dead franchise. Plus it costs them nothing to wait and see.

But yeah, this is ultimately a labor of love, and I have no idea how it’ll turn out. In the meantime, it’s at least an incredible reference of one way to implement a modern (circa 2011) game engine.


> If Garena ever does have an issue, I’m hoping I can get them on the phone and work out a deal.

This is not how lawyers work, especially IP lawyers.


Indeed. If the axe comes down someday, oh well. Till then, it’s an interesting experiment that ultimately no one is harmed by.

Garena being based in Asia also helps quite a lot, since the IP concerns are a bit less. Cross cultural IP wars seem less frequent, and Asian franchises in particular seem a bit less aggressively litigious than English counterparts.

There is a moral aspect to it too. I put a year or so of my life into developing that game. It’s not legally mine to give away, but it’s the only chance the franchise has for survival. So I’ll just be clear about all of the risks (which seem minimal) and everyone can go into it with eyes open.


> Asian franchises in particular seem a bit less aggressively litigious than English counterparts.

Shall I tell you about a small Asian franchise owner called Nintendo, or the reason why the most anonymous among the commonly used file sharing networks—Perfect Dark—originates and has most of its users in Japan?

More seriously, there’s (East) Asian and there’s Chinese, and only the latter can be said to uniformly have lax copyright and trademark enforcement.


> I fell in love with the engine during my time there.

OK, uh, I’ve tried a bunch of times to put this in terms that wouldn’t imply a whole lot of work, but I couldn’t, so I’ll just ask outright:

Any exploration hints for someone who hasn’t ever delved into a modern engine and has their knowledge limited to the very obsolete stuff in Abrash’s books and the generalities in Nystrom?

I’ve long wanted to explore how game engines are built, but people don’t usually say good things about the internals—if you do here, that sounds like a chance.


Yes! So many. And writing about them is one of the many things I need to do. Please, please keep in touch — my email’s in my profile, and you can reach me quickly and reliably via Twitter DM. https://www.twitter.com/theshawwn

You’re exactly my target user. I want to help as many people get into gamedev as possible.

The most important thing is to get the codebase open in an IDE, and building. From there you can place breakpoints and start looking at things.

One trick is to literally just hit the pause button in the debugger while the game is running and see where you end up by looking at the stack frames. I use that all the time to map out new codebases. Then start changing some code and see what happens.

I’m sorry I haven’t been able to get something comprehensive together yet; my wife and I have been in the hospital for the last month, and we have a month to go. But it’s almost over.

EDIT: there’s a dev stream too. Sorry for the quality and the music, but you might be able to glean some useful tricks. Pay close attention to the chapter titles, since it’s a serialization of my thought process as I hunted down a bug: https://youtu.be/VBj0RcpxCIc?t=132


> One big problem holding devs back from enjoying gamedev is a lack of quality 3D assets.

There are plenty of 3D assets available. There's TurboSquid, SketchFab, ArtStation, and the Unity and Unreal asset stores. Some are free, some cost. Everybody is moving to glTF format, and import and export has much improved.

If you want a good hard project to work on, write something that takes an overly-detailed 3D asset, with extensive detail in the 3D model, and turns it into a much smaller game asset where much of the fine detail is represented in the normal map. This has been done, but not all that well. Nobody has done it since machine learning started to work. Since the goal is to have the visual appearance from all directions match, you need a good evaluator for "looks the same to a human".


I'm not sure this fixes anything, it just moves the needle somewhere else. Once you've got good models you're now missing animations and textures, and then you get into lighting. If you standardise all of this stuff, you end up with games looking exactly the same (see the default unity movement in a large number of indie games).


You’re right about the anims. I’ve been spending most of my time trying to get the collada exporter right so that you can import it into Maya and make your own relatively easily. I’d do blender, but I honestly have no idea whether animators use blender for character anims circa 2023 and Maya has nice IK support. (If yo8 happen to be an artist, please chime in here.)


Afraid I'm not an artist sorry. I'm a lowly programmer who has had the (mis)fortune to write tooling in this space for a couple of games.


Speaking for myself, I found the process of learning to hand roll basic assets to be enjoyable. They aren't top of the line or complex, but that stuff isn't needed for a one man solo project.


Do you have any tips on this front? I've dabbled with game engines, but spheres and cubes are only so compelling.


Download blender, and learn how to make more complex polygonal shapes. I haven't reached the stage of making anything like foliage or utilizing curves yet, but just being able to make something like a door or a desk is liberating.

Similarly, you can do a lot of texturing work with just GIMP and a phone camera.


Hey! I would love to use these models but can't figure out how to. I see they are in .model format – how would I convert them to something like .obj or .gltf?


Hi! This code is sitting uncommitted on my laptop. I’m sorry to report that since I’ve been in the hospital with my wife for the last month, I wasn’t able to get it committed in a usable state. It pains me that one of the most important items is still a TODO, and it’s partly why I hesitated to show this so soon.

You have a few options. One is to write an importer based on the code in src/k2/c_model.cpp. Another is to wait a week or so while I get my WIP code pushed.

Do you have any contact info? I’d love to keep in touch with you, because you’re my target user. In fact, you’re the first person to ever want to use this besides me, and it’d be a shame to let you slip away. My email is in my profile, and twitter DM is the most reliable way to reach me quickly: https://www.twitter.com/theshawwn

Thanks for asking — it meant a lot!


What do you think about something like stable diffusion, but for 3D assets? Seems like something a few years away.


I’ve been waiting years for it. It’s one of the reasons I wanted to get into ML in 2019.

One of the major hurdles is that it needs to generate assets in a way that fits into an overall art pipeline. Each game studio has a unique style, from the naming of bones in a skeleton to the way UVs are laid out on textures. This will be hard to turnkey.

But it doesn’t need to be turnkey. I bet this will supercharge artists long before it’s an automatic solution for gamedevs. So I predict that any artist who heavily invests in this tooling will stand to win handsomely over the next few years.

Here’s an Erdrich horror I made in a few minutes in ZBrush + photoshop AI: https://twitter.com/theshawwn/status/1669106560654614528?s=6... the eye texture is all photoshop AI, which felt remarkable to me even as terrible as it looks.

The other one who might win is a lone wolf gamedev who autogenerates everything. When all your art is autogenerated, you don’t need a style (or an art pipeline). But this is exceptionally difficult to achieve, and I think very few ML people have the gamedev perspective necessary to pull it off.

Luckily, it’s easier than ever to get into ML. So I’m hopeful that gamedevs will jump into ML themselves, as I did, rather than wait for someone else to make it. Invent the future yourself! You really can.


I think this an area where AI generation can help a lot. Big studios will still do things by hand for better quality and less constraints, but for indies, generating a character with "stylized cell-shaded human character under X polygons" and then go from there will be a revolution.


I was that 14yo with StarEdit


wow, an open-source HoN... that's awesome! what a cool project!


Hey! Just saw an increment in raylib github stargazers and raylib Discord members and someone point me to HN!

I'm the author of raylib, feel free to ask me about it if you want.


No questions, just wanted to say thank you for helping to make gamedev actually fun again. I had no idea raylib existed till now. Unity and Unreal Engine have formed such a depressing monoculture that it’s no wonder gamedev has gone out of fashion in the last decade, and projects like yours help to rekindle it.

Oh, one question, I was hoping to convert a bunch of models to raylib’s format. Right now my exporter goes from Heroes of Newerth format to Collada. What would be the best way to import from there into raylib? (They’re rigged character meshes with 15+ animations for each, so it’s a bit tricky since there’s no universal simple format like obj.)


Thank you very much! Glad you enjoy raylib! I know it's not that popular like the big engines but, actually, next month raylib will be 10 years old! :D

raylib supports several 3d model formats (obj, gltf/glb, iqm, m3d, vox), I think Blender has exporters for most of them. Note that some formats support must be enabled in raylib/src/config.h file!


Okay, I’ll try converting the meshes to iqm. Thanks.

I edited in some context — they’re rigged character meshes with animations, so a few formats are unusable here (like obj) since it can’t handle skeletons. Would you guess that iqm is the best one to look into out of the ones you listed? Otherwise I guess I’ll buckle up and look at all of them.

(Kind of sheepish that the only formats I’ve heard of are obj and m3d…)


Not author but if you're sharing these assets, distributing them in the gltf (json/ascii, not binary) format is really helpful, as it seems to quite easily be imported into tools like blender and threejs.


Awesome, thank you! That’s really helpful to know. The context is over here https://news.ycombinator.com/item?id=36613343 but it’s basically 80 rigged characters with a dozen or so anims, along with normal/diffuse/specular maps. The aim is to distribute them as widely as possible into as many engines and programs as I can, but it’s been hard to figure out what people actually use for their art and engine pipelines nowadays. I’ll prioritize gltf.


> Unity and Unreal Engine have formed such a depressing monoculture.

That's because those got finished and shipped. There are a huge number of hobbyist small game engines that made it to about 80% of useful before the creator got bored. This is the "0.x" curse of open source. In the Rust gamedev world, it's said that there are five games and fifty engines.

In Rust land, if you want to do something that will get used, get behind WGPU, Bevy, and Rend3, and push. It won't be easy, because they've solved the easy problems and are now working on the hard ones. Progress is way too slow.


Hey Ray! Thank you for raylib. I'm learning a ton just from working with it/watching others use it (shout out Tsoding on Twitch—did you see he's been calling raylib from Fortran recently?).

Not to impose upon you with a technical question, but I have one for you if you're up for it.

I'm working with a very small indie language implemented in C that has bindings to raylib as a "first party" library/language extension. I'm trying to get raygui working with those bindings.

If I bundle raygui.h together with the rest of the raylib bindings library, everything seems to work. But, if I create a separate bindings library for raygui and try to import both libraries in the same program, then raygui functions seg fault immediately when called (valgrind points to, as an example, GuiCheckBox -> DrawRectangle -> rlSetTexture).

I don't know enough about C programming to trace this all the way down (I've only learned what I know by trying to cobble together extensions for this language) but it seems like when raygui is compiled apart from the main raylib bindings library, raygui somehow isn't able to share the OpenGL context created by the main library? That diagnosis might be a completely off-base, but that's what it seems like anyway.

Is this a familiar situation at all that you've seen in any other language with bindings for raylib? Any advice for what I could try to get this working?

I know it's hard to say anything conclusive without looking at actual code, but at the same time I don't want to take up any more than the bare minimum of your time.


Thanks! Glad you are learning with it! That was the original objective of the library! Yeah, I learn about Tsoding recently and saw some of the videos! Really nice! About the issue with raygui you comment, it seems related to calling some raygui function before raylib InitWindow(), an OpenGL context is required to call rlSetTexture()... ok, I see you got to a similar conclusion, yeah, it could be that raygui as a separate library can not access the raygui library OpenGL context.

My recommendation is to compile raygui together with raylib, afair, the default raylib Makefile includes an option to add ragui module into raylib on compilation.


This is a great effort, valuable endeavor. Lot of programmers starting out are just overwhelmed by the number of options. Having something streamlined to just coding is great.


Thanks! raylib was originally created to teach gamedev programming basis to young arts students, I tried to keep it as simple as possible but still focused on code writing and able to learn low-level concepts.


Hey, I've been checking out raylib on and off for some time.

I'm currently making an isometric pixel art game using SFML [0]. Technically this is not possible since SFML does not use a depth buffer/z value, but I found a way around this.

I still feel limited in SFML in many ways, like being forced to use the color channels to pass custom codes to the GPU for shaders (while still needing to use color)

Is it possible to setup a custom vertex array in raylib? Beyond world pos, texture pos, and color, is it easy to pass additional information to the GPU for customizing assets in the shader?

Most (all?) of the examples I've see are 3D, but I imagine raylib would have no problem handling a 2D game? Or is specifically designed for 3D and 2D is an afterthought/non-existant?

[0] https://twitter.com/YesboxStudios/status/1676924625912045568


Actually, afaik most raylib users use it for 2d games/tools; it has a batching system to minimize draw calls that works very good with sprites (but also used with 3d shapes). About shaders, raylib provides a Mesh structure with some predefined vertex attribute arrays but you can use them for custom data if required. Also, you can use the lower-level library rlgl for a more fine grain control over the buffers.


Raylib is awesome! It reminds me of the old school days of using BlitzBASIC to get things drawn on screen because it's easy and so much fun. This is how programming used to be, no fuss, just easy to use libraries.

I currently use Raylib with Go and the Go bindings[1] to create screensavers for Linux and I'm really happy with the results.

I even use it at work to draw interactive infrastructure diagrams that animate dependencies, allow controlling start-up etc. It's really flexible and simpler than anything else I've found to get stuff on-screen. I love it!

[1]: https://github.com/gen2brain/raylib-go


Been using raylib for years to power generative digital paintings on embedded systems (RPI and the like). I have been really impressed with its performance and accessible API. Plus it's a very active and welcoming open source project, kudos to the maintainer.


Do you have any examples of code and/or art you can share?

I’ve always been fascinated by generative art.


After cleaning up my bookmarks i narrowed down my "Creative Coding" folder to these.

"Generative Design: Visualize, Program, and Create with JavaScript in p5.js":

http://www.generative-gestaltung.de/2/

Articles by Tyler Hobbs specially the one on "Flow Fields" :

https://tylerxhobbs.com/essays/2020/flow-fields

Articles by Sighack specially the one on "Watercolor Techniques":

https://sighack.com/post/generative-watercolor-in-processing

"Steve's Makerspace" on Youtube:

https://youtube.com/@StevesMakerspace


I don't know how known it is but Jared Tarbell has an excellent gallery: http://www.complexification.net/gallery/

EDIT: nevermind, bio says he co-founded Etsy... he's probably well known


Raysan5 is giving us a masterclass [0] next month on his path to making raylib (and how other people might build something similar.) Worth checking out - there's an online track for it.

[0] https://handmadecities.com/boston


Raysan5 (the author), has built a really neat ecosystem from tools he's also made. I really enjoy the way he has gone about it. It honestly reminds me of a minecraft world or something.

Check out the full repo and see the projects!


The pixel artstyle he uses for his websites and raylib helps haha


I’ve been using the Raylib_cs bindings for C# to write a CHIP-8 interpreter. It was by far the fastest library to get up and running and drawing things to a Window, although my use case is extremely simple. I’d likely come back to it if I were to make something more complicated!


Haha, I used it for the exact same thing in C#. And for visualising Advent-of-Code output under NodeJS. Just as quick, pretty much just an npm-install away. Great community, too!


The Janet bindings work great as well. Lots of fun! https://github.com/janet-lang/jaylib


and there's even a haxe binding https://github.com/haxeui/raylib-haxe


Turns out that raylib works quite well with FORTRAN:

"Tic-Tac-Toe in Fortran with Raylib”: https://www.twitch.tv/videos/1861499073

“Fortran is the Next Rust”: https://www.twitch.tv/videos/1864047709

https://github.com/tsoding/tic-tac-toe-fortran-raylib


This looks awesome. I used to use ncurses for casual game development, but this looks like a good way to get back into it.


Genuinely love this little thing. Its API is really ergonomic and it has plenty of things that are missing even from libs like SDL like some nice filesystem utilities.

I'd consider it the Godot equivalent for C programmers.


"Access to this site has been restricted."??? Github problem?


Raylib is excellent, I've been working on it with the Rust bindings to build a little game. Very good API and awesome performance. Reminds me of Microsoft's XNA Framework.


Actually raylib was highly inspired by XNA, it was my main reference framework.


I’ve been using the Raylin bindings in Odin for a little side project I’m working on. The API is really nice.

Also nice that the Raylib bindings are packaged along with the language.


I had watched a YT video of a developer using this library. His main complaint was the library polluting the global namespace. None of the functions are prefixed and there is a ton of generic named functions and it does define some common constants like for the colors (RED, BLUE, etc.)

Is this an actual issue or was he just being too judgemental?


I used Raylib to make an interactive simulation of earthquakes I had modeled in C++. Very easy to use and it was very rewarding


Isn't it very inefficient to pass structs like Model by value to functions?

I guess it doesn't matter for the matrix operations since they will be probably inlined, but what about the bigger functions?


Depends what's inside model, if it's just a bunch of pointers to meshes, materials, etc. that are allocated and owned elsewhere then it's really not a big deal or concern.


What is "a bunch of" nowadays? My knowledge about efficient programming is still at the level of 20 years ago :) Looking at the DrawModel function, it looks like it's passing around 400 bytes of data structures for a model with one mesh (assuming that matrix operations are inlined).


I've been wanting to use your library recently coming from SDL and GLFW/GLEW, thank you so much for making it.

Would you say it's easier to use than Monogame or equivalent?


raylib is highly inspired by XNA so it has many similitudes to MonoGame but being plain C is not object-oriented like MonoGame.


Why does the page claim "no external dependencies" as the very first feature, which is utterly false given it requires 26 additional libraries to be installed first:

libasound2-dev libegl-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libglx-dev libopengl-dev libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxcursor-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev x11proto-dev xorg-sgml-doctools xtrans-dev


they actually use zig as build system, and it can be compiled (and cross-compiled) with zig cc


One of the options is zig cc. The default is makefiles and there's also good cmake support and plain bash/batch scripts.


Actually the Nim wrapper use none of the above, instead compiles and links the static library per project, recompiling only when the C source files has changed. Allows for the best flexibility if you are using nim.


Nice to see the influence of Borland noted.


> Written in plain C code (C99) using PascalCase/camelCase notation

Is this really something to be proud of? I thought snake_case was the common way of writing C?


There is no solid standard, since it's C we're talking about. I would kind of agree that lower case is more common. More weirdly (from reading the header [1], I have not worked with raylib) the public types and function names are not namespaced so if your code already used Texture or Camera those become clobbered along with DrawPixel(), InitWindow() and hundreds more (the header is ~1,500 lines).

I'm not saying that's bad, and the API seems really nice to work with, it's just a bit odd and against the "common wisdom" on how to design C libraries.

I guess for a game there might not be a lot of need for other libraries, since raylib really does a lot of stuff.

[1]: https://github.com/raysan5/raylib/blob/master/src/raylib.h


I don't think there's an agreed-upon standard.

There's a couple of 'conventions' to avoid collisions between types and names, one would be PascalCase for types and camelCase for anything else, another is using snake_case for both, but use the _t postfix for types (which is a bit shunned upon because the _t postfix is reserved by POSIX - but not the C standard).


No, not an standard. But most large C projects seem to use snake case while most C++ projects use Java-case (which OP calls pacal+camel case)


C styling varies quite a bit between libraries in my experience. Unfortunately, this means your code often looks kind of ugly. The most standard thing I can think of is appending _t to structs / types but I’m pretty sure I’ve used libraries that don’t do that.


appending _t is not allowed under POSIX, for what that's worth.


Since there are no namespaces in C one kind of weird advantage of this is that raylib will stay out of your own (proper) namespace :)


In the non-unix (BeOS,Amiga,NT) world especially video games PascalCase is very popular. But there are exceptions. snake_case has a hacky feel to it, camelCase is very enterprisy and PascalCase says you are from the wirthian world of video games; lisp-case meanse you are into lisp.


You don't see a lot of C written in lisp-case since it parses as a subtraction.


Looks like GitHub just killed this project.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: