Graphic library for math and geometry

Hi everyone. I am looking for advice on which library to use for creating graphic elements. What I want to represent are geometric elements as vectors on three-dimensional spaces and function studies.
I had taken into account the OpenGL but from what I have read once designed something that element is not editable, ie the library does not remember the object drawn and can not be modified by modifying its parameters as if it were an object.
An example of what I would like to do is to have a form in which insert the module and the angle of 2 vectors and obtain the graphic representation of the vectors and their sum.
If there were a chance to edit the drawn elements with OpenGL it would be ok for me.
Thanks in advance to anyone who will read the post.
I think you have a misunderstanding of what OpenGL is. OpenGL is an API for sending instructions to your GPU. It is a multi-platform alternative to Microsoft's DirectX, and recently there has been another multi-platform API called Vulkan. All three of these APIs can accomplish mostly the same things. It is rare that you'll find one that can magically do something a magnitude better than another, though I'm sure there's beneficial extensions that are unique to each one.

Most graphical libraries are most likely built on top of OpenGL or DirectX calls, so the most you can do is mask those low-level calls.

In OpenGL, one way to send data to the GPU is with glBufferData and glBufferSubData
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferSubData.xhtml
glBufferData initializes a buffer's contents in the GPU, and glBufferSubData can updates parts of that existing buffer. I don't know what you mean by "library does not remember the object drawn". On every frame, the screen needs to be drawn, and it renders what it gets called to draw. If you need to update or change something, you need to make an API call to let the GPU know it needs to update or draw something.

Any basic loop in a graphical program will look like this:

Create window and other contexts
while (window is open)
{
    get user input (optional)
    update CPU-side data
    update GPU-side data
    draw to the window
}


An example of what I would like to do is to have a form in which insert the module and the angle of 2 vectors and obtain the graphic representation of the vectors and their sum.

You can certainly present this using OpenGL or other higher-level libraries.

If your question is about the math itself, like in your title, I would check out libraries like GLM: OpenGL Mathematics.
https://glm.g-truc.net/0.9.9/index.html
It has classes like glm::vec3 that map 1-to-1 with OpenGL vectors, and has glm::mat* classes for matrices.

If you're a beginner, figuring out the initial boilerplate and setup of OpenGL can be rough, so be warned, but here's a good tutorial website: http://www.opengl-tutorial.org/

I don't actually have too much experience in other 3D-graphics libraries (i.e. calling "high level APIs", any major one I guarantee is either built on top of OpenGL or DirectX), but if you don't want to deal directly with OpenGL, you might want to check out libraries listed here:
https://en.wikipedia.org/wiki/List_of_3D_graphics_libraries#High-level_3D_API
Personally, I've heard good things about OpenSceneGraph, OGRE3D, and Irrlicht Engine. But I've only ever used OpenGL itself.

As far as beginner-friendly 2D graphics, I highly suggest SFML. Its design is very straightforward and clean.
https://www.sfml-dev.org/
Last edited on
Thank you a lot Ganado :)
I'll try to do something with OpenGL.
When I say "library does not remember the object drawn" I mean I would like to use a lbrary that allows me to draw an object, for example a line, associated with parameters (like start point x1,y1 and end point x2,y2) and then once drawn the object in the screen update the object when its parameters are update, ie redraws automatically the line with the new start and end point.
If it's not possible I'll have to know how to delete the line with the old parameters and then draw the line with the current parameters.
Topic archived. No new replies allowed.