1f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang//
2f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang// Use of this source code is governed by a BSD-style license that can be
4f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang// found in the LICENSE file.
5f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang//
6f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
7f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang#ifndef SAMPLE_UTIL_MATRIX_H
8f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang#define SAMPLE_UTIL_MATRIX_H
9f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
10f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang#include "Vector.h"
11f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
12f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Langstruct Matrix4
13f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang{
14f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    float data[16];
15f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
16f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    Matrix4();
17f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    Matrix4(float m00, float m01, float m02, float m03,
18f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang            float m10, float m11, float m12, float m13,
19f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang            float m20, float m21, float m22, float m23,
20f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang            float m30, float m31, float m32, float m33);
21f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
22f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 identity();
23f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 rotate(float angle, const Vector3 &p);
24f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 translate(const Vector3 &t);
25f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 scale(const Vector3 &s);
26f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 frustum(float l, float r, float b, float t, float n, float f);
27f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 perspective(float fov, float aspectRatio, float n, float f);
28f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 ortho(float l, float r, float b, float t, float n, float f);
29f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 rollPitchYaw(float roll, float pitch, float yaw);
30f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
31f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 invert(const Matrix4 &mat);
32f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Matrix4 transpose(const Matrix4 &mat);
33f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Vector3 transform(const Matrix4 &mat, const Vector3 &pt);
34f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang    static Vector3 transform(const Matrix4 &mat, const Vector4 &pt);
35f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang};
36f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
37f6139359a16220c0e29695b23b3707d3d6f053eaGeoff LangMatrix4 operator*(const Matrix4 &a, const Matrix4 &b);
38f6139359a16220c0e29695b23b3707d3d6f053eaGeoff LangMatrix4 &operator*=(Matrix4 &a, const Matrix4 &b);
39f6139359a16220c0e29695b23b3707d3d6f053eaGeoff LangMatrix4 operator*(const Matrix4 &a, float b);
40f6139359a16220c0e29695b23b3707d3d6f053eaGeoff LangMatrix4 &operator*=(Matrix4 &a, float b);
41f6139359a16220c0e29695b23b3707d3d6f053eaGeoff LangVector4 operator*(const Matrix4 &a, const Vector4 &b);
42f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
43f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Langbool operator==(const Matrix4 &a, const Matrix4 &b);
44f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Langbool operator!=(const Matrix4 &a, const Matrix4 &b);
45f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang
46f6139359a16220c0e29695b23b3707d3d6f053eaGeoff Lang#endif // SAMPLE_UTIL_MATRIX_H
47