ANGLE Development
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.
Building ANGLE
This section describes how to build ANGLE.
Required Tools
- Microsoft Windows SDK
- DirectX SDK (June 2010)
- Visual C++ 2008 Express Edition
- OPTIONAL Flex and Bison
- This is only required if you need to modify GLSL ES grammar files (glslang.l and glslang.y under src\compiler)
- It is available as part of cygwin or gnuwin32 distribution on windows
Setup & Configuration
- Install the required tools (above)
- Configure VC++ so that it can locate your DirectX SDK files.
- run Visual C++ Express
- Select Tools -> Options -> Projects and Solutions -> VC++ Directories
- Click Show directories for: "Include files"
- ensure that $(WindowsSdkDir)\include is listed
- add a new line and point it to the Include folder in your DirectX SDK installation
- Click Show directories for: "Library Files"
- ensure that $(WindowsSdkDir)\lib is listed
- add a new line and point it to the Lib\x86 folder in your DirectX SDK installation
- Click OK to close the Options window.
Building
Where source locations are referenced, $(BASE) refers to the folder where your angleproject checkout is located.
- Open $(BASE)/src/ANGLE.sln
- 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. $(BASE)/src/Release) will contain the required libraries and dlls to build and run an OpenGL ES 2.0 application.
Application Development with ANGLE
This sections describes how to use ANGLE to build an OpenGL ES application.
To build an application
- Configure your build environment to have access to the $(BASE)/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 $(BASE)/src/Release folder to provide access to the libEGL.lib and libGLESv2.lib libraries.
- 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 and libGLESv2.lib file to Additional Dependencies, separated by a semicolon.
- Alternatively, you can add both the ANGLE projects and your project to the same solution and configure the dependencies. To do this:
- Right-click the solution in the Solution Explorer, click Add, then Existing Project....
- Select the libGLESv2.vcproj file in the $(BASE)/src/libGLESv2/ folder.
- Repeat for $(BASE)/src/libEGL/libEGL.vcproj and $(BASE)/src/compiler/compiler.vcproj.
- Next, right-click the libGLESv2 project in the Solution Explorer, and click Project Dependencies....
- Select the checkbox for the compiler project and click OK.
- Similarly, configure the libEGL project to depend on the libGLESv2 project.
- Finally, make your project depend on both libEGL and libGLESv2.
- Code your application to the Khronos OpenGL ES 2.0 and EGL 1.4 APIs
To run an application
- Add $BASE/src/Release to your path, or simply copy libEGL.dll and libGLESv2.dll into your application folder.
- Launch your application as normal.
GLSL ES to GLSL Translator
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 emulator on top of desktop OpenGL.
Getting the source
The translator code is fully independent of the rest of ANGLE code and resides in $BASE/src/compiler. Since the translator is supposed to be a cross-platform utility, it uses a different build system GYP, which generates native project files for all supported platforms. If you will be writing your own build system, you do not need to use GYP. You can simply checkout the source under $BASE/src/compiler and headers under $BASE/include/GLSLANG. You can look at translator_common.vcproj and translator_glsl.vcproj as examples for writing your own build system.
If you plan to use GYP, please follow the following instructions to checkout source code and generate build files:
- Install the depot tools as described here.
- Create a directory to hold your source code. This example assumes the directory is $ANGLE_BASE. Important: Make sure the full directory path has no spaces.
- In a shell window, execute the following commands:
- cd $ANGLE_BASE
- gclient config http://angleproject.googlecode.com/svn/trunk
- To download the initial code or update your checkout execute:
- cd $ANGLE_BASE
- gclient sync
- The build files will be auto-generated by gclient sync in the $BASE/trunk/build directory. If you need to regenerate the build files execute:
- cd $ANGLE_BASE
- gclient runhooks --force
- In order to commit, you can convert an existing read-only checkout to a read-write checkout with the following instructions:
- cd $ANGLE_BASE
- Edit $ANGLE_BASE/.gclient and replace http://angleproject.googlecode.com/svn/trunk with https://angleproject.googlecode.com/svn/trunk
- gclient sync
Usage
The basic usage is shown in essl_to_glsl sample under $BASE/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.