Module: MilkTea::OpenGLRegistry

Defined in:
lib/milk_tea/bindings/opengl_registry.rb

Defined Under Namespace

Classes: BlockEntry, CommandEntry, CommandParam, EnumEntry, Error, ExtensionEntry, FeatureEntry, Generator, TypeEntry

Constant Summary collapse

DEFAULT_API =
"gl"
DEFAULT_VERSION =
"4.6"
DEFAULT_PROFILE =
"core"
SOURCE_NAME =
"opengl_registry"
HELPER_HEADER_BASENAME =
"gl_registry_helpers.h"
IMPLEMENTATION_DEFINE =
"MT_LANG_GL_REGISTRY_HELPERS_IMPLEMENTATION"

Class Method Summary collapse

Class Method Details

.helper_header_path(root: MilkTea.root) ⇒ Object



28
29
30
# File 'lib/milk_tea/bindings/opengl_registry.rb', line 28

def helper_header_path(root: MilkTea.root)
  root.join("std/c/#{HELPER_HEADER_BASENAME}")
end

.prepare!(root: MilkTea.root, api: DEFAULT_API, version: DEFAULT_VERSION, profile: DEFAULT_PROFILE, extensions: []) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/milk_tea/bindings/opengl_registry.rb', line 37

def prepare!(root: MilkTea.root, api: DEFAULT_API, version: DEFAULT_VERSION, profile: DEFAULT_PROFILE, extensions: [])
  registry_source = source(root:)
  registry_source.bootstrap!

  generated = Generator.new(
    xml_path: registry_source.checkout_root.join("xml/gl.xml"),
    api:,
    version:,
    profile:,
    extensions:,
  ).generate

  path = helper_header_path(root:)
  FileUtils.mkdir_p(path.dirname)
  return if File.exist?(path) && File.read(path) == generated

  File.write(path, generated)
end

.source(root: MilkTea.root) ⇒ Object



32
33
34
35
# File 'lib/milk_tea/bindings/opengl_registry.rb', line 32

def source(root: MilkTea.root)
  UpstreamSources.default_sources(root:).find { |entry| entry.name == SOURCE_NAME } ||
    raise(Error, "missing upstream source definition for #{SOURCE_NAME}")
end