<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: grplyler</title>
    <description>The latest articles on DEV Community by grplyler (@grplyler).</description>
    <link>https://dev.to/grplyler</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1093355%2Fa6608123-413b-4d71-a53e-9bdd8dae0cfb.jpeg</url>
      <title>DEV Community: grplyler</title>
      <link>https://dev.to/grplyler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/grplyler"/>
    <language>en</language>
    <item>
      <title>Building and Linking Google's ANGLE with Raylib on MacOS</title>
      <dc:creator>grplyler</dc:creator>
      <pubDate>Sat, 03 Jun 2023 04:53:03 +0000</pubDate>
      <link>https://dev.to/grplyler/building-and-linking-googles-angle-with-raylib-on-macos-11kp</link>
      <guid>https://dev.to/grplyler/building-and-linking-googles-angle-with-raylib-on-macos-11kp</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bu0wzjm980dczmhmzxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bu0wzjm980dczmhmzxj.png" alt="raylib"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tnmmx17kql33g16p7xw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tnmmx17kql33g16p7xw.png" alt="google angle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;If there's one thing I like more than computer graphics, it' fast computer graphics...&lt;/p&gt;

&lt;p&gt;By the end of this post, you'll know you how to build and link Google's ANGLE with Raylib, giving at least a 3x boost in raw frame-rate on Macs with M1/M2 chips. In fact, its the same low-level graphics library that powers Google Chrome! (And any chromium based browsers)&lt;/p&gt;

&lt;p&gt;This tutorial assumes some basic knowledge of compiling C/C++ software and some comfort in the command line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You'll also need the following prerequisites:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Apple Developer Command Line Tools (required)&lt;/li&gt;
&lt;li&gt;VS Code (recommended)&lt;/li&gt;
&lt;li&gt;Homebrew (recommended)&lt;/li&gt;
&lt;li&gt;Ninja &lt;code&gt;brew install ninja&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;CMake &lt;code&gt;brew install cmake&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Python 3 (required)&lt;/li&gt;
&lt;li&gt;Git (required)&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;The impatient can skip to the Short Version, showing your how to heist &lt;code&gt;libEGL.dylib&lt;/code&gt; and &lt;code&gt;libGLESv2.dylib&lt;/code&gt; from Chrome.&lt;/p&gt;

&lt;p&gt;If you'd like a more complete guide, and want to learn how to build raylib and ANGLE from scratch and tie it together in a nice cmake project, please checkout the Slightly Longer Version&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Why use ANGLE anyway?
&lt;/h2&gt;

&lt;p&gt;It seem's everyone's got their own graphics API these days. Microsoft sees the future in Direct3D. Kronos (developer of the OpenGL and Vulkan specs) sees Vulkan as the next-gen solution. Apple on the other hand, true to their nature of building fullstack, hardware and software products, choose freedom and flexibility and decided they too needed their own shiny accelerated graphics API - Metal&lt;/p&gt;

&lt;p&gt;NVidia supports as many as it can, they just want to sell hardware.&lt;/p&gt;

&lt;p&gt;Now usually, OpenGL has a pretty good cross-platform support. And thats usually the go-to for anything cross platform. But with Apple focusing on Metal and essentially deprecating OpenGL support in 2018, performance of the OpenGL drivers on Mac hasn't seen much love and likely won't in the future. The good news is, Metal can get about 10x more draw calls than OpenGL, especially on modern M1/M2 chips.&lt;/p&gt;

&lt;p&gt;With all these different APIs, abstraction layers are starting to pop up. In fact, Google develops such an API thats present in all Chromium based browsers called ANGLE. It provides a compliant OpenGL ES 2.0 frontend with backends to all the major native graphics APIs. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In short, you can get HUGE speed boosts when using Metal through ANGLE on MacOS platforms. Usually double, tipple, or even more the framerate of OpenGL powered solutions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Quickstart (Short Version Using ANGLE from your Browser)
&lt;/h2&gt;

&lt;p&gt;Shout out to &lt;a href="https://github.com/Peter0x44" rel="noopener noreferrer"&gt;Peter0x44&lt;/a&gt; on Github and Raylib's Discord server for pointing this out, but you can actually just grab ANGLE in the form of &lt;code&gt;libEGL.dylib&lt;/code&gt; and &lt;code&gt;libGLESv2.dylib&lt;/code&gt; from a Chromium based browser your probably already have!&lt;/p&gt;

