- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / examples / api / graphics_3d / matrix.h
1 #ifndef EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
2 #define EXAMPLES_HELLO_WORLD_GLES_MATRIX_H
3
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  */
8
9 /** @file matrix.cc
10  * Implements simple matrix manipulation functions.
11  */
12
13 //-----------------------------------------------------------------------------
14 #define _USE_MATH_DEFINES 1
15 #include <limits.h>
16 #include <math.h>
17 #include <GLES2/gl2.h>
18
19 typedef GLfloat Matrix_t[16];
20
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);
31
32 void glhPerspectivef2(Matrix_t mat,
33                       GLfloat fovyInDegrees,
34                       GLfloat aspectRatio,
35                       GLfloat znear,
36                       GLfloat zfar);
37
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);
42
43 #endif  // EXAMPLES_HELLO_WORLD_GLES_MATRIX_H