On Mon, 10 Mar 2003 22:23:07 +0000 José Fonseca <[EMAIL PROTECTED]> wrote: [snip] > As I said above this can be done in C++, and without damage to > efficiency. > > Imagine you have a TnL abstract class: > > class TNL { > // A OpenGL function > virtual void Coord3f(GLfloat x, GLfloat y, GLfloat z) = 0; > > // Activate > virtual void activate() = 0; > > protected: > struct dispatch_table *my_dispatch_table; > } ; > > and then you have two inherited classes for software and hardware > rendering: > > class SoftwareTNL : public TNL { > // The software version. Note the _inline_ > inline void Coord3f(x, y, z) { > _mesa_swrast_deal_with_this_vertex(x, y, z); > } > }; > > class HardwareTNL : public TNL { > // The hardware version. Note the _inline_ > inline void Coord3f(x, y, z) { > _add_vertex_to_DMA_buffer(x, y, z); > } > }; > > and then the C-callable versions for the glapi disptach table: > > void softwareCoord3f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z) { > Driver::Context *context = ctx; > Driver::SoftwareTNL &tnl = ctx->tnl; > > // There will be no call as the function will be expanded inline > tnl.Coord3F(x, y, z); > }
Here you're converting a GLcontext * to a Driver::Context *. Can you do that because Mesa::Context has GLcontext as first member? Anyway, if that didn't work you could always do some fancy pointer arithmetics with the offset of the GLcontext in Driver::Context. But then, if the GLcontext is a member (not a pointer) in Mesa::Context, then it would have to be created by the constructor of Mesa::Context. Just checked in radeonCreateContext, the GLcontext is really created there by calling _mesa_create_context. But _mesa_create_context returns a pointer to the GLcontext. You would need a _mesa_create_context which takes a GLcontext pointer as a parameter. Maybe I'm getting lost in details, but IME it's better to stumble sooner than later. Disclaimer: I support the idea of a C++ framework for DRI driver development. ;-) [snip] > José Fonseca Regards, Felix ------------ __\|/__ ___ ___ ------------------------- Felix ___\_e -_/___/ __\___/ __\_____ You can do anything, Kühling (_____\Ä/____/ /_____/ /________) just not everything [EMAIL PROTECTED] \___/ \___/ U at the same time. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel