10f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#ifndef EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
20f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#define EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
30f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
40f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
50f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be
60f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) * found in the LICENSE file.
70f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) */
80f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
90f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)/** @file matrix.cc
100f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) * Implements simple matrix manipulation functions.
110f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) */
120f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
130f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//-----------------------------------------------------------------------------
140f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#define _USE_MATH_DEFINES 1
150f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include <limits.h>
160f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include <math.h>
170f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include <GLES2/gl2.h>
180f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
190f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)typedef GLfloat Matrix_t[16];
200f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
210f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)/// Since GLES2 doesn't have all the nifty matrix transform functions that GL
220f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)/// has, we emulate some of them here for the sake of sanity from:
230f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)/// http://www.opengl.org/wiki/GluPerspective_code
240f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void glhFrustumf2(Matrix_t mat,
250f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat left,
260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat right,
270f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat bottom,
280f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat top,
290f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat znear,
300f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  GLfloat zfar);
310f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
320f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void glhPerspectivef2(Matrix_t mat,
330f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                      GLfloat fovyInDegrees,
340f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                      GLfloat aspectRatio,
350f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                      GLfloat znear,
360f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                      GLfloat zfar);
370f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
380f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void identity_matrix(Matrix_t mat);
390f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void multiply_matrix(const Matrix_t a, const Matrix_t b, Matrix_t mat);
400f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void rotate_matrix(GLfloat x_deg, GLfloat y_deg, GLfloat z_deg, Matrix_t mat);
410f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)void translate_matrix(GLfloat x, GLfloat y, GLfloat z, Matrix_t mat);
420f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
430f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#endif  // EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
44