On Fri, Sep 10, 1999 at 02:51:28PM -0600, Thomas Roell wrote:
> > 
> > Is this really all that different?
> 
> Yes, it is different. Look at the two functions below:
> 
> void (*rect)();
> 
> foo_1()
> {
>       glRectf(0.0, 0.0, 1.0, 1.0);
> }
> 
> foo_2()
> {
>       (*rect)(0.0, 0.0, 1.0, 1.0);
> }
> 
> main()
> {
>       rect = glGetProcAddressEXT("glRectf");
> }
> 
> 
> foo_1() can be called regardless of which context is current. foo_2()
> can only be called with whatever context was current when
> glGetProcAddressEXT was called. In order to make things work for
> foo_2() it has to be reformulated in a bizarre way:
> 
> 
> foo_2()
> {
>       (*glGetProcAddressEXT("glRectf"))(0.0, 0.0, 1.0, 1.0);
> }
> 
> 

Is it really that difficult for the programmer to keep track of which
section of code is in which context?  I can see a variable (possibly
global in scope) that would contain a structure that contains
information relevant to the current context.  The programmer could
initialize each structure by switching contexts at the start of their
program to get the function pointers they are looking for.  Your
example above could be changed to read:

foo_2()
{
        currentContext->rectFunc(0.0, 0.0, 1.0, 1.0);
}

When the programmer changes contexts, they can also change this
variable.  I don't see that as being too much of a burden on
applications programmers and it could simplify the underlying driver
code.


BAPper

Reply via email to