Convert Figma logo to code with AI

google logoangle

A conformant OpenGL ES implementation for Windows, Mac, Linux, iOS and Android.

3,403
586
3,403
3

Top Related Projects

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

One stop solution for all Vulkan samples

2,977

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.

Quick Overview

ANGLE (Almost Native Graphics Layer Engine) is an open-source graphics engine abstraction layer developed by Google. It allows WebGL and OpenGL ES applications to run on multiple platforms by translating OpenGL ES and OpenGL ES API calls to various native graphics APIs, such as Direct3D, Metal, and Vulkan.

Pros

  • Cross-platform compatibility: Enables developers to write graphics code once and run it on multiple platforms
  • Performance optimization: Provides efficient translation of graphics APIs, minimizing overhead
  • Active development: Regularly updated and maintained by Google and the open-source community
  • Widely adopted: Used in major browsers like Chrome and Firefox for WebGL support

Cons

  • Learning curve: Requires understanding of graphics APIs and ANGLE's specific implementation
  • Limited to OpenGL ES: Not suitable for applications requiring full OpenGL functionality
  • Potential inconsistencies: Slight differences in behavior across different backend implementations
  • Debugging complexity: Troubleshooting issues can be challenging due to the abstraction layer

Code Examples

  1. Initializing ANGLE and creating a rendering context:
#include <EGL/egl.h>
#include <GLES2/gl2.h>

EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);

EGLConfig config;
EGLint numConfigs;
eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);

EGLSurface surface = eglCreateWindowSurface(display, config, nativeWindow, NULL);
EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);

eglMakeCurrent(display, surface, surface, context);
  1. Drawing a simple triangle using OpenGL ES 2.0:
const char* vertexShaderSource = R"(
    attribute vec4 position;
    void main() {
        gl_Position = position;
    }
)";

const char* fragmentShaderSource = R"(
    precision mediump float;
    void main() {
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    }
)";

// Compile and link shaders...

GLfloat vertices[] = {
    0.0f,  0.5f, 0.0f,
   -0.5f, -0.5f, 0.0f,
    0.5f, -0.5f, 0.0f
};

glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), vertices);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLES, 0, 3);
  1. Swapping buffers and cleaning up:
eglSwapBuffers(display, surface);

// Cleanup
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(display, context);
eglDestroySurface(display, surface);
eglTerminate(display);

Getting Started

  1. Clone the ANGLE repository:

    git clone https://github.com/google/angle.git
    cd angle
    
  2. Build ANGLE using CMake:

    mkdir build && cd build
    cmake ..
    cmake --build .
    
  3. Include ANGLE headers and link against the built libraries in your project.

  4. Use ANGLE's EGL and OpenGL ES headers instead of the system's OpenGL headers in your code.

  5. Compile and run your application, ensuring that ANGLE's libraries are in the system's library path.

Competitor Comparisons

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

Pros of DirectXShaderCompiler

  • Specialized for DirectX shaders, offering deeper optimization for DirectX-based applications
  • Supports newer shader models and DirectX-specific features
  • More extensive documentation and integration with Microsoft's development ecosystem

Cons of DirectXShaderCompiler

  • Limited cross-platform support compared to ANGLE's broader compatibility
  • Steeper learning curve for developers not familiar with DirectX ecosystem
  • Less flexibility for targeting multiple graphics APIs

Code Comparison

ANGLE (GLSL to HLSL conversion):

