aboutsummaryrefslogtreecommitdiff
path: root/src/libmatrix/test/shader_source_test.cc
blob: 31d0265e14195b7984db701a28fa00a01a61202b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
44
45
46
47
48
49
//
// Copyright (c) 2012 Linaro Limited
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the MIT License which accompanies
// this distribution, and is available at
// http://www.opensource.org/licenses/mit-license.php
//
// Contributors:
//     Jesse Barker - original implementation.
//
#include <string>
#include "libmatrix_test.h"
#include "shader_source_test.h"
#include "../shader-source.h"
#include "../vec.h"

using std::string;
using LibMatrix::vec4;

void
ShaderSourceBasic::run(const Options& options)
{
    static const string vtx_shader_filename("test/basic.vert");

    ShaderSource vtx_source(vtx_shader_filename);
    ShaderSource vtx_source2(vtx_shader_filename);
    
    pass_ = (vtx_source.str() == vtx_source2.str());
}

void
ShaderSourceAddConstGlobal::run(const Options& options)
{
    // Load the original shader source.
    static const string src_shader_filename("test/basic.vert");
    ShaderSource src_shader(src_shader_filename);

    // Add constant at global scope
    static const vec4 constantColor(1.0, 1.0, 1.0, 1.0);
    src_shader.add_const("ConstantColor", constantColor);

    // Load the pre-modified shader
    static const string result_shader_filename("test/basic-global-const.vert");
    ShaderSource result_shader(result_shader_filename);

    // Compare the output strings to confirm the results.
    pass_ = (src_shader.str() == result_shader.str());
}