Why is OpenGL designed in a way that the actual functions have to be loaded manually at runtime? -


i had read through loading opengl functions , wondered why opengl designed way, instead of easy way, providing dynamic library , according headers?

providing dynamic library , according headers?

then have misunderstanding of how "dynamic library" works.

let's take windows example. on windows, if had "a dynamic library , according headers", still unable load dll , use it. use of __declspec(dllimport) declarations in header insufficient. need 1 more thing: import library. .lib job of loading function pointers when load dll.

in short, it's syntactic sugar: nice have, not essential. lot opengl loading library.

on linux, things bit different. files more self contained; store equivalent of import library within them. there, in theory "a dynamic library , according headers".

even so, it's still sugar; can dynamically load them , fetch function pointers manually if wish.

all of sugar theoretically used opengl. let's think ramifications of that.

on windows, import library statically linked application. therefore, must work; if fails find dll, or dll not provide functions ought to, program cannot run. @ all. that's of "missing dll" errors about; static import library trying find dll doesn't exist.

so... if want write application uses opengl 3.3 minimum, able use features opengl 4.5 if present? can't link opengl 4.5 import library, since it'll fail load on amy 3.3 implementation. have link import library opengl 3.3. then, how access 4.5 functions? that's right: have load function pointers if exist.

so people going have load functions anyway. it's cleaner load whole thing. way, don't have have versioned import libraries.

also, loading opengl functions dynamically, don't have wait os vendor update dll before can use next set of opengl functions. main dll provides connection ihv driver dll (or open source driver on linux) implements opengl.

note microsoft's opengl32.dll still provides opengl 1.1. i'd we've benefited not waiting on them ;)

also, have "the easy way": use opengl loading library.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -