{"id":51556147,"url":"https://github.com/erlangsters/opengl-es-2.0","last_synced_at":"2026-07-10T05:02:37.010Z","repository":{"id":369520441,"uuid":"862472076","full_name":"erlangsters/opengl-es-2.0","owner":"erlangsters","description":"OpenGL ES 2.0 binding for the BEAM (Erlang and Elixir).","archived":false,"fork":false,"pushed_at":"2026-07-05T17:31:04.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-07-05T19:15:34.900Z","etag":null,"topics":["beam","binding","elixir","erlang","erlangsters","gles2","gles20","opengl-es"],"latest_commit_sha":null,"homepage":"https://about.erlangsters.org","language":"Erlang","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":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-24T16:51:04.000Z","updated_at":"2026-07-05T17:31:09.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/erlangsters/opengl-es-2.0","commit_stats":null,"previous_names":["erlangsters/opengl-es-2.0"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/erlangsters/opengl-es-2.0","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-es-2.0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-es-2.0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-es-2.0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-es-2.0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erlangsters","download_url":"https://codeload.github.com/erlangsters/opengl-es-2.0/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erlangsters%2Fopengl-es-2.0/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35321224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-10T02:00:06.465Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","binding","elixir","erlang","erlangsters","gles2","gles20","opengl-es"],"created_at":"2026-07-10T05:02:36.241Z","updated_at":"2026-07-10T05:02:37.005Z","avatar_url":"https://github.com/erlangsters.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenGL ES 2.0 binding for the BEAM\n\n[![Erlangsters Repository](https://img.shields.io/badge/erlangsters-opengl--es--2.0-%23a90432)](https://github.com/erlangsters/opengl-es-2.0)\n![Supported Erlang/OTP Versions](https://img.shields.io/badge/erlang%2Fotp-28-%23a90432)\n![Current Version](https://img.shields.io/badge/version-0.0.1-%23354052)\n![License](https://img.shields.io/github/license/erlangsters/opengl-es-2.0)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/erlangsters/opengl-es-2.0/build.yml)](https://github.com/erlangsters/opengl-es-2.0/actions/workflows/build.yml)\n[![Documentation Link](https://img.shields.io/badge/documentation-available-yellow)](https://erlangsters.github.io/opengl-es-2.0/)\n\n\u003e [!WARNING]\n\u003e This repository is still in development. Until release tags are cut, the\n\u003e `master` branch may be rewound.\n\nThis repository hosts the generated OpenGL ES 2.0 binding for Erlang and Elixir.\nOnly the OpenGL ES surface selected for this target is exposed through the\n`gl` module. Loading custom OpenGL functions is not supported.\n\nAfter an EGL context is current, calling OpenGL from Erlang looks like this:\n\n```erlang\n{ok, Version} = gl:get_string(version),\nio:format(\"OpenGL version: ~p~n\", [Version]).\n```\n\nFrom Elixir, the same module is available as `:gl`:\n\n```elixir\n{:ok, version} = :gl.get_string(:version)\nIO.puts(\"OpenGL version: #{version}\")\n```\n\nIt works with the [EGL binding](https://github.com/erlangsters/egl-1.5),\nwhich provides OpenGL contexts and surfaces. The\n[GLFW binding](https://github.com/erlangsters/glfw) can be used when an\napplication needs a window.\n\nBindings for other versions of OpenGL and OpenGL ES are available from the\n[Erlangsters repository list](https://github.com/orgs/erlangsters/repositories?type=all\u0026q=opengl-).\n\nGenerated by the Erlangsters [community](https://about.erlangsters.org/) and\nreleased under the MIT [license](https://opensource.org/license/mit).\n\n## Quick preview\n\nAll the pieces together, with EGL, OpenGL and optional GLFW for a window, look\nroughly like this:\n\n```erlang\nglfw:init(),\n\nDisplay = egl:get_display(default_display),\n{ok, _} = egl:initialize(Display),\n\nConfigAttribs = [\n    {surface_type, [window_bit]},\n    {renderable_type, [opengl_es2_bit]}\n],\n{ok, Configs} = egl:choose_config(Display, ConfigAttribs),\nConfig = hd(Configs),\n\nContextAttribs = [\n    {context_major_version, 2},\n    {context_minor_version, 0}\n],\negl:bind_api(opengl_es_api),\n{ok, Context} = egl:create_context(Display, Config, no_context, ContextAttribs),\n\n{ok, Window} = glfw:create_window(640, 480, \"Hello World!\"),\nWindowHandle = glfw:window_egl_handle(Window),\n{ok, Surface} = egl:create_window_surface(Display, Config, WindowHandle, []),\n\nok = egl:make_current(Display, Surface, Surface, Context),\n\n% Here goes your OpenGL initialization code.\nVertices = [\n     0.0,  0.5, 0.0, 1.0, 0.0, 0.0,\n    -0.5, -0.5, 0.0, 0.0, 1.0, 0.0,\n     0.5, -0.5, 0.0, 0.0, 0.0, 1.0\n],\n\n{ok, [Buffer]} = gl:gen_buffers(1),\ngl:bind_buffer(array_buffer, Buffer),\ngl:buffer_data(\n    array_buffer,\n    length(Vertices) * 4,\n    \u003c\u003c\u003c\u003cVertex:32/float-little\u003e\u003e || Vertex \u003c- Vertices\u003e\u003e,\n    static_draw\n),\n\nloop_window(Display, Surface, Window).\n```\n\nHere is how the loop function can look:\n\n```erlang\nloop_window(Display, Surface, Window) -\u003e\n    case glfw:window_should_close(Window) of\n        true -\u003e\n            glfw:terminate();\n        false -\u003e\n            % Here goes your OpenGL rendering code.\n            gl:clear([color_buffer_bit]),\n\n            egl:swap_buffers(Display, Surface),\n            glfw:poll_events(),\n            handle_events(Window),\n\n            loop_window(Display, Surface, Window)\n    end.\n```\n\nAnd here is a small event handler:\n\n```erlang\nhandle_events(Window) -\u003e\n    receive\n        #glfw_window_size{size = {Width, Height}} -\u003e\n            gl:viewport(0, 0, Width, Height),\n            handle_events(Window)\n    after 0 -\u003e\n        ok\n    end.\n```\n\nFor more examples, consult the\n[OpenGL samples repository](https://github.com/erlangsters/opengl-samples),\nwhich contains mini-programs written in C, Erlang and Elixir.\n\n## Working with the binding\n\nBefore writing larger programs, it is useful to understand the thread-safety\nmodel and the API mapping rules.\n\n**Thread safety**\n\nOpenGL is a C API with thread-affine state: a context is current on one OS\nthread at a time. The BEAM schedules Erlang processes across OS threads, so the\nbinding relies on EGL to preserve a process-oriented context model for OpenGL\ncalls.\n\nIn practice, think of the BEAM process that owns the current EGL context as the\nplace where the matching OpenGL calls should happen. This mirrors how OpenGL is\nusually structured in C while keeping the Erlang process model intact.\n\nThe target documentation explains this in more detail:\n[Context and testing](docs/context-and-testing.md).\n\n**API mapping**\n\nThe generated API follows deterministic mapping rules from the C OpenGL API to\nErlang and Elixir. Function names become lower snake case, enums are atoms, and\nOpenGL output parameters become return values.\n\nMost OpenGL code can be translated directly once those rules are familiar. If a\nspecific function shape is unclear, use the local\n[API mapping](docs/api-mapping.md), the generated\n[API reference](https://erlangsters.github.io/opengl-es-2.0/), and the\n[binding generator documentation](https://github.com/erlangsters/opengl-x.y-generator).\n\n## Using the binding in your project\n\nWith Rebar3, add the following to your project's `rebar.config`:\n\n```erlang\n{deps, [\n    {egl, {git, \"https://github.com/erlangsters/egl-1.5.git\", {tag, \"master\"}}},\n    {gl, {git, \"https://github.com/erlangsters/opengl-es-2.0.git\", {tag, \"master\"}}}\n]}.\n```\n\nDuring early development, `master` is shown for convenience. Pin a release tag\nor commit in applications that need reproducible builds.\n\nIf you use Erlang.mk, add the Git dependencies to your Makefile:\n\n```make\nBUILD_DEPS = egl gl\ndep_egl = git https://github.com/erlangsters/egl-1.5 master\ndep_gl = git https://github.com/erlangsters/opengl-es-2.0 master\n```\n\n## Generating the binding yourself\n\nThis repository is generated and hosted for convenience. To reproduce the\ngenerated files, clone the\n[OpenGL binding generator](https://github.com/erlangsters/opengl-x.y-generator),\ncompile it, and generate this target:\n\n```bash\nrebar3 escriptize\n./_build/default/bin/opengl_gen gles 2.0\n```\n\nThe generator writes `gl.erl`, `gl.hrl`, and `gl.c` into its working directory.\nThose files are then copied into this target repository and built as\n`priv/beam-gl.so` by CMake through Rebar3 hooks.\n\nDo not hand-edit generated `gl.erl`, `gl.hrl`, or `gl.c` files in this target\nrepository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferlangsters%2Fopengl-es-2.0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferlangsters%2Fopengl-es-2.0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferlangsters%2Fopengl-es-2.0/lists"}