&lt;p&gt;So here we go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Hiest &lt;code&gt;libEGL.dylib&lt;/code&gt; and &lt;code&gt;libGLESv2.dylib&lt;/code&gt; from Chrome&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4qawf35z3xbdnybbcka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4qawf35z3xbdnybbcka.png" alt="angle heist"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using Chrome for example, lets dig down into the &lt;code&gt;.app&lt;/code&gt; and grab these files. We'll use the &lt;code&gt;find&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /Applications/Google&lt;span class="se"&gt;\ &lt;/span&gt;Chrome.app
find ./ &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'libEGL.dylib'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your output should look something like this. Sweet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.//Contents/Frameworks/Google Chrome Framework.framework/Versions/113.0.5672.126/Libraries/libEGL.dylib
.//Contents/Frameworks/Google Chrome Framework.framework/Versions/114.0.5735.90/Libraries/libEGL.dylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now locate &lt;code&gt;libGLESv2.dylib&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find ./ -name 'libGLESv2.dylib'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.//Contents/Frameworks/Google Chrome Framework.framework/Versions/113.0.5672.126/Libraries/libGLESv2.dylib
.//Contents/Frameworks/Google Chrome Framework.framework/Versions/114.0.5735.90/Libraries/libGLESv2.dylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Copy &lt;code&gt;libEGL.dylib&lt;/code&gt; and &lt;code&gt;libGLESv2.dylib&lt;/code&gt; raylib to your project folder&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd &amp;lt;your project&amp;gt;
cp "/Applications/Google Chrome.app/Frameworks/Google Chrome Framework.framework/Versions/114.0.5735.90/Libraries/libGLESv2.dylib" ./
cp "/Applications/Google Chrome.app/Contents/Frameworks/Google Chrome Framework.framework/Versions/114.0.5735.90/Libraries/libEGL.dylib" ./
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Link with raylib&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's a one-liner if you're using a static build of raylib:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;g++ &lt;span class="nt"&gt;-std&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;c++14 &lt;span class="nt"&gt;-I&lt;/span&gt;/path/to/raylib/include &lt;span class="nt"&gt;-o&lt;/span&gt; main main.cpp /path/to/raylib.a /path/to/libEGL.dylib /path/to/libGLESv2.dylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Slightly Longer Version
&lt;/h2&gt;

&lt;p&gt;A single &lt;code&gt;g++&lt;/code&gt; or &lt;code&gt;gcc&lt;/code&gt; command is fine for small projects, but for most projects, you're going to want a build system. We'll go with CMake since it seems to be the defacto standard for C/C++ projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1 Folder Structure &amp;amp; Setup
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Folder setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and pick a root project on your computer. I suggest something like &lt;code&gt;~/code/raylib-angle&lt;/code&gt; or something easy.&lt;/p&gt;

&lt;p&gt;Put the following in the folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── CMakeLists.txt
├── src
│   └── main.cpp
└── vendor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After we setup git submodules, and add some source code, it should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── CMakeLists.txt
├── build
├── src
│   └── main.cpp
└── vendor
    ├── angle
    ├── raygui
    └── raylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 Git submodules
&lt;/h3&gt;

&lt;p&gt;While you can certainly link with raylib static builds, I like to keep everything bundled as source code you can compile without fuss. So lets add &lt;code&gt;raylib&lt;/code&gt; and &lt;code&gt;raygui&lt;/code&gt; if you're feeling adventurous.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add raylib as a submodule to &lt;code&gt;vender/raylib&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git submodule add https://github.com/raysan5/raylib.git vendor/raylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add raylib as a submodule to &lt;code&gt;vendor/raygui&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git submodule add https://github.com/raysan5/raygui.git vendor/raygui
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add ANGLE as a submodule to &lt;code&gt;vendor/angle&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git submodule add https://chromium.googlesource.com/angle/angle vendor/angle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Initialize the submodules&lt;/strong&gt;&lt;br&gt;
You only really need to do this if you're cloning your root repo, but as a reminder for the future run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git submodule update --init --recursive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cool, now lets build ANGLE&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 Building Angle
&lt;/h3&gt;

&lt;p&gt;I haven't quite got this tied into my &lt;code&gt;CMakeLists.txt&lt;/code&gt; yet since angle uses a separate build system, &lt;code&gt;ninja&lt;/code&gt; (which is crazy fast btw), so we'll build ANGLE separately for now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Bootstrap ANGLE&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd vendor/angle
python3 scripts/bootstrap.py
gclient sync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Generate Ninja Build Files&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gn gen out/Release --args='is_debug=false'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we generated build files for release (optimized) build, but you can generate a Debug build my removing &lt;code&gt;--args='is_debug=false'&lt;/code&gt; and running &lt;code&gt;gn gen out/Debug&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to thin down the dylibs from about 11MB to 8MB, you can disabled the non-Metal backends for a leaner build.&lt;/p&gt;

