ANGLE provides OpenGL ES 2.0 and EGL 1.4 libraries and dlls. You can use these to build and run OpenGL ES 2.0 applications on Windows.
ANGLE uses git for version control. If you are not familiar with git, helpful documentation can be found at http://git-scm.com/documentation.
On all platforms:
- depot_tools
- Required to generate projects and build files, contribute patches, run the unit tests or build the shader compiler on non-Windows systems.
On Windows:
- Visual Studio Community 2015 Update 3
- Required to build ANGLE on Windows and for the packaged Windows 10 SDK. Note: Chrome is in the process of upgrading to Visual Studio 2017. ANGLE will switch over once Chrome does.
- Windows 10 Standalone SDK (recommended)
- Not required to build, but comes with additional features that aid ANGLE development, such as the Debug runtime for D3D11.
- Cygwin's Bison, flex, and patch (optional)
- This is only required if you need to modify GLSL ES grammar files (
glslang.l
andglslang.y
undersrc/compiler/translator
, orExpressionParser.y
andTokenizer.l
insrc/compiler/preprocessor
). Use the latest versions of bison, flex and patch from the 64-bit cygwin distribution.
- This is only required if you need to modify GLSL ES grammar files (
On Linux:
- The GCC or Clang compilers
- Development packages for OpenGL, X11 and libpci
- Bison and flex are not needed as we only support generating the translator grammar on Windows.
On MacOS:
- XCode for Clang and development files.
- Bison and flex are not needed as we only support generating the translator grammar on Windows.
Set the following environment variables as needed:
On Windows:
GYP_GENERATORS
tomsvs
(other options includeninja
andmake
)GYP_MSVS_VERSION
to2015
On Linux and MacOS:
GYP_GENERATORS
toninja
(defaults to 'make' that pollutes your source directory)
Download the ANGLE source by running the following commands:
git clone https://chromium.googlesource.com/angle/angle
cd angle
python scripts/bootstrap.py
gclient sync
git checkout master
GYP will generate the project files, if you update ANGLE or make a change to the projects, they can be regenerated by executing gclient runhooks
.
On Windows GYP will generate the main VS2015 solution file as gyp/ANGLE.sln. For generating a Windows Store version of ANGLE view the Windows Store instructions.
On Linux and MacOS, GYP will generate the out/Debug
and out/Release
directories.
- Open one of the ANGLE Visual Studio solution files (see Getting the source).
- Select Build -> Configuration Manager
- In the "Active solution configuration:" drop down, select the desired configuration (eg. Release), and close the Configuration Manager.
- Select Build -> Build Solution.
Once the build completes, the output directory for your selected configuration (eg.
Release_Win32
, located next to the solution file) will contain the required libraries and dlls to build and run an OpenGL ES 2.0 application.
Run ninja -C out/Debug
or ninja -C out/Release
. Ninja is provided by depot_tools
so make sure you set up your PATH
correctly.
Once the build completes, the out/Debug
or out/Release
directories will contain the .so or .dylib libraries and test binaries.
Presently, it is not possible to build standalone ANGLE for Android.
But, ANGLE for Android can be built within a Chromium checkout.
The reason for that is a dependency on Chromium for Android toolchain and that it only supports GN.
Also, it can only be built on Linux, as this is the only platfrom that Chromium for Android supports.
In theory, once ANGLE supports standalone GN build, it may be possible to put Chromium for Android toolchain in third_party
or buildtools
to build standalone ANGLE for Android.
But, for now, the steps in Checking out and building Chromium for Android should be followed to check out Chromium for Android and set up build environment.
Name your output directories out/Debug
and out/Release
, because Chromium GPU tests look for browser binaries in these folders. Replacing out
with other names seems to be OK when working with multiple build configurations.
It's best to use a build configuration of some Android bot on GPU.FYI waterfall. Look for generate_build_files
step output of that bot. Remove goma_dir
flag.
For example, these are the build flags from Nexus 5X bot:
build_angle_deqp_tests = true
dcheck_always_on = true
ffmpeg_branding = "Chrome"
is_component_build = false
is_debug = false
proprietary_codecs = true
symbol_level = 1
target_cpu = "arm64" # Nexus 5X is 64 bit, remove this on 32 bit devices
target_os = "android"
use_goma = true # Remove this if you don't have goma
These ANGLE targets are supported:
ninja -C out/Release translator libEGL libGLESv2 angle_unittests angle_end2end_tests angle_white_box_tests angle_deqp_gles2_tests angle_deqp_gles3_tests angle_deqp_egl_tests
In order to run ANGLE tests, prepend bin/run_
to the test name, for example: ./out/Release/bin/run_angle_unittests
.
Additional details are in Android Test Instructions.
Note: Running the tests not using the test runner is tricky, but is necessary in order to get a complete TestResults.qpa from the dEQP tests (since the runner shards the tests, only the results of the last shard will be available when using the test runner). First, use the runner to install the APK, test data and test expectations on the device. After the tests start running, the test runner can be stopped with Ctrl+C. Then, run
adb shell am start -a android.intent.action.MAIN -n org.chromium.native_test/.NativeUnitTestNativeActivity -e org.chromium.native_test.NativeTest.StdoutFile /sdcard/chromium_tests_root/out.txt
After the tests finish, get the results with
adb pull /sdcard/chromium_tests_root/third_party/deqp/src/data/TestResults.qpa .
In order to run GPU telemetry tests, build chrome_public_apk
target. Then follow GPU Testing doc, using --browser=android-chromium
argument. Make sure to set your CHROMIUM_OUT_DIR
environment variable, so that your browser is found, otherwise the stock one will run.
Also, follow How to build ANGLE in Chromium for dev to work with Top of Tree ANGLE in Chromium.
This sections describes how to use ANGLE to build an OpenGL ES application.
ANGLE can use either a backing renderer which uses D3D11 on systems where it is available, or a D3D9-only renderer.
ANGLE provides an EGL extension called EGL_ANGLE_platform_angle
which allows uers to select which renderer to use at EGL initialization time by calling eglGetPlatformDisplayEXT with special enums. Details of the extension can be found in it's specification in extensions/ANGLE_platform_angle.txt
and extensions/ANGLE_platform_angle_d3d.txt
and examples of it's use can be seen in the ANGLE samples and tests, particularly util/EGLWindow.cpp
.
By default, ANGLE will use a D3D11 renderer. To change the default:
- Open
src/libANGLE/renderer/d3d/DisplayD3D.cpp
- Locate the definition of
ANGLE_DEFAULT_D3D11
near the head of the file, and set it to your preference.
On Windows:
- Configure your build environment to have access to the
include
folder to provide access to the standard Khronos EGL and GLES2 header files.
- For Visual C++
- Right-click your project in the Solution Explorer, and select Properties.
- Under the Configuration Properties branch, click C/C++.
- Add the relative path to the Khronos EGL and GLES2 header files to Additional Include Directories.
- Configure your build environment to have access to
libEGL.lib
andlibGLESv2.lib
found in the build output directory (see Building ANGLE).
- For Visual C++
- Right-click your project in the Solution Explorer, and select Properties.
- Under the Configuration Properties branch, open the Linker branch and click Input.
- Add the relative paths to both the
libEGL.lib
file andlibGLESv2.lib
file to Additional Dependencies, separated by a semicolon.
- Copy
libEGL.dll
andlibGLESv2.dll
from the build output directory (see Building ANGLE) into your application folder. - Code your application to the Khronos OpenGL ES 2.0 and EGL 1.4 APIs.
On Linux and MacOS, either:
- Link you application against
libGLESv2
andlibEGL
- Use
dlopen
to load the OpenGL ES and EGL entry points at runtime.
In addition to OpenGL ES 2.0 and EGL 1.4 libraries, ANGLE also provides a GLSL ES to GLSL translator. This is useful for implementing OpenGL ES emulators on top of desktop OpenGL.
The translator code is fully independent of the rest of ANGLE code and resides in src/compiler
. It is cross-platform and build files for operating systems other than Windows can be generated by following the Generating project files
steps above.
The basic usage is shown in essl_to_glsl
sample under samples/translator
. To translate a GLSL ES shader, following functions need to be called in the same order:
ShInitialize()
initializes the translator library and must be called only once from each process using the translator.ShContructCompiler()
creates a translator object for vertex or fragment shader.ShCompile()
translates the given shader.ShDestruct()
destroys the given translator.ShFinalize()
shuts down the translator library and must be called only once from each process using the translator.