Code for legacy openGL but still compatible with new openGL

Started by
17 comments, last by 21st Century Moose 8 years, 6 months ago
I am developing a tool that need to support as a wish the old legacy openGL, but I still would like to make the things easy to be used with new openGL (using minimal switches and code reuse) The thing I need to develop dont need special features, just show triangles, simple color materials, normals, maybe textures. It would be something that can be done with legacy openGL, but I would like to still be able to use to extended in future to use some more features from shaders.. Could you suggest some tutorials or way that I can achieve this goal?
Advertisement

Well, you could use OpenGL 3.x core context (or maybe OpenGL ES 2.0) while programming to avoid using legacy calls, use shaders with a low #version to allow easier conversion to the legacy version, use VBO, avoid doing fancy modern stuff, and everytime you add a call to a gl function you would need to check if it also exists in the legacy version (most likely 2.0 or 2.1, maybe 1.5 with some extensions) and only use it if thats true. Probably, you will find missing calls you need and then have to find a way around that, like creating a single VAO only when using the modern version. You would also need to regularly test with the legacy version.

That is, if you want to do all the extraneous work.rolleyes.gif

Thanks. I am also looking for a way to structure the data (polygons) so it can be more easily used in the two versions. What format could be handled by the two verions?



Thanks. I am also looking for a way to structure the data (polygons) so it can be more easily used in the two versions. What format could be handled by the two verions?

You might want to check the list of formats supported by glInterleavedArrays to see if any of those would suit you. Here is the manual page. If you want to go the structures of arrays route, I believe anything that GL1.1 gl[Vertex|Normal|Texcoord|Color]Pointer works with also works with shaders in the newer versions.

If you want a more specific answer, you may want to wait for someone more experienced to chime in.

You need to be more specific. OpenGL is not a carefully designed API with clear distinctions between versions. It's a collection of extensions and modifications, occasionally rolled up into an amalgamation christened with a version number, and then implemented to (often wildly) varying degrees of correctness and completeness by the many various hardware vendors. OpenGL apps tended to be very crash-prone or misbehave in crazy ways unless applications stuck to very vendor-specific limited subsets or specific sequences of function calls. In games, this was often just, "figure out how Quake did it, because that's the only thing the hardware driver vendors actually ****ing tested." Very modern drivers are much much better, but if you only cared about modern systems you wouldn't be asking about legacy version support, I'd wager. smile.png


Do you need to target OpenGL 2.0? 1.4? 1.0? What "era" of hardware? Are any particular extensions allowed? What operating systems need to be supported? Whose drivers do you need to remain compatible with? Are you even referring to actual OpenGL or is this legacy OpenGL|ES you're asking about?

The answers to those questions (and more I'm probably not remembering) will heavily modify the answer to your original question.


Opinion: If you need to support legacy systems and you aren't targeting some UNIX then just use DirectX 8 or 9; you'll spend less time wrestling with Khronos' API or implementations and be able to spend more time making a better application.

Sean Middleditch – Game Systems Engineer – Join my team!

Thanks for the answers. I mean by "legacy" the glBegin style with no extensions. So, the very basic of triangles, vertex color, vertex normals, textures. light. Something that will look like a beginner did in end 90's happy.png

No openES but it will need to support *nixs (linux and macOS) and win.

You can write the whole thing in a modern GL version, and then write your own old skool Begin/Vertex/End functions on top.

One big game engine that I used did that -- it was built for D3D9/GCM/GX, but provided a GL1.x style API for immediate mode rendering.

You can write the whole thing in a modern GL version, and then write your own old skool Begin/Vertex/End functions on top.

Would you like to explain it better? What do you mean "on top" ? Will that mix the two somehow at same time? Thanks!

Thanks for the answers. I mean by "legacy" the glBegin style with no extensions. So, the very basic of triangles, vertex color, vertex normals, textures. light. Something that will look like a beginner did in end 90's happy.png

No openES but it will need to support *nixs (linux and macOS) and win.

Now I feel like we may be missing a critical piece of information. Will it be you who would use the glBegin etc. style programming, or will it be whoever it was who wished for this support?

You can write the whole thing in a modern GL version, and then write your own old skool Begin/Vertex/End functions on top.

Would you like to explain it better? What do you mean "on top" ? Will that mix the two somehow at same time? Thanks!

Hodgman means that you would write your own Begin function that sets up some lists or arrays to collect vertexes etc., Vertex functions that add to those, and an End function that actually draws those primitives using modern OpenGL. So it would be your very own implementation of "legacy OpenGL" using modern OpenGL.

Is the program actually required to run on machines with very old GPU and drivers that only support GL1.x, no shaders etc. or is it just that you want to supply a legacy OpenGL style API for users of the program?

This topic is closed to new replies.

Advertisement