OpenGL Bindings for Crystal

This repository contains dynamically generated OpenGL bindings for the Crystal language. In addition, this repository also contains bindings for OpenGL ES and OpenGL ES-SC. This repository is updated with the contents of the OpenGL Registry.

Usage

Each branch in this repository references one version of OpenGL (or GLES). The master branch always references the latest version of OpenGL. However, it is recommended that a versioned branch is used over master. Add the following to your shard.yml dependencies:

dependencies:
  opengl:
    gitlab: arctic-fox/opengl.cr
    branch: gl-4.6-core

The branch names are formatted like so:

API-VERSION[-PROFILE]

Where API is one of:

VERSION is the version of the API. PROFILE is the OpenGL profile, which only applies to the gl API. It can be core or compatibility. Only OpenGL versions 3.2+ need to specify a profile. See OpenGL 3.2 and Profiles for details on profiles.

Branches

LibGL

Everything in the shard is contained in a LibGL C lib. There are no wrappers or objects, just the C bindings and values. Names have been "crystalized." This means the function and enum names have been modified to fit Crystal's naming scheme. All function names have the gl prefix stripped. Enum groups are fully-fledged Crystal enums. This helps ensure type safety.

require "opengl"

LibGL.clear(LibGL::ClearBufferMask::ColorBuffer)
LibGL.begin(LibGL::PrimitiveType::Triangles)
LibGL.color_3f(1.0, 0.0, 0.0)
LibGL.vertex_2f(-0.75, -0.75)
LibGL.color_3f(0.0, 1.0, 0.0)
LibGL.vertex_2f(0.75, -0.75)
LibGL.color_3f(0.0, 0.0, 1.0)
LibGL.vertex_2f(0.0, 0.75)
LibGL.end
LibGL.flush

All binding files are in the src/opengl/ directory. Contents are grouped logically into files based on their group or type. Some important files are functions.cr, types.cr, and procs.cr. The functions.cr file contains all of the function bindings. The types.cr file contains all of the non-enum types. They are mostly aliases to existing types. The procs.cr file contains methods that return Proc types for their corresponding method. This can be used for OpenGL function loaders.

Contributing

This shard and the entire repository are dynamically generated. Issues and pull requests should not be submitted on this repository. Instead, submit them to the generator repository.