0.0
No commit activity in last 3 years
No release in over 3 years
Parses the Khronos OpenGL registry into a standardized and user-friendly data structure that can be walked through, providing an essential need for tools that generate code to create an OpenGL wrapper/bindings, for any language. Given an API name, version, and profile, is capable of filtering and grouping data structures that cover that specific subset of definitions, using a typical Ruby object-oriented approach.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.0

Runtime

~> 2.13
 Project Readme

OpenGL Registry

Parses the Khronos OpenGL registry into a standardized and user-friendly data structure that can be walked through, providing an essential need for tools that generate code to create an OpenGL wrapper/bindings, for any language. Given an API name, version, and profile, is capable of filtering and grouping data structures that cover that specific subset of definitions, using a typical Ruby object-oriented approach.

Installation

Add this line to your application's Gemfile:

gem 'opengl-registry'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install opengl-registry

Usage

Get the OpenGL Registry from Khronos

You can either download the latest copy of gl.xml directly from the Khronos repo, or fetch it through the API.

require 'opengl-registry'

GL::Registry.download('/path/to/save/gl.xml')

For successive runs, you can simply check that the version you have is up to date.

if GL::Registry.outdated?('/path/to/gl.xml')
  # Download updated copy
end

Create a Registry instance

First step is to create the registry, which is essentially a container that stores every definition defined for OpenGL, OpenGLES (Embedded Systems), and OpenGLSC (Security Critical).

registry = GL::Registry.load('/path/to/gl.xml')

Alternatively, if you have the XML as a string...

registry = GL::Registry.parse(xml_string)

Create the OpenGL specification you wish to target

In order to filter results and definitions by a subset of the API, version, profile, etc, create a new spec.

extensions = ['GL_ARB_get_program_binary', 'GL_ARB_texture_storage']
spec = GL::Spec.new(registry, :gl, 3.3, :core, extensions)

The created spec object can be then used to enumerate through every definition that this subset defines. The data will automatically be filtered and sorted, allowing for easy inspection of each entity.

spec.functions.each do |function|
  # Print out the function name and return type
  puts "#{function.name} (#{function.type})"
    
  # Loop through argument definitions
  function.arguments.each do |argument|
    puts "  #{argument.name} (#{argument.type})"
  end
end

spec.enums.each do |enum|
  # Enums also define "groups" for creating C-style enumeration types, etc
  puts "#{enum.name} = #{enum.value}"
end

There are many helper functions throughout for detailed filtering, and retrieving any relevant information that might be required, such as generating bindings for a particular language, etc. See the documentation for more details.

License

The gem is available as open source under the terms of the MIT License.