Sha256: 01d128f41f32bb5059be86805b2eec335bae9a3c83a043401870329e7103fdd1

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# -*- coding: utf-8 -*-


require 'xot/block_util'
require 'rays/ext'


module Rays


  class Shader

    def initialize(
      fragment_shader_source,
      vertex_shader_source   = nil,
      builtin_variable_names = nil,
      ignore_no_uniform_location_error: false,
      **uniforms, &block)

      setup(
        fragment_shader_source, vertex_shader_source,
        builtin_variable_names&.values_at(
          :attribute_position, :attribute_texcoord, :attribute_color,
            :varying_position,   :varying_texcoord,   :varying_color,
          :uniform_position_matrix, :uniform_texcoord_matrix,
          :uniform_texcoord_min, :uniform_texcoord_max, :uniform_texcoord_offset,
          :uniform_texture),
        ignore_no_uniform_location_error)

      uniform(**uniforms) unless uniforms.empty?

      Xot::BlockUtil.instance_eval_or_block_call self, &block if block
    end

    def uniform(name = nil, *args, **uniforms)
      set_uniform name, *args if name
      uniforms.each do |key, value|
        set_uniform key, value
      end
    end

  end# Shader


end# Rays

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rays-0.1.34 lib/rays/shader.rb
rays-0.1.33 lib/rays/shader.rb
rays-0.1.32 lib/rays/shader.rb
rays-0.1.31 lib/rays/shader.rb
rays-0.1.30 lib/rays/shader.rb
rays-0.1.29 lib/rays/shader.rb