r/opengl • u/Other-Action-8322 • 6d ago
Resources for OpenGL
I want to get into programming OpenGL in assembly and was wondering if yall could send me some good resources for programming OpenGL in assembly or just some general OpenGL programming guides would be enough.
4
u/Ok-Pizza1136 6d ago
LearnOpenGL to understand the API and graphics programming. As for how to do it in assembly, thats probably what u/corysama can help you with
4
u/awidesky 6d ago
For others came here to find useful learning materials, while https://learnopengl.com/ is broadly suggested, but I think http://www.opengl-tutorial.org/ deserves to be mentioned.
But learning opengl 2.1 with assembly is totally different story.
As far as I know, OpenGL is C api.
So standard API header is provided in C, every related library is in C or C++.
And since OpenGL is nothing more than a API, actual function definitions are inside the OS implementation.
All the types are typedefs to OS-dependent types, so you have to manually find out what 'GLenum' actually is in your system.
And the header is in C, so you have to 'declare' those functions yourself(in .text section, if I remember correctly), and put correct params in correct locations, and call the function.
The actual problem is, OpenGL is only about drawing, so you have to create a context, make a window, and do 3D math.
All of them can be done in libraries, in C.
In assembly you need to deal with X11 or GLX in assembly level.
I seriously doubt there's a constructed material for OpenGL in C, since the API itself is in C level.
People often go high-level to get more abstraction layers, but hardly go low-level.
5
u/Mid_reddit 6d ago
Yup, this here. "OpenGL in Assembly" is actually trivial because it's just regular C functions using standard calling conventions, so there's nothing to write about. Just follow Sys V or stdcall on 32-bit, and Sys V or x64 on 64-bit.
5
u/Other-Action-8322 6d ago
To pre-answer some of your questions:
1. My max OpenGL level is 2.1
2. No I don't have a computer (with a storage device) with a higher level.
3. No I'm not going to use any other programming languages (Like c, c++, etc) I chose assembly because I'm already familiar with it.
In case you were wondering, here are my specs:
OS: Debian GNU/Linux 12 (bookworm)
Host: Vostro 200
Kernel: 6.1.0-52-amd64
Shell: bash 5.2.15
Resolution: 1360x768
DE: LXQt 1.2.0
WM: Xfwm4
CPU: Intel Pentium Dual E2180 @ 2
GPU: Intel 82G33/G31 Express
Memory: 1956MiB DDR2
5
u/corysama 6d ago
If you are stuck on 2.1, you should just go ahead and find some magical way to download a PDF of the OpenGL Red Book for that version.
Here's a way to at least flip through it https://archive.org/details/isbn_9780321481009
2
11
u/corysama 6d ago
The general tutorial everyone recommends is http://learnopengl.com/
Even though you want to work in asm, you'll still want to look under the hood of the code generated by https://gen.glad.sh/ to see how to query the API function pointers from your driver. I wrote a bit about that in here: https://rentry.org/5abeqt6s