{"id":28961382,"url":"https://github.com/erlangsters/opengl-samples","last_synced_at":"2026-05-06T08:32:44.370Z","repository":{"id":300014323,"uuid":"876902394","full_name":"erlangsters/opengl-samples","owner":"erlangsters","description":"Tiny OpenGL demos in C, Erlang and Elixir —handy for quick reference.","archived":false,"fork":false,"pushed_at":"2026-04-25T05:03:33.000Z","size":4983,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-25T06:24:45.153Z","etag":null,"topics":["beam","demos","elixir","erlang","erlangsters","glfw","opengl","opengl-es"],"latest_commit_sha":null,"homepage":"https://about.erlangsters.org/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erlangsters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-22T18:37:53.000Z","updated_at":"2026-04-25T05:03:36.000Z","dependencies_parsed_at":"2025-06-19T12:52:40.060Z","dependency_job_id":null,"html_url":"https://github.com/erlangsters/opengl-samples","commit_stats":null,"previous_names":["erlangsters/opengl-samples"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erlangsters/opengl-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erlangsters","download_url":"https://codeload.github.com/erlangsters/opengl-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32684645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beam","demos","elixir","erlang","erlangsters","glfw","opengl","opengl-es"],"created_at":"2025-06-24T02:02:41.254Z","updated_at":"2026-05-06T08:32:44.354Z","avatar_url":"https://github.com/erlangsters.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenGL Samples (Erlang \u0026 Elixir)\n\n\u003e :construction: It's a work-in-progress. Notably, the Elixir examples are not\n\u003e implemented yet.\n\n[![Erlangsters Repository](https://img.shields.io/badge/erlangsters-opengl--samples-%23a90432)](https://github.com/erlangsters/opengl-samples)\n![Supported Erlang/OTP Versions](https://img.shields.io/badge/erlang%2Fotp-28-%23a90432)\n![License](https://img.shields.io/github/license/erlangsters/glfw)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/erlangsters/glfw/workflow.yml)](https://github.com/erlangsters/glfw/actions/workflows/workflow.yml)\n\nThis repository contains simple OpenGL programs written in C with their\ncounter-part written in Erlang and Elixir. They can be used as reference to\nwrite applications that use the the OpenGL\n[bindings](https://github.com/orgs/erlangsters/repositories?q=opengl-), and\nimplicitly, the EGL [binding](https://github.com/erlangsters/egl-1.5). Note\nthat they use GLFW to display the graphics in a window.\n\nThe available samples are the following.\n\n- `colored-triangle` - Shows a basic colored triangle.\n- `textured-cube` - Shows a rotating textured cube.\n\nEach sample is written to work with all OpenGL and OpenGL ES versions that are\nmade available to Erlang and Elixir.\n\n- OpenGL: [3.3](https://github.com/erlangsters/opengl-3.3) |\n  [4.1](https://github.com/erlangsters/opengl-4.1) |\n  [4.6](https://github.com/erlangsters/opengl-4.6)\n- OpenGL ES: [2.0](https://github.com/erlangsters/opengl-es-2.0) |\n  [3.0](https://github.com/erlangsters/opengl-es-3.0) |\n  [3.1](https://github.com/erlangsters/opengl-es-3.1) |\n  [3.2](https://github.com/erlangsters/opengl-es-3.2)\n\nOn macOS and Windows, the native samples currently target OpenGL ES 3.1\nthrough the ANGLE layer. Linux remains the platform where the wider desktop\nOpenGL and OpenGL ES matrix is compiled and exercised.\n\n## OpenGL availability\n\nAll versions of OpenGL and OpenGL ES are available on Linux, and work is primarily\ntested on this platform.\n\nHowever, the **macOS** and **Windows** platforms have limitations.\n\nOn both platforms, the current native sample build uses ANGLE to provide EGL and\nan OpenGL ES implementation on top of the host system. That keeps the sample\nlayer aligned with the EGL-first architecture used by the bindings.\n\nWith that said, Linux is still the broadest verification platform. The macOS and\nWindows jobs currently build the OpenGL ES 3.1 samples only.\n\n## Compile and run C samples\n\nThe native samples now use CMake.\n\nInstead of reconfiguring the same build tree with an environment variable, CMake exposes one target per OpenGL version and one executable target per sample/version pair.\n\nThe version group targets are.\n\n- `opengl_33`\n- `opengl_41`\n- `opengl_46`\n- `opengl_es_20`\n- `opengl_es_30`\n- `opengl_es_31`\n- `opengl_es_32`\n\nConfigure the project once, then build the version you want.\n\n```\ncmake -S samples/native -B samples/native/build\ncmake --build samples/native/build --target opengl_es_31\n```\n\nThis produces both native samples for OpenGL ES 3.1 in the build directory.\n\nIf you want a single executable, build its sample-specific target. For instance, to build only the `colored-triangle` sample for OpenGL 4.6:\n\n```\ncmake --build samples/native/build --target colored_triangle_opengl_4_6\n./samples/native/build/colored-triangle-opengl-4.6\n```\n\nOn macOS and Windows, configure the native samples with ANGLE and the vcpkg\ntoolchain, then build the `opengl_es_31` target.\n\n```sh\ncmake -S samples/native -B samples/native/build \\\n  -DCMAKE_TOOLCHAIN_FILE=\"$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake\" \\\n  -DANGLE_INCLUDE_DIR=\"$ANGLE_INCLUDE_DIR\" \\\n  -DANGLE_LIB_DIR=\"$ANGLE_LIB_DIR\"\ncmake --build samples/native/build --target opengl_es_31\n```\n\nFor the moment, `opengl_es_31` is the non-Linux target that is wired into CI.\n\n## Compile and run Erlang samples\n\nSamples can only be compiled for one OpenGL version at a time. However, unlike\nthe C samples, all samples are compiled at the same time with a single command.\n\n```\nrebar3 as opengl_es_2.0 compile\n```\n\nTo run a specific sample, use.\n\n```\nrebar3 as opengl_es_2.0 shell --eval 'colored_triangle:run().'\n```\n\n\nTherefore, first\nset the `OPENGL_VERSION` environment variable to one of the following values.\n\n- `opengl-3.0`\n- `opengl-4.6`\n- `opengl-es-2.0`\n- `opengl-es-3.2`\n\nThen head to the `samples/erlang` folder and run `make`. All samples should be\ncompiled.\n\nRun them individually. For instance `./hello-world`.\n\n## Compile and run Elixir samples\n\nXXX: Not implemented yet.\n\n## Available samples\n\nSeveral samples are provided with each attempting to reproduce a major feature\nof OpenGL. This section describes that.\n\n### The 'hello-world' sample\n\nTo be written.\n\n## Bar\n\nTo be written.\n\n---\n\n- OpenGL samples that I aim to have it ported to Erlang\n- Help me showcase/test the code by having a reference\n\n\n\nOpenGL ES 3.2\n\n```\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cGLES3/gl3.h\u003e\n#include \u003cEGL/egl.h\u003e\n#include \u003cGLFW/glfw3.h\u003e\n\nglfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);\nglfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);\nglfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);\n\nCC = gcc\nCFLAGS = -Wall -Wextra -I/usr/include\nLDFLAGS = -lglfw -lGLESv2 -lEGL\n\nconst char* vertex_shader_src = R\"(\n#version 320 es\nlayout(location = 0) in vec3 aPos;\nlayout(location = 1) in vec3 aColor;\nout vec3 ourColor;\nvoid main() {\n    gl_Position = vec4(aPos, 1.0);\n    ourColor = aColor;\n}\n)\";\n\nconst char* fragment_shader_src = R\"(\n#version 320 es\nprecision mediump float;\nin vec3 ourColor;\nout vec4 FragColor;\nvoid main() {\n    FragColor = vec4(ourColor, 1.0);\n}\n)\";\n\n```\n\nOpenGL 4.6\n\n```\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n#include \u003cGL/glew.h\u003e\n#include \u003cGLFW/glfw3.h\u003e\n\nglfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);\nglfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);\nglfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);\n\nCC = gcc\nCFLAGS = -Wall -Wextra -I/usr/include\nLDFLAGS = -lglfw -lGLEW -lGL\n\n```\n\n## Project origin\n\nDuring the development of the EGL and OpenGL bindings for Erlang, references in\nC needed to be used. Developing a large array of OpenGL bindings is challenging\nas they have to be cross-platform and also because each version of OpenGL has\ntheir specificities which we must test.\n\nWith those programs, we also set goals. Each program uses a specific feature of\nOpenGL, and if we can get it to reproduce this exact same behavior in Erlang,\nour task is complete.\n\nIn other words, they're sort of unit tests which allows test-driven\ndevelopment.\n\nOf course, those programs are excellent candidates for source of reference\nafter the bindings are complete and released to the public - They's why it's a\npublic [repo](https://github.com/erlangsters/opengl-samples).\n\n## Files organization\n\nYou will find the C samples in the `samples/c/` folder and their Erlang\ncounter-parts in the `samples/erlang/` folder. Each folder comes with a\n`Makefile` which allows you to conveniently compiles and run each sample.\n\nAdditionally, you will find the relevant quick reference cards as provided by\nKhronos Group in the `cards/` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferlangsters%2Fopengl-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferlangsters%2Fopengl-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferlangsters%2Fopengl-samples/lists"}