[Mesa-users] Switch OSMesa/implementation at runtime

Brian Paul brianp at vmware.com
Mon Oct 7 11:44:37 PDT 2013


On 10/06/2013 04:34 AM, Ardillas del Monte wrote:
> Hi,
>
> I'm planning a system which would need to use the (non-Mesa) system
> implementation at some times, and OSMesa at other times (by "system
> implementation" I mean whatever -commercial- system driver has the user
> installed as provided by the hardware vendor of their graphics hardware).
>
> The reason for this is that I need to render with floating point color
> (in software) sometimes, while rendering the same scene at lower quality
> and the fastest hardware-accelerated performance at other times.
>
> I've thought some possibilities for doing this. The one I thought as
> most realistic would be to put the Mesa implementation inside a C++
> namespace, and render OpenGL through a C++ object: if you select the
> OSMesa object, commands are sent to the Mesa namespace, and if you
> select the system object, commands are sent raw, with no namespace, to
> the system OpenGL driver.
>
> However, I don't know if there would be some approach more practical
> than this, and moreover, maybe I'm ignoring some problem or issue I
> might face with the namespace idea.
>
> This software would need to run on OSX, Linux, and Windows, so I need
> either an approach which would work on all these OSs, or a different
> approach for each OS.
>
> I'll appreciate any ideas or suggestions you might have.
>

Other people have done this.  I think the usual approach is to build 
Mesa/OSMesa with name "mangling" then add a layer to your app to choose 
between the normal "glFoo" function and the mangled "mglFoo" functions 
at runtime.

Basically, if you build mesa with --enable-mangling all the GL 
entrypoints with "mgl" prefixes instead of "gl".  You'll also want 
--enable-osmesa or --enable-gallium-osmesa

-Brian



More information about the mesa-users mailing list