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