&lt;p&gt;Edit the out/Release/args.gn and add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;angle_enable_d3d9 = false
angle_enable_d3d11 = false
angle_enable_gl = false
angle_enable_null = false
angle_enable_metal = true
angle_enable_vulkan = false
angle_enable_essl = false
angle_enable_glsl = true
is_debug = false
is_component_build = false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Compile Angle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This step will take a hot minute. It took about 10 mins on my 2021 Macbook M1 Pro. The debug build was about half that time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ninja -j 10 -k1 -C out/Release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here I used all 10 CPUs. Use something appropriate for your system.&lt;/p&gt;

&lt;p&gt;When complete, the shared libraries (dylib's) you want are &lt;code&gt;libEGL.dylib&lt;/code&gt; and &lt;code&gt;libGLESv2.dylib&lt;/code&gt; found in the &lt;code&gt;vendor/angle/out/Release/&lt;/code&gt; copy those too your project root: &lt;code&gt;~/code/raylib-angle&lt;/code&gt; (or whatever yours is)&lt;/p&gt;

&lt;h3&gt;
  
  
  4.3 Building the Project
&lt;/h3&gt;

&lt;p&gt;Now lets setup a quick &lt;code&gt;CMakeLists.txt&lt;/code&gt; and compile raylib and its bundled code like &lt;code&gt;glfw&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create CMakeLists.txt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add this to &lt;code&gt;&amp;lt;project-root&amp;gt;/CMakeLists.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cmake"&gt;&lt;code&gt;&lt;span class="nb"&gt;cmake_minimum_required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;VERSION 3.16&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;project&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;raylib-starter&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;CMAKE_CXX_STANDARD 14&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add raylib subdir&lt;/span&gt;
&lt;span class="nb"&gt;add_subdirectory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;vendor/raylib&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add my sources&lt;/span&gt;
&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;GLOB_RECURSE SOURCES &lt;span class="s2"&gt;"src/*.cpp"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;add_executable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;SOURCES&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Define path to ANGLE libraries&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;ANGLE_LIBRARY_DIR vendor/angle/out/Release&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Find ANGLE libraries&lt;/span&gt;
&lt;span class="nb"&gt;find_library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;ANGLE_GLESv2_LIBRARY libGLESv2.dylib PATHS &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ANGLE_LIBRARY_DIR&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;find_library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;ANGLE_EGL_LIBRARY libEGL.dylib PATHS &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ANGLE_LIBRARY_DIR&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add raylib include directory&lt;/span&gt;
&lt;span class="nb"&gt;target_include_directories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; PRIVATE vendor/raylib/src&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add raygui include directory&lt;/span&gt;
&lt;span class="nb"&gt;target_include_directories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; PRIVATE vendor/raygui/src&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Add ANGLE include directory&lt;/span&gt;
&lt;span class="nb"&gt;target_include_directories&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; PRIVATE vendor/angle/include&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Link against raylib and ANGLE libraries&lt;/span&gt;
&lt;span class="nb"&gt;target_link_libraries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; raylib &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ANGLE_EGL_LIBRARY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ANGLE_GLESv2_LIBRARY&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Create &lt;code&gt;&amp;lt;project-root&amp;gt;src/main.cpp&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here's some hello world raylib code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;"raylib.h"&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;screenWidth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;screenHeight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;450&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;InitWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;screenWidth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;screenHeight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"raylib [core] example - basic window"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;SetTargetFPS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;WindowShouldClose&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;BeginDrawing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;ClearBackground&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RAYWHITE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;DrawText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Congrats! You created your first window!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;190&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LIGHTGRAY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="n"&gt;DrawFPS&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;EndDrawing&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;CloseWindow&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Generate CMake Build Files&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmake -DCUSTOMIZE_BUILD=ON -DOPENGL_VERSION="ES 2.0" -B build
cmake --build build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The flags &lt;code&gt;-DCUSTOMIZE_BUILD=ON -DOPENGL_VERSION="ES 2.0"&lt;/code&gt; are key. They tell Tell raylib to look for an OpenGL ES implementation which ANGLE will provide. You can find more about the cmake flags on the &lt;a href="https://github.com/raysan5/raylib/wiki/CMake-Build-Options" rel="noopener noreferrer"&gt;Raylib Wiki&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Validation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here you can see can see our raylib project is using Googles OpenGL ES implementation backed by Metal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;λ ~/code/projects/raylib-angle-test/ master* ./r
INFO: Initializing raylib 4.6-dev
INFO: Supported raylib modules:
INFO:     &amp;gt; rcore:..... loaded (mandatory)
INFO:     &amp;gt; rlgl:...... loaded (mandatory)
INFO:     &amp;gt; rshapes:... loaded (optional)
INFO:     &amp;gt; rtextures:. loaded (optional)
INFO:     &amp;gt; rtext:..... loaded (optional)
INFO:     &amp;gt; rmodels:... loaded (optional)
INFO:     &amp;gt; raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     &amp;gt; Display size: 1920 x 1080
INFO:     &amp;gt; Screen size:  800 x 450
INFO:     &amp;gt; Render size:  800 x 450
INFO:     &amp;gt; Viewport offsets: 0, 0
INFO: GLAD: OpenGL ES2.0 loaded successfully
INFO: GL: Supported extensions count: 104
INFO: GL: OpenGL device information:
INFO:     &amp;gt; Vendor:   Google Inc. (Apple)
INFO:     &amp;gt; Renderer: ANGLE (Apple, Apple M1 Pro, OpenGL 4.1 Metal - 76.3)
INFO:     &amp;gt; Version:  OpenGL ES 3.0.0 (ANGLE 2.1.21199 git hash: b0e9bbd79fb6)
INFO:     &amp;gt; GLSL:     OpenGL ES GLSL ES 3.00 (ANGLE 2.1.21199 git hash: b0e9bbd79fb6)
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: SYSTEM: Decompress data: Comp. size: 1059 -&amp;gt; Original size: 131072
INFO: TEXTURE: [ID 3] Texture loaded successfully (256x256 | GRAY_ALPHA | 1 mipmaps)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.4 Performance
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;With ANGLE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flla9r1ro3y23hh3siodf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flla9r1ro3y23hh3siodf.png" alt="With Angle 11000 fps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes... Thats 11 thousand + FPS you see correctly. I even have a Chrome Browser running spotify and VS Code Running. Granted, raylib's not doing much here, but still!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without ANGLE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh3kdxmeb4mk4zevv0wrs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh3kdxmeb4mk4zevv0wrs.png" alt="Without angle 2900 fps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yeah... nuf said. Thats &lt;strong&gt;nearly 4 times faster&lt;/strong&gt;. ANGLE is definitely WORTH it on MacOS and M1/M2 Chips.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Troubleshooting
&lt;/h3&gt;

&lt;p&gt;If you get an error like when compiling like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: incompatible pointer types assigning to 'int *' from 'bool *'
    if (active == NULL) active = &amp;amp;temp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just edit this line in &lt;code&gt;vendor/raygui/src/raygui.h&lt;/code&gt; and change these lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    bool temp = false;
    if (active == NULL) active = &amp;amp;temp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    bool temp = false;
    if (active == NULL) active = (int *)&amp;amp;temp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This casts &lt;code&gt;temp&lt;/code&gt;, which is a &lt;code&gt;bool *&lt;/code&gt; to an &lt;code&gt;int *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You could also change &lt;code&gt;bool temp&lt;/code&gt; to &lt;code&gt;int temp&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'll submit a pull request for this fix later. This may not be an issue by the time you read this.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's all for now! ANGLE may not give the same speed improvement on other platforms like Windows and Linux, but I may be wrong. &lt;br&gt;
ANGLE support in Raylib is still experimental, but this pretty much confirms it works!&lt;/p&gt;

&lt;p&gt;I hope to be back with some more Raylib writeups. For now, Go checkout ray's awesome ecosystem show the project some love at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.raylib.com/" rel="noopener noreferrer"&gt;https://www.raylib.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.raylibtech.com/" rel="noopener noreferrer"&gt;https://www.raylibtech.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/raysan5/raylib" rel="noopener noreferrer"&gt;https://github.com/raysan5/raylib&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.patreon.com/raylib" rel="noopener noreferrer"&gt;https://www.patreon.com/raylib&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.gg/raylib" rel="noopener noreferrer"&gt;https://discord.gg/raylib&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd like the starter pack code we setup today, you can find that at &lt;a href="https://github.com/grplyler/raylib-cmake-starter" rel="noopener noreferrer"&gt;https://github.com/grplyler/raylib-cmake-starter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Until next time! Keep programming!&lt;/p&gt;

&lt;p&gt;-Ryan "Vortigon"&lt;/p&gt;

</description>
      <category>raylib</category>
      <category>graphics</category>
      <category>gamedev</category>
      <category>metal</category>
    </item>
  </channel>
</rss>
