On Wed, Mar 05, 2003 at 10:04:40AM -0800, Ian Romanick wrote:
> Philip Brown wrote:
> > Are you saying that C++ somehow allows for more code sharing between
> > drivers than straight ANSI C?
> 
> It's not so much that it allows it as it makes it less painful.  Look at 
> the texmem-0-0-1 branch.  In lib/GL/mesa/src/drv/common/texmem.h there 
> is a structure called driTextureObject.  In 
> lib/GL/mesa/src/drv/radeon/radeon_context.h there is a structure called 
> radeon_tex_obj that has a driTextureObject as it's first element. 
> Basically, I'm using inheritance here.  The problem is that everywhere I 
> want to use something from the base "class" I have to say 
> "tObj->base.foo".  There's also no easy way to over-ride functions from 
> the base.
>..
> There are a number of structures, like the *_context structures, where 
> we could do this.  It's possible to do in C, but in C++ it's less 
> syntactically painful.

Given the abundance of macros already in use in dri, I would think you
would just define a macro for that sort of stuff ;-)

Also, rather than containing the struct, you could do what is done already
in the drm level, with drm_map_t vs drm_local_map_t (and all over the X
server code), and just extend the struct, rather than encapsulating it.  So
[quick-n-dirty illustration for discussion purposes]

struct dritexture{
        int baseval;
};
struct radeontexture {
        int baseval;
        int radeonextraval;
};



Also, since functions are not part of "the object", I dont see where
"overriding functions" comes into play. If you dont want to use a "base"
function, you just call a radeon-specific one?



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to