Sha256: f2121cc3d92fe6364f41ed10716a7e10d1df81f069895a2f33e9d12359b38668

Contents?: true

Size: 1.45 KB

Versions: 13

Compression:

Stored size: 1.45 KB

Contents

describe("Preprocessor", function() {
  var matr;
  
  beforeEach(function() {
    matr = new Jax.Material();
  });
  
  it("should be able to determine shader type from within common code", function() {
    Jax.shaders['test'] = new Jax.Shader({
      common: "void <%=shader_type%>(void) { return; }",
      vertex: "void main(void) { gl_Position = vec4(0,0,0,1); }",
      fragment: "void main(void) { discard; }",
      name: "test"
    });
    
    expect(Jax.shaders['test'].getVertexSource(matr)).toMatch(/void vertex\(void\)/);
    expect(Jax.shaders['test'].getFragmentSource(matr)).toMatch(/void fragment\(void\)/);
  });
  
  describe("with multiple similar vardecs", function() {
    Jax.shaders['test'] = new Jax.Shader({
      vertex: "shared uniform mat4 ivMatrix, mvMatrix, pMatrix, vMatrix;\n" +
              "uniform mat4 imvMatrix;\n" +
              "void main(void) { gl_Position = pMatrix * imvMatrix * vec4(0,0,0,1); }",
      fragment: "void main(void) { }",
      name: "test"
    });

    var TestMaterial = Jax.Class.create(Jax.Material, {
      initialize: function($super) { $super({shader: "test"}); },

      setVariables: function(context, mesh, options, vars) {
        vars.set('imvMatrix', context.getInverseModelViewMatrix());
      }
    });

    beforeEach(function() {
      matr.addLayer(new TestMaterial());
    });

    it("should should not fail", function() {
      new Jax.Mesh({material:matr}).render(SPEC_CONTEXT);
    });
  });
});

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jax-2.0.12 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.11 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.10 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.9 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.8 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.7 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.6 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.5 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.4 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.3 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.2 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.1 spec/javascripts/shaders/preprocessor_spec.js
jax-2.0.0 spec/javascripts/shaders/preprocessor_spec.js