• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Book:      OpenGL(R) ES 2.0 Programming Guide
3 // Authors:   Aaftab Munshi, Dan Ginsburg, Dave Shreiner
4 // ISBN-10:   0321502795
5 // ISBN-13:   9780321502797
6 // Publisher: Addison-Wesley Professional
7 // URLs:      http://safari.informit.com/9780321563835
8 //            http://www.opengles-book.com
9 //
10 
11 /*
12  * (c) 2009 Aaftab Munshi, Dan Ginsburg, Dave Shreiner
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a
15  * copy of this software and associated documentation files (the "Software"),
16  * to deal in the Software without restriction, including without limitation
17  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18  * and/or sell copies of the Software, and to permit persons to whom the
19  * Software is furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included
22  * in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  */
32 
33 //
34 /// \file ESUtil.h
35 /// \brief A utility library for OpenGL ES.  This library provides a
36 ///        basic common framework for the example applications in the
37 ///        OpenGL ES 2.0 Programming Guide.
38 //
39 #ifndef ESUTIL_H
40 #define ESUTIL_H
41 
42 ///
43 //  Includes
44 //
45 #include <GLES2/gl2.h>
46 #include <EGL/egl.h>
47 
48 #ifdef __cplusplus
49 
50 extern "C" {
51 #endif
52 
53 typedef struct
54 {
55 	GLfloat m[4][4];
56 } ESMatrix;
57 
58 //
59 /// \brief multiply matrix specified by result with a scaling matrix and return new matrix in result
60 /// \param result Specifies the input matrix.  Scaled matrix is returned in result.
61 /// \param sx, sy, sz Scale factors along the x, y and z axes respectively
62 //
63 void esScale(ESMatrix* result, GLfloat sx, GLfloat sy, GLfloat sz);
64 
65 //
66 /// \brief multiply matrix specified by result with a translation matrix and return new matrix in result
67 /// \param result Specifies the input matrix.  Translated matrix is returned in result.
68 /// \param tx, ty, tz Scale factors along the x, y and z axes respectively
69 //
70 void esTranslate(ESMatrix* result, GLfloat tx, GLfloat ty, GLfloat tz);
71 
72 //
73 /// \brief multiply matrix specified by result with a rotation matrix and return new matrix in result
74 /// \param result Specifies the input matrix.  Rotated matrix is returned in result.
75 /// \param angle Specifies the angle of rotation, in degrees.
76 /// \param x, y, z Specify the x, y and z coordinates of a vector, respectively
77 //
78 void esRotate(ESMatrix* result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
79 
80 //
81 // \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
82 /// \param result Specifies the input matrix.  new matrix is returned in result.
83 /// \param left, right Coordinates for the left and right vertical clipping planes
84 /// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
85 /// \param nearZ, farZ Distances to the near and far depth clipping planes.  Both distances must be positive.
86 //
87 void esFrustum(ESMatrix* result, float left, float right, float bottom, float top, float nearZ, float farZ);
88 
89 //
90 /// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
91 /// \param result Specifies the input matrix.  new matrix is returned in result.
92 /// \param fovy Field of view y angle in degrees
93 /// \param aspect Aspect ratio of screen
94 /// \param nearZ Near plane distance
95 /// \param farZ Far plane distance
96 //
97 void esPerspective(ESMatrix* result, float fovy, float aspect, float nearZ, float farZ);
98 
99 //
100 /// \brief multiply matrix specified by result with a perspective matrix and return new matrix in result
101 /// \param result Specifies the input matrix.  new matrix is returned in result.
102 /// \param left, right Coordinates for the left and right vertical clipping planes
103 /// \param bottom, top Coordinates for the bottom and top horizontal clipping planes
104 /// \param nearZ, farZ Distances to the near and far depth clipping planes.  These values are negative if plane is behind the viewer
105 //
106 void esOrtho(ESMatrix* result, float left, float right, float bottom, float top, float nearZ, float farZ);
107 
108 //
109 /// \brief perform the following operation - result matrix = srcA matrix * srcB matrix
110 /// \param result Returns multiplied matrix
111 /// \param srcA, srcB Input matrices to be multiplied
112 //
113 void esMatrixMultiply(ESMatrix* result, ESMatrix* srcA, ESMatrix* srcB);
114 
115 //
116 //// \brief return an indentity matrix
117 //// \param result returns identity matrix
118 //
119 void esMatrixLoadIdentity(ESMatrix* result);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif // ESUTIL_H
126