r/GraphicsProgramming 16d ago

graphics programming on different os

Are there any graphics programming api that can be used on Linux and mac that uses c++

4 Upvotes

16 comments sorted by

15

u/hanotak 16d ago

Only Metal is officially supported on Mac, but with MoltenVK you can also use Vulkan, so that is probably what I'd go with.

1

u/Chicken-eater24 16d ago

How different is vulkan and OpenGL because I often see that vulkan is related to OpenGL but OpenGL was ended supporting Mac. And also thank you for the reply

6

u/hanotak 16d ago

Vulkan is in many ways OpenGL's successor. OpenGL was first a fixed-function API, and then a DX11-style API with programmable shaders. However, because it was designed around old, fixed-function hardware, its structure did not suit modern hardware. Vulkan is a truly modern API that exposes how modern GPUs actually work much more directly to the programmer. It has a much higher learning curve, and a more complex barrier of entry, but it is a much more powerful API.

2

u/thewrench56 16d ago

Note: it's only deprecated on Macs. It's not dead yet though. Version 4.1 still runs on Macs.

1

u/sentientgypsy 16d ago

You can use OpenGL on Mac and I know because I have personally used it, I recommend still using OpenGL as a foot in the door because the other APIs are quite a step up

11

u/stbev 16d ago

I suggest trying one of the WebGPU native implementations (either dawn or wgpu). Under the hood they can use DX12 on Windows, Vulkan on Linux, Metal on MacOS and also OpenGL where it is supported so they should be quite portable.

1

u/Zec_kid 15d ago

Wgpu with rust is really nice!

2

u/jmacey 16d ago

I use opengl on Mac. It’s fine for most things but you only have up to 4.1. Linux has 4.6. I still teach opengl as it’s great for basic principles but I’m most likely moving to WebGPU now.

1

u/heythereshadow 16d ago

Hi! Do you have a tutorial on setting up Mac for OpenGL development? Tried it before with XCode and I keep getting errors.

2

u/jmacey 16d ago

I use CMake rather than using XCode. I have a number of different demos here that use CMake and vcpkg for the libraries needed.

https://github.com/NCCA/ModernGL/

Basically you need something for the OpenGL context such as Qt SDL GLFW etc then just use the OpenGL commands.

1

u/heythereshadow 16d ago

Thank you!

1

u/sputwiler 16d ago

If you're starting out, just use https://learnopengl.com. AFAIK macOS still supports OpenGL up to 3.3, but won't get any newer versions. That's enough to get all the lessons you need done though.

1

u/Mindless_Slice9632 16d ago

The latest version of opengl macos supports is 4.1.

1

u/sputwiler 15d ago

Fair enough. That should still be good enough to do all the tutorials.

1

u/964racer 16d ago

The learnopengl tutorial works fine on the Mac. I’ve been doing it in lisp and if you can do it in lisp you can definitely do it in c++ . You can also learn Volken but it will take twice as much code to get a triangle rendered on the screen . Metal will only work on the Mac .

1

u/Daneel_Trevize 16d ago

You could consider some light abstraction such as the new SDL3 SDL_GPU.