Class: Rugl::CommandCompiler
- Inherits:
-
Object
- Object
- Rugl::CommandCompiler
- Defined in:
- lib/rugl/command_compiler.rb
Constant Summary collapse
- STATE_KEYS =
%i[ depth blend stencil scissor cull polygon_offset color_mask front_face line_width dither sample viewport ].freeze
Instance Method Summary collapse
- #compile(opts) ⇒ Object
-
#initialize(context) ⇒ CommandCompiler
constructor
A new instance of CommandCompiler.
Constructor Details
#initialize(context) ⇒ CommandCompiler
Returns a new instance of CommandCompiler.
10 11 12 |
# File 'lib/rugl/command_compiler.rb', line 10 def initialize(context) @context = context end |
Instance Method Details
#compile(opts) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rugl/command_compiler.rb', line 14 def compile(opts) validate_command_opts!(opts) program = get_or_create_program(opts.fetch(:vert), opts.fetch(:frag)) attributes = compile_attributes(opts[:attributes] || {}, program) uniforms = compile_uniforms(opts[:uniforms] || {}, program) elements = opts[:elements] state = compile_state(opts) draw_params = { count: opts[:count], primitive: opts.fetch(:primitive, :triangles), offset: opts.fetch(:offset, 0), instances: opts[:instances] } vao = create_vao(attributes, elements) Command.new( context: @context, program: program, vao: vao, attributes: attributes, uniforms: uniforms, elements: elements, state: state, draw_params: draw_params, framebuffer: opts[:framebuffer] ) end |