#version 300 es
precision highp float;
out vec4 fragColor;
void main() {
    fragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

DirectXShaderCompiler (HLSL):

struct PSInput {
    float4 position : SV_POSITION;
};

float4 PSMain(PSInput input) : SV_TARGET {
    return float4(1.0, 0.0, 0.0, 1.0);
}

Summary

ANGLE focuses on cross-platform graphics API translation, particularly from OpenGL ES to various backends, making it ideal for multi-platform development. DirectXShaderCompiler specializes in DirectX shader compilation and optimization, offering deeper integration with Microsoft's graphics ecosystem but with more limited cross-platform applicability.

Pros of SPIRV-Tools

  • Specialized focus on SPIR-V tooling and optimization
  • Broader compatibility across different graphics APIs
  • More extensive SPIR-V validation and transformation capabilities

Cons of SPIRV-Tools

  • Narrower scope, primarily focused on SPIR-V processing
  • Less integrated with specific graphics APIs like OpenGL or Direct3D
  • Steeper learning curve for developers not familiar with SPIR-V

Code Comparison

SPIRV-Tools (SPIR-V optimization):

spv_target_env target_env = SPV_ENV_UNIVERSAL_1_5;
spvtools::Optimizer optimizer(target_env);
optimizer.RegisterPerformancePasses();
std::vector<uint32_t> binary;
optimizer.Run(words.data(), words.size(), &binary);

ANGLE (shader translation):

ShBuiltInResources resources;
ShInitBuiltInResources(&resources);
ShHandle compiler = ShConstructCompiler(GL_FRAGMENT_SHADER, SH_GLSL_450_CORE_OUTPUT);
ShCompile(compiler, &shaderStrings[0], 1, SH_OBJECT_CODE);

Both repositories serve different purposes in the graphics programming ecosystem. SPIRV-Tools focuses on SPIR-V processing and optimization, while ANGLE primarily deals with shader translation and graphics API abstraction. The choice between them depends on the specific requirements of your graphics project.

One stop solution for all Vulkan samples

Pros of Vulkan-Samples

  • Focuses specifically on Vulkan, providing in-depth examples and best practices
  • Offers a wide range of samples covering various Vulkan features and techniques
  • Maintained by Khronos Group, the creators of Vulkan, ensuring high-quality and up-to-date content

Cons of Vulkan-Samples

  • Limited to Vulkan only, not suitable for cross-API development
  • May have a steeper learning curve for beginners compared to ANGLE's abstraction layer
  • Smaller community and fewer contributors than ANGLE

Code Comparison

ANGLE (OpenGL ES to Direct3D translation):

// Initialize ANGLE
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);

// Create context and surface
EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
EGLSurface surface = eglCreateWindowSurface(display, config, window, NULL);

Vulkan-Samples (Vulkan initialization):

VkInstance instance;
VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
vkCreateInstance(&createInfo, nullptr, &instance);

VkPhysicalDevice physicalDevice;
vkEnumeratePhysicalDevices(instance, &deviceCount, &physicalDevice);
2,977

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.

Pros of glslang

  • Official reference compiler for GLSL and ESSL, ensuring high standards and compliance
  • Supports a wider range of shader languages, including HLSL and SPIR-V
  • More focused on shader compilation and validation, making it a specialized tool

Cons of glslang

  • Less comprehensive graphics API abstraction compared to ANGLE
  • May require additional tools or libraries for complete graphics pipeline integration
  • Potentially steeper learning curve for beginners due to its specialized nature

Code Comparison

ANGLE (GLSL to HLSL translation):

// Vertex Shader
attribute vec4 a_position;
void main() {
    gl_Position = a_position;
}

glslang (GLSL validation):

#version 450
layout(location = 0) in vec4 a_position;
void main() {
    gl_Position = a_position;
}

While ANGLE focuses on translating GLSL to other shading languages, glslang primarily validates and compiles GLSL code. ANGLE provides a broader graphics API abstraction, whereas glslang specializes in shader language processing and validation.

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.

Pros of MoltenVK

  • Specifically designed for macOS and iOS, providing native Metal support
  • Maintained by Khronos Group, ensuring alignment with Vulkan standards
  • Offers a more direct translation of Vulkan to Metal, potentially resulting in better performance

Cons of MoltenVK

  • Limited to Apple platforms, lacking cross-platform support
  • May have a steeper learning curve for developers not familiar with Vulkan
  • Smaller community and ecosystem compared to ANGLE

Code Comparison

MoltenVK (Vulkan to Metal):

VkResult vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo,
                          const VkAllocationCallbacks* pAllocator,
                          VkInstance* pInstance) {
    // Implementation using Metal API
}

ANGLE (OpenGL ES to various backends):

EGLBoolean eglCreateContext(EGLDisplay dpy, EGLConfig config,
                            EGLContext share_context,
                            const EGLint *attrib_list) {
    // Implementation using platform-specific APIs
}

Both projects aim to provide graphics API translation, but MoltenVK focuses on Vulkan-to-Metal conversion for Apple platforms, while ANGLE offers broader OpenGL ES support across multiple backends and platforms.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

ANGLE - Almost Native Graphics Layer Engine

