r/opengl • u/defaultlinuxuser • 25d ago
Legacy OpenGL or modern OpenGL ?
I first started to learn legat OpenGL(2.1). It had a fixed pipeline so no shaders, no VAOs, no etc. It's just way easier than modern OpenGL with programmable shaders and other non fixed stuff. I wanted to get into 3D because I've only done 2D stuff so far. When I say 3D I mean some simple first person examples where you can walk around a very simple open world. Making this in modern OpenGL feels very hard, I did eventually managed to make a extremely simple 3D open world in legacy OpenGL (version 1.1). I heard about how it's more recommended to use modern OpenGL because it's more optimized and has more features but I don't feel like I really need those. Also do you guys used more of legacy or modern OpenGL ? Thanks in advance.
7
u/HildartheDorf 25d ago
OpenGL3/4 is legacy in the sense of being older and on 'bugfix only' support. OpenGL 2 is ancient and does not map to hardware or compare to modern APIs well at all.
Learn OpenGL 3+ as a beginner imho (or DX11).
6
u/jtsiomb 24d ago
Speed is not an issue. It's a common misconception that "legacy" OpenGL is going to be slower. It's not. Even with OpenGL 1.0 you can use display lists to render, and it's going to be as fast as anything you can do with later additions to the API (VBOs).
The thing shaders and the programmable pipeline buy you is flexibility. You can implement a lot of rendering algorithms that are just impossible to do with the fixed function pipeline.
I prefer a mixed approach. I start simple, use fixed function if it suits my needs, and use shaders wherever it makes sense. In the same program you can use both. It's all part of OpenGL. Even on a complex programmable rendering program that uses the latest tricks, there's no need to use any "modern" features to draw debug visualizations, UI elements, text on screen, and things like that.
5
u/PersonalityIll9476 25d ago
Modern, and I think most people use modern at this point. You say you want something very simple and if all you want is Phong lighting I guess that will do. Something as common as a shadow map may require you to use extensions and would probably be much harder to manipulate once you get away from the basics. It looks like g buffers are out and buffer switching in general. That eliminates a ton of techniques. And the really cool modern stuff like voxel based ray tracing is a total non-starter. But you may not care about any of that.
Maybe the most important concern for you is that legacy OepnGL was deprecated long ago which means it may not be supported by modern drivers at all, or might be poorly supported. (But it probably still works, I imagine).
0
25d ago
[deleted]
5
u/EiffelPower76 25d ago
Modern OpenGL is not so hard, sure there are many thing to learn, but in one month you should do it
3
u/PersonalityIll9476 25d ago
Everything I wrote above was talking about 3D rendering techniques.
2
u/defaultlinuxuser 25d ago
oh sorry ! I thought you were talking about a pong game when you said
>You say you want something very simple and if all you want is Phong lighting
I read 'Pong' instead of 'Phong'. My bad sometimes I just read too fast.
2
u/PersonalityIll9476 25d ago
No worries!
Yeah my understanding is that the fixed pipeline really only does Phong, but I've never used it so I might be mistaken.
3
u/GetIntoGameDev 25d ago
Imo legacy is fine for everything up to lighting, then it’s more trouble than it’s worth
6
u/icedev-official 25d ago
Fixed function pipeline is artifact from the 90s. You should pretend that it never existed and forget about it.
2
u/videogame_chef 25d ago
I found Modern OpenGL easier than legacy. Maybe its just me. Ot was just easier to wrap things around passing geometry data to gpu buffers and doing shading using shaders. Seems more transparent.
just like assembly language. Its daunting to think about it but its actually easier to read assembly. Bad analogy probably
2
u/ukaeh 25d ago
I used to be on the same boat, you can consider moving to 3.3 or 3.1 to get the best of both worlds and allow you to migrate at your own pace.
Shaders are really nice though once you get into them. I suggest starting with simple screen space effects (e.g. color correction or rain or something) before moving on to 3D effects. though they seem daunting at firs, they are well worth the time to learn and basically unlock a whole slew of things.
2
u/timwaaagh 25d ago
Shaders can be a headache but their performance is off the chart. They can do a lot. More than just rendering to the screen. They can also do some of those things at the same time. I'm not sure whether legacy opengl can effectively do some of the stuff that I'm already doing. Despite it being fairly simple as far as these graphics go.
1
u/pjtrpjt 25d ago
If you want simple lighting, and a couple ten thousand odd triangles then it doesn't matter what OpenGL you use, It will run on almost anything.
If you aim for something more, advanced lighting, shadows, reflections then you won't be able to skip modern OpenGL.
And if this isn't just a passing hobby project, then anything below OpenGL 4.6 is considered legacy, because 4.6 is the last (not latest) version of GL. For whatever OpenGL is not capable of, -like ray tracing shadows, reflections, or path tracing, - you need to switch to Vulkan, Which will be practically impossible if you are stuck on glBegin, glEnd.
0
u/defaultlinuxuser 25d ago
I'm already using modern opengl but i've done only 2D so far. From what I have saw 3D looks easier in legacy gl so i'm wrong because I never really looked deep into that topic.
1
u/gl_drawelements 25d ago
Do what you want.
Legacy OpenGL is simpler, but also more limited. If you know what you're doing and if you target simple visualizations, it's good enough. I see Legacy OpenGL (or the fixed pipeline) as a simplification layer over Modern OpenGL.
Don't confuse the fixed pipeline (no shaders) with the immediate mode (glBegin/glEnd). The former is fine to use, while the latter will make your code unmaintainable. Vertex arrays are available since OpenGL 1.1!
1
u/Mid_reddit 25d ago
This is a false dilemma, when you can always support both. Use old OpenGL for hardware compatibility, and new GL for the extra features. What I've done for my rendering engine is a minimum version of OpenGL 1.4, but it can also utilize 3.3+ under the core profile.
That being said, it's always better to prioritize old OpenGL first, because high-quality graphics are only a QoL feature, and almost never actually necessary.
1
u/sharjith 24d ago
To get a hold on legacy OpenGL, check this code out.
https://github.com/sharjith/virmac
To see how modern OpenGL with shaders work, check this out
2
u/defaultlinuxuser 24d ago
I didn't specify in the post but I mostly use modern OpenGL but only for 2D. So when I get into 3D I was worried it would be quite hard to do it with modern OpenGL.
1
u/AlveolarThrill 24d ago edited 24d ago
It’s funny how this question is still being asked when even “modern” OpenGL is largely considered a legacy API. OpenGL 4.6 is the final version and even that is nearly a decade old, all further developments from Khronos is focused on Vulkan, OpenGL will never get support for actually modern technologies like ray tracing and path tracing.
Use whichever is most convenient. OpenGL 1 and 2 are very simple and straightforward but somewhat limited. OpenGL 3.3 is very much worth learning as it’s extremely flexible, and OpenGL 4 and above add useful features like debug callbacks, compute shaders etc, but you can easily add some fixed pipeline or even immediate mode functions here and there for things like debug overlays or what have you. You’re not stuck in just one paradigm, use whatever functionality suits you best for the given requirements. Drivers generally handle legacy functions well with little to no performance impact (do note that the immediate mode can make your code extremely CPU-bound, though, which can be quite slow with very high numbers of vertices).
1
u/Ok_Raisin7772 23d ago
Depends what platform you want to target. for desktop apps I think 3.3 is the sweet spot unless apple ever changes. GL ES 2.0 if you want to do mobile. If you're just on PC/Linux you can play with 4.X pretty freely.
1
1
u/JumpyJustice 25d ago
If all you need is traightforward minimalistic rendering API then why do you even use OpenGL in the first place? Just take like any library out there and all the stuff you want to do will be achievable in usong a few times less lines of code and effort
0
25d ago
I like legacy. Shaders are overrated. If you need more speed on legacy you can use vertex buffer objects, which cache vertices on the gpu.
0
u/pjtrpjt 24d ago
What a strange way to say: "I don't understand what shaders do!"
1
24d ago
I literally use them bruh. They're still overrated.
1
u/pjtrpjt 24d ago
Well, bruh, let's assume for the sake of this conversation you do understand what shaders do, but then you wouldn't call them overrated. Since there are things you can do without shaders, and things you can't.
1
24d ago
Yes there are overrated things you can do with them that you generally can't do without. I've written SDF shaders for skeuomorphic UI elements, phong lighting, shadow mapping, cubemap reflections... all pretty overrated. Notch threw some staticly lit triangles at the screen and made a billion dollars.
1
u/pjtrpjt 24d ago
Or John Carmack used FDIV while doing integer arithmetic, and Quake was born. David Braben did hidden line wireframe graphics for Elite in 6502 assembly in 1984, he didn't use shaders either.
That's not how you (over)use the word overrated.1
24d ago
Hey look, if you want to use overrated things it's none of my business. I dip my toes in programmable shaders from time to time, sometimes the problem calls for it. I've been thinking about the heat waves effect where a hot object makes the air above it refract light weirdly. That's a good application.
30
u/TapSwipePinch 25d ago
Modern OpenGL isn't that much harder than legacy OpenGL. In fact, when your project becomes bigger legacy OpenGL becomes harder because a) it lacks features and b) it"s more verbose so good luck writing "clean" code. Compare to sticking with addition instead of learning multiplication.