fen
fen

Reputation: 10115

performance of wglGetProcAddress, should calls be cached?

There is a simple code inside a function (from a legacy library) used in init phase - for instance in a Texture Loader module.

loadTexture() {
    // ...
    gl_func = wglGetProcAddress(...)
    // ...
    gl_func()
}

Should I worry about the cost of wglGetProcAddresscall? Or maybe it is so fast that no caching mechanism is needed? Or maybe WGL caches such calls for the process?

What about other similar functions from GLX and Apple? Should I worry or not about them as well?

Upvotes: 0

Views: 478

Answers (1)

a.lasram
a.lasram

Reputation: 4411

wglGetProcAddress will at least do some string comparisons so it's not free. The big issue is that your code will be ugly if you insert wglGetProcAddress every time you use a gl function.

It's best if you use a generator that puts all the ugly wglGetProcAddress in a separate file. For example using glux or glloadgen.

Upvotes: 2

Related Questions