1848b8605Smrg<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2848b8605Smrg<html lang="en">
3848b8605Smrg<head>
4848b8605Smrg  <meta http-equiv="content-type" content="text/html; charset=utf-8">
5848b8605Smrg  <title>Off-screen Rendering</title>
6848b8605Smrg  <link rel="stylesheet" type="text/css" href="mesa.css">
7848b8605Smrg</head>
8848b8605Smrg<body>
9848b8605Smrg
10848b8605Smrg<div class="header">
11848b8605Smrg  <h1>The Mesa 3D Graphics Library</h1>
12848b8605Smrg</div>
13848b8605Smrg
14848b8605Smrg<iframe src="contents.html"></iframe>
15848b8605Smrg<div class="content">
16848b8605Smrg
17848b8605Smrg<h1>Off-screen Rendering</h1>
18848b8605Smrg
19848b8605Smrg
20848b8605Smrg<p>
21848b8605SmrgMesa's off-screen interface is used for rendering into user-allocated memory
22848b8605Smrgwithout any sort of window system or operating system dependencies.
23848b8605SmrgThat is, the GL_FRONT colorbuffer is actually a buffer in main memory,
24848b8605Smrgrather than a window on your display.
25848b8605Smrg</p>
26848b8605Smrg
27848b8605Smrg<p>
28848b8605SmrgThe OSMesa API provides three basic functions for making off-screen
29848b8605Smrgrenderings: OSMesaCreateContext(), OSMesaMakeCurrent(), and
30848b8605SmrgOSMesaDestroyContext().  See the Mesa/include/GL/osmesa.h header for
31848b8605Smrgmore information about the API functions.
32848b8605Smrg</p>
33848b8605Smrg
34848b8605Smrg<p>
35848b8605SmrgThe OSMesa interface may be used with any of three software renderers:
36848b8605Smrg</p>
37848b8605Smrg<ol>
38848b8605Smrg<li>llvmpipe - this is the high-performance Gallium LLVM driver
39848b8605Smrg<li>softpipe - this it the reference Gallium software driver
40848b8605Smrg<li>swrast - this is the legacy Mesa software rasterizer
41848b8605Smrg</ol>
42848b8605Smrg
43848b8605Smrg
44848b8605Smrg<p>
45848b8605SmrgThere are several examples of OSMesa in the mesa/demos repository.
46848b8605Smrg</p>
47848b8605Smrg
48848b8605Smrg<h1>Building OSMesa</h1>
49848b8605Smrg
50848b8605Smrg<p>
51848b8605SmrgConfigure and build Mesa with something like:
52848b8605Smrg
53848b8605Smrg<pre>
54b8e80941Smrgmeson builddir -Dosmesa=gallium -Dgallium-drivers=swrast -Ddri-drivers= -Dvulkan-drivers= -Dprefix=$PWD/builddir/install
55b8e80941Smrgninja -C builddir install
56848b8605Smrg</pre>
57848b8605Smrg
58848b8605Smrg<p>
59848b8605SmrgMake sure you have LLVM installed first if you want to use the llvmpipe driver.
60848b8605Smrg</p>
61848b8605Smrg
62848b8605Smrg<p>
63848b8605SmrgWhen the build is complete you should find:
64848b8605Smrg</p>
65848b8605Smrg<pre>
66b8e80941Smrg$PWD/builddir/install/lib/libOSMesa.so  (swrast-based OSMesa)
67b8e80941Smrg$PWD/builddir/install/lib/gallium/libOSMsea.so  (gallium-based OSMesa)
68848b8605Smrg</pre>
69848b8605Smrg
70848b8605Smrg<p>
71b8e80941SmrgSet your LD_LIBRARY_PATH to point to $PWD/builddir/install to use the libraries
72848b8605Smrg</p>
73848b8605Smrg
74848b8605Smrg<p>
75848b8605SmrgWhen you link your application, link with -lOSMesa
76848b8605Smrg</p>
77848b8605Smrg
78848b8605Smrg</div>
79848b8605Smrg</body>
80848b8605Smrg</html>
81