The goal of ANGLE is to allow users of multiple operating systems to seamlessly run WebGL and other OpenGL ES content by translating OpenGL ES API calls to one of the hardware-supported APIs available for that platform. ANGLE currently provides translation from OpenGL ES 2.0, 3.0 and 3.1 to Vulkan, desktop OpenGL, OpenGL ES, Direct3D 9, and Direct3D 11. Future plans include ES 3.2, translation to Metal and MacOS, Chrome OS, and Fuchsia support.

Level of OpenGL ES support via backing renderers

Direct3D 9Direct3D 11Desktop GLGL ESVulkanMetal
OpenGL ES 2.0completecompletecompletecompletecompletecomplete
OpenGL ES 3.0completecompletecompletecompletecomplete
OpenGL ES 3.1incompletecompletecompletecomplete
OpenGL ES 3.2in progressin progresscomplete

Additionally, OpenGL ES 1.1 is implemented in the front-end using OpenGL ES 3.0 features. This version of the specification is thus supported on all platforms specified above that support OpenGL ES 3.0 with known issues.

Platform support via backing renderers

Direct3D 9Direct3D 11Desktop GLGL ESVulkanMetal
Windowscompletecompletecompletecompletecomplete
Linuxcompletecomplete
Mac OS Xcompletecomplete [1]
iOScomplete [2]
Chrome OScompleteplanned
Androidcompletecomplete
GGP (Stadia)complete
Fuchsiacomplete

[1] Metal is supported on macOS 10.14+

[2] Metal is supported on iOS 12+

ANGLE v1.0.772 was certified compliant by passing the OpenGL ES 2.0.3 conformance tests in October 2011.

ANGLE has received the following certifications with the Vulkan backend:

  • OpenGL ES 2.0: ANGLE 2.1.0.d46e2fb1e341 (Nov, 2019)
  • OpenGL ES 3.0: ANGLE 2.1.0.f18ff947360d (Feb, 2020)
  • OpenGL ES 3.1: ANGLE 2.1.0.f5dace0f1e57 (Jul, 2020)
  • OpenGL ES 3.2: ANGLE 2.1.2.21688.59f158c1695f (Sept, 2023)

ANGLE also provides an implementation of the EGL 1.5 specification.

ANGLE is used as the default WebGL backend for both Google Chrome and Mozilla Firefox on Windows platforms. Chrome uses ANGLE for all graphics rendering on Windows, including the accelerated Canvas2D implementation and the Native Client sandbox environment.

Portions of the ANGLE shader compiler are used as a shader validator and translator by WebGL implementations across multiple platforms. It is used on Mac OS X, Linux, and in mobile variants of the browsers. Having one shader validator helps to ensure that a consistent set of GLSL ES shaders are accepted across browsers and platforms. The shader translator can be used to translate shaders to other shading languages, and to optionally apply shader modifications to work around bugs or quirks in the native graphics drivers. The translator targets Desktop GLSL, Vulkan GLSL, Direct3D HLSL, and even ESSL for native GLES2 platforms.

OpenCL Implementation

In addition to OpenGL ES, ANGLE also provides an optional OpenCL runtime built into the same output GLES lib.

This work/effort is currently work-in-progress/experimental.

This work provides the same benefits as the OpenGL implementation, having OpenCL APIs be translated to other HW-supported APIs available on that platform.

Level of OpenCL support via backing renderers

VulkanOpenCL
OpenCL 1.0in progressin progress
OpenCL 1.1in progressin progress
OpenCL 1.2in progressin progress
OpenCL 3.0in progressin progress

Each supported backing renderer above ends up being an OpenCL Platform for the user to choose from.

The OpenCL backend is a "passthrough" implementation which does not perform any API translation at all, instead forwarding API calls to other OpenCL driver(s)/implementation(s).

OpenCL also has an online compiler component to it that is used to compile OpenCL C source code at runtime (similarly to GLES and GLSL). Depending on the chosen backend(s), compiler implementations may vary. Below is a list of renderers and what OpenCL C compiler implementation is used for each:

  • Vulkan : clspv
  • OpenCL : Compiler is part of the native driver

Sources

ANGLE repository is hosted by Chromium project and can be browsed online or cloned with

git clone https://chromium.googlesource.com/angle/angle

Building

View the Dev setup instructions.

Contributing