Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / examples / api / graphics_3d / matrix.h
blobed094eda094c092ab37d33ea973419894e2da10f
1 #ifndef EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
2 #define EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
4 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
9 /** @file matrix.cc
10 * Implements simple matrix manipulation functions.
13 //-----------------------------------------------------------------------------
14 #define _USE_MATH_DEFINES 1
15 #include <limits.h>
16 #include <math.h>
17 #include <GLES2/gl2.h>
19 typedef GLfloat Matrix_t[16];
21 /// Since GLES2 doesn't have all the nifty matrix transform functions that GL
22 /// has, we emulate some of them here for the sake of sanity from:
23 /// http://www.opengl.org/wiki/GluPerspective_code
24 void glhFrustumf2(Matrix_t mat,
25 GLfloat left,
26 GLfloat right,
27 GLfloat bottom,
28 GLfloat top,
29 GLfloat znear,
30 GLfloat zfar);
32 void glhPerspectivef2(Matrix_t mat,
33 GLfloat fovyInDegrees,
34 GLfloat aspectRatio,
35 GLfloat znear,
36 GLfloat zfar);
38 void identity_matrix(Matrix_t mat);
39 void multiply_matrix(const Matrix_t a, const Matrix_t b, Matrix_t mat);
40 void rotate_matrix(GLfloat x_deg, GLfloat y_deg, GLfloat z_deg, Matrix_t mat);
41 void translate_matrix(GLfloat x, GLfloat y, GLfloat z, Matrix_t mat);
43 #endif // EXAMPLES_HELLO_WORLD_GLES_MATRIX_H