Class: GL::Registry
- Inherits:
-
Object
- Object
- GL::Registry
- Defined in:
- lib/opengl/registry.rb,
lib/opengl/registry/enum.rb,
lib/opengl/registry/group.rb,
lib/opengl/registry/token.rb,
lib/opengl/registry/feature.rb,
lib/opengl/registry/version.rb,
lib/opengl/registry/argument.rb,
lib/opengl/registry/function.rb,
lib/opengl/registry/extension.rb,
lib/opengl/registry/native_type.rb,
lib/opengl/registry/feature_group.rb,
lib/opengl/registry/feature_provider.rb
Overview
Container for all definitions of the OpenGL registry.
Defined Under Namespace
Classes: Argument, Enum, Extension, Feature, FeatureGroup, FeatureProvider, Function, Group, NativeType, Token
Constant Summary collapse
- GL_TYPES =
An array of OpenGL type names, as symbols.
%i[ GLenum GLboolean GLbitfield GLvoid GLbyte GLubyte GLshort GLushort GLint GLuint GLclampx GLsizei GLfloat GLclampf GLdouble GLclampd GLeglClientBufferEXT GLeglImageOES GLchar GLhandleARB GLhalf GLhalfARB GLfixed GLintptr GLintptrARB GLsizeiptr GLsizeiptrARB GLint64 GLint64EXT GLuint64 GLuint64EXT GLsync struct\ _cl_context struct\ _cl_event GLDEBUGPROC GLDEBUGPROCARB GLDEBUGPROCKHR GLDEBUGPROCAMD GLhalfNV GLvdpauSurfaceNV GLVULKANPROCNV ].freeze
- VERSION =
The current version of the
opengl-registry
gem. '1.0.1'
Instance Attribute Summary collapse
-
#enums ⇒ Array<Enum>
readonly
A complete collection of all OpenGL enum values.
-
#extensions ⇒ Array<Extension>
readonly
A complete collection of all OpenGL extensions.
-
#features ⇒ Array<FeatureGroup>
readonly
A complete collection of all OpenGL feature groups.
-
#functions ⇒ Array<Function>
readonly
A complete collection of all OpenGL functions.
-
#groups ⇒ Array<Group>
readonly
A collection of all enumeration groups defined by OpenGL.
Class Method Summary collapse
-
.download(path) ⇒ Boolean
Download the latest version of the OpenGL registry to the specified file.
-
.load(path) ⇒ Registry
Creates a new Registry from the specified XML file.
-
.outdated?(path) ⇒ Boolean
Compares the registry at the specified path to the current registry version and returns value indicating if there is a newer version available.
-
.parse(xml) ⇒ Registry
Creates a new Registry from the specified XML string.
Instance Method Summary collapse
-
#api_names ⇒ Array<Symbol>
An array of Symbol objects that represent each defined API in the registry.
-
#each_enum ⇒ Object
Enumerates through each enum defined in the registry.
-
#each_extension ⇒ Object
Enumerates through each extension defined in the registry.
-
#each_feature ⇒ Object
Enumerates through each feature group defined in the registry.
-
#each_function ⇒ Object
Enumerates through each function defined in the registry.
-
#each_group ⇒ Object
Enumerates through each group defined in the registry.
-
#profiles(api = nil, version = '1.0') ⇒ Array<Symbol>
Retrieves an array of profiles defined in the registry.
Instance Attribute Details
#enums ⇒ Array<Enum> (readonly)
Returns a complete collection of all OpenGL enum values.
|
# File 'lib/opengl/registry.rb', line 68
|
#extensions ⇒ Array<Extension> (readonly)
Returns a complete collection of all OpenGL extensions.
78 79 80 |
# File 'lib/opengl/registry.rb', line 78 def extensions @extensions end |
#features ⇒ Array<FeatureGroup> (readonly)
Returns a complete collection of all OpenGL feature groups.
74 75 76 |
# File 'lib/opengl/registry.rb', line 74 def features @features end |
#functions ⇒ Array<Function> (readonly)
Returns a complete collection of all OpenGL functions.
66 67 68 |
# File 'lib/opengl/registry.rb', line 66 def functions @functions end |
#groups ⇒ Array<Group> (readonly)
This is for reference only, and should not be used for building definitions or determining a comprehensive list of which enum values belong in each group, use the GL::Registry::Enum#groups property instead.
Returns a collection of all enumeration groups defined by OpenGL.
62 63 64 |
# File 'lib/opengl/registry.rb', line 62 def groups @groups end |
Class Method Details
.download(path) ⇒ Boolean
Download the latest version of the OpenGL registry to the specified file.
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/opengl/registry.rb', line 237 def self.download(path) begin URI.open('https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml') do |io| FileUtils.mv(io.path, path) end return true rescue return false end end |
.load(path) ⇒ Registry
Creates a new GL::Registry from the specified XML file.
86 87 88 89 |
# File 'lib/opengl/registry.rb', line 86 def self.load(path) doc = Ox.load_file(path, mode: :generic) new(doc.root) end |
.outdated?(path) ⇒ Boolean
This method is not guaranteed to be accurate, it only uses the timestamps in the file's metadata, which could be inaccurate due to file copying, system time changes, creating from different source, etc.
Compares the registry at the specified path to the current registry version and returns value indicating if there is a newer version available.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/opengl/registry.rb', line 259 def self.outdated?(path) return false unless path && File.exist?(path) begin uri = URI('https://api.github.com/repos/KhronosGroup/OpenGL-Registry/commits?path=xml/gl.xml') Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 3, read_timeout: 5) do |http| req = Net::HTTP::Get.new(uri) response = http.request(req) if response.code == '200' json = JSON.parse(response.body, symbolize_names: true) commit = DateTime.parse(json.first[:commit][:author][:date]).to_time return File.mtime(path) < commit end end rescue warn('failed to query current registry version') return false end end |
.parse(xml) ⇒ Registry
Creates a new GL::Registry from the specified XML string.
97 98 99 100 |
# File 'lib/opengl/registry.rb', line 97 def self.parse(xml) doc = Ox.load(xml, mode: :generic) new(doc.root) end |
Instance Method Details
#api_names ⇒ Array<Symbol>
Returns an array of Symbol objects that represent each defined API in the registry.
104 105 106 107 108 |
# File 'lib/opengl/registry.rb', line 104 def api_names # RubyMine warns that the return value is wrong. It lies. #noinspection RubyYardReturnMatch @features.map(&:api).uniq end |
#each_enum ⇒ Enumerator #each_enum {|enum| ... } ⇒ void
Enumerates through each enum defined in the registry.
150 151 152 153 154 155 156 157 |
# File 'lib/opengl/registry.rb', line 150 def each_enum #noinspection RubyYardReturnMatch return enum_for(__method__) unless block_given? @groups.each do |group| group.members.each { |item| yield item } end nil end |
#each_enum ⇒ Enumerator #each_enum {|enum| ... } ⇒ void
Enumerates through each extension defined in the registry.
224 225 226 227 228 229 |
# File 'lib/opengl/registry.rb', line 224 def each_extension #noinspection RubyYardReturnMatch return enum_for(__method__) unless block_given? @extensions.each { |item| yield item } nil end |
#each_feature ⇒ Enumerator #each_feature {|enum| ... } ⇒ void
Enumerates through each feature group defined in the registry.
206 207 208 209 210 211 |
# File 'lib/opengl/registry.rb', line 206 def each_feature #noinspection RubyYardReturnMatch return enum_for(__method__) unless block_given? @features.each { |item| yield item } nil end |
#each_function ⇒ Enumerator #each_function {|enum| ... } ⇒ void
Enumerates through each function defined in the registry.
188 189 190 191 192 193 |
# File 'lib/opengl/registry.rb', line 188 def each_function #noinspection RubyYardReturnMatch return enum_for(__method__) unless block_given? @functions.each { |item| yield item } nil end |
#each_group ⇒ Enumerator #each_group {|group| ... } ⇒ void
Enumerates through each group defined in the registry.
170 171 172 173 174 175 |
# File 'lib/opengl/registry.rb', line 170 def each_group #noinspection RubyYardReturnMatch return enum_for(__method__) unless block_given? @groups.each { |item| yield item } nil end |
#profiles ⇒ Array<Symbol> #profiles(api) ⇒ Array<Symbol> #profiles(api, version) ⇒ Array<Symbol>
Retrieves an array of profiles defined in the registry.
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/opengl/registry.rb', line 123 def profiles(api = nil, version = '1.0') # RubyMine warns that the return value is wrong. It lies. if api values = @features.find_all { |group| group.api == api && group.version <= version.to_s } #noinspection RubyYardReturnMatch return values.flat_map(&:additions).map(&:profile).uniq end #noinspection RubyYardReturnMatch @features.flat_map(&:additions).map(&:profile).uniq end |