Mail Archives: djgpp/1998/10/05/21:53:57
James Dominy wrote:
>
> Right I've got two putpixel routines, one for VESA 1.2 banked mode, the
> other for VESA 2.0 Linear Frame Buffer Mode.
>
> They are both implemented as macros now for speed purposes, although no
> doubt inline would have much the same effect on performance.
>
> However, I do not want to continuously have if statements all over my code
> checking which routine should be used. So, I set up an array as such
>
> void *putpixel[2](int x, int y, int c);
>
> and call putpixel[0](0,0,15) for example or use 1 instead of 0 for the
> second routine.
>
> But can I inline them in any way? I realize that this would involve the
> compiler knowing which routine would be used on each call, but I would know
> that from after my mode setting routine!
Probably not: if the function's address has to come from a variable, it
*will* go through a function call mechanism, and won't be inlined.
A good idea might be to use an algorithm that doesn't involve putpixel,
but rather writes to a buffer and then blits it to the screen.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -