Jump to content
  • Advertisement
babaliaris

OpenGL A good 3D math library in C for OpenGL?

Recommended Posts

Posted (edited)

Hello!

I'm trying to find a good math library to use in my game engine. Because I need good DLL support, and c++ has tired me with DLLs, I ended up choosing C. I found CGLM but maybe you know something better :P Of course I won't create the entire engine in C, I will use a lot of c++ but the DLL (which will include the renderer and any GL calls) will be made purely in C.

Thank you.

Edited by babaliaris

Share this post


Link to post
Share on other sites
Advertisement
2 hours ago, babaliaris said:

c++ has tired me with DLLs,

What is wrong with C++ dlls that C dlls do not have ?

Share this post


Link to post
Share on other sites
12 minutes ago, _Silence_ said:

What is wrong with C++ dlls that C dlls do not have ?

I have trouble compiling them in different platforms, even though I'm really careful with name mangling.

Share this post


Link to post
Share on other sites

If you're having trouble with DLLs in C++, wouldn't it be a better idea to drop the DLLs than to drop C++?

Seriously, DLLs are a huge pain in the ass for basically no benefit.  The only time DLLs make sense is when different parts of the project need to be distributed under different licenses.  That's a legal reason for using DLLs.  There is no technical reason for using DLLs, ever.

Share this post


Link to post
Share on other sites

I am confused by the term dll as math libraries i think of (vectors, matrixes, quaternions, boudning shapes, rays, collisions, intersections, etc. pp) usually come as header-only files.

How about data types and precision that are much easier to implement in C++ (templates) than in C ? Almost all math libs i know, if they are not for pure demonstration purposes, offer that functionality.

 

Share this post


Link to post
Share on other sites
Posted (edited)

I would recommend GLM, since it is made to have similar styntax to GLSL, so you can write your math in the same way; both server-side and client-side. Especially if you enable swizzling, "vec3 v = other.xyz;". It is not a DLL, so no linking required.

I'm with "a light breeze" on not dropping C++. It will probably serve you better to work in C++ than C, if you want to make games and work with graphics. There is no need to learn C first and then move on to C++, since the languages grow increasingly distant by each new release.

Not sure about C-compatibility though. CGLM seems to be GLM, so I would go with that.
https://www.khronos.org/news/permalink/new-optimized-opengl-graphics-math-glm-for-c-feedback-requested

https://github.com/recp/cglm

Good luck! :)

Edited by fredrick91

Share this post


Link to post
Share on other sites
Posted (edited)
5 hours ago, a light breeze said:

If you're having trouble with DLLs in C++, wouldn't it be a better idea to drop the DLLs than to drop C++?

Seriously, DLLs are a huge pain in the ass for basically no benefit.  The only time DLLs make sense is when different parts of the project need to be distributed under different licenses.  That's a legal reason for using DLLs.  There is no technical reason for using DLLs, ever.

The reason I want dll's is for updating mechanisms and moding techniques. If I want to be able to send updates for my game, linking everything to an executable will require on a single change in the code to resend the whole executable to the clients. If the game is 50gb, even the slight change in the code would lead to send that 50gb all over again. With dll's I can just send that particular dll only where the change in the code happened.

Also, if I want to support modes, I must give the users a way of extending the game without actually the need to download the whole project. They are going to just include an API which i will provide them, compile their code into a Dll and then just copy-paste that dll into the game directory and the game will automatically load the dll and use the code to dynamically extend the capabilities of the game. 

Edited by babaliaris

Share this post


Link to post
Share on other sites
7 minutes ago, babaliaris said:

. If the game is 50gb,

So it have at least 49.9gb in datapack and less than 100 mb in executables/dlls.

Share this post


Link to post
Share on other sites
52 minutes ago, Fulcrum.013 said:

So it have at least 49.9gb in datapack and less than 100 mb in executables/dlls.

I'm not sure what you mean, but the 49.9gb will already exist on the user's installation, so I will only send the 100mb dll to the user when he updates the game.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!