View Full Version : return of "wglGetProcAddress()" is same in different RC?
08-20-2007, 12:08 AM
We know if we want to call a ext API,we must use "wglGetProcAddress" to get the function address,but can I use a function address in different RC?I mean I get all the function address my program needed in a RC,the the function will be called in different RC created later,is it valid?
08-20-2007, 12:47 AM
Theoretically, the specs tell us that you must call wglGetProcAddress after the creation of every new context, because function pointers could not be the same. In practice they are always the same (or almost. I've never found a case where I got two diferent pointers for the same function) The only thing I can realize that could provoke diferent returns for the same function with wglGetProcAddress is when both context uses (perhaps due a different pixel format?) different OpenGL implementations. I think that it is a very rare case, only possible in situations where in the same machine are installed more than one graphic card of different vendors, and both gl contexts are 'attached' to different cards/implementations. I dont know if in a single application the user could create an (e.g) ATI context and another one, for a NV card, suppossing the system has those cards installed, but it if were the case, wglGetProcAddress will return different pointers for sure
08-20-2007, 06:36 AM
When using the WGL_gpu_affinity extension, one *must* create a context in order to have the relevant functions defined, then destroy the context, then create a new one targeted at the desired GPU.
So I'd assume that in most cases you'd be fine....
08-20-2007, 02:47 PM
Seeing as though you can use a render context on any DC, so long as the pixel formats match, and the function pointers belong to the context which was active when they were got....
But consider a multi-threaded driver, which creates a thread for each new context. It might decide to dole out function pointers from a thread-local table, for instance.
But on planet earth, they've always been the same for me.
08-20-2007, 08:27 PM
Ok,from your reply,can I make decision below:
I can create a temp window,and get its dc to create a temp rc,and then get all the function pointers I need,then destroy the temp rc & window,and use the function pointers under a rc created later.
Why is it so important for you to get the function-pointers first? Can't you just check them, when you create the RC, that you will actually use?
08-21-2007, 07:20 AM
Well if you had more than one context you'd have to store the function pointers in an array, which would be a nightmare.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.