Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: third_party/gles_book_examples/Common/Source/esShapes.c

Issue 527016: Added gyp file for examples. Removed unnecessary functions. Added header file... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // 1 //
2 // Book: OpenGL(R) ES 2.0 Programming Guide 2 // Book: OpenGL(R) ES 2.0 Programming Guide
3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner 3 // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
4 // ISBN-10: 0321502795 4 // ISBN-10: 0321502795
5 // ISBN-13: 9780321502797 5 // ISBN-13: 9780321502797
6 // Publisher: Addison-Wesley Professional 6 // Publisher: Addison-Wesley Professional
7 // URLs: http://safari.informit.com/9780321563835 7 // URLs: http://safari.informit.com/9780321563835
8 // http://www.opengles-book.com 8 // http://www.opengles-book.com
9 // 9 //
10 10
11 // ESShapes.c 11 // ESShapes.c
12 // 12 //
13 // Utility functions for generating shapes 13 // Utility functions for generating shapes
14 // 14 //
15 15
16 /// 16 ///
17 // Includes 17 // Includes
18 // 18 //
19 #include "esUtil.h" 19 #include "esUtil.h"
20 #include <stdlib.h> 20 #include <stdlib.h>
21 #include <math.h> 21 #include <math.h>
22 #include <string.h>
22 23
23 /// 24 ///
24 // Defines 25 // Defines
25 // 26 //
26 #define ES_PI (3.14159265f) 27 #define ES_PI (3.14159265f)
27 28
28 ////////////////////////////////////////////////////////////////// 29 //////////////////////////////////////////////////////////////////
29 // 30 //
30 // Private Functions 31 // Private Functions
31 // 32 //
(...skipping 11 matching lines...) Expand all
43 /// \brief Generates geometry for a sphere. Allocates memory for the vertex dat a and stores 44 /// \brief Generates geometry for a sphere. Allocates memory for the vertex dat a and stores
44 /// the results in the arrays. Generate index list for a TRIANGLE_STRIP 45 /// the results in the arrays. Generate index list for a TRIANGLE_STRIP
45 /// \param numSlices The number of slices in the sphere 46 /// \param numSlices The number of slices in the sphere
46 /// \param vertices If not NULL, will contain array of float3 positions 47 /// \param vertices If not NULL, will contain array of float3 positions
47 /// \param normals If not NULL, will contain array of float3 normals 48 /// \param normals If not NULL, will contain array of float3 normals
48 /// \param texCoords If not NULL, will contain array of float2 texCoords 49 /// \param texCoords If not NULL, will contain array of float2 texCoords
49 /// \param indices If not NULL, will contain the array of indices for the triang le strip 50 /// \param indices If not NULL, will contain the array of indices for the triang le strip
50 /// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array 51 /// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
51 /// if it is not NULL ) as a GL_TRIANGLE_STRIP 52 /// if it is not NULL ) as a GL_TRIANGLE_STRIP
52 // 53 //
53 int ESUTIL_API esGenSphere ( int numSlices, float radius, GLfloat **vertices, GL float **normals, 54 int esGenSphere ( int numSlices, float radius, GLfloat **vertices, GLfloat **nor mals,
54 GLfloat **texCoords, GLuint **indices ) 55 GLfloat **texCoords, GLuint **indices )
55 { 56 {
56 int i; 57 int i;
57 int j; 58 int j;
58 int numParallels = numSlices / 2; 59 int numParallels = numSlices / 2;
59 int numVertices = ( numParallels + 1 ) * ( numSlices + 1 ); 60 int numVertices = ( numParallels + 1 ) * ( numSlices + 1 );
60 int numIndices = numParallels * numSlices * 6; 61 int numIndices = numParallels * numSlices * 6;
61 float angleStep = (2.0f * ES_PI) / ((float) numSlices); 62 float angleStep = (2.0f * ES_PI) / ((float) numSlices);
62 63
63 // Allocate memory for buffers 64 // Allocate memory for buffers
64 if ( vertices != NULL ) 65 if ( vertices != NULL )
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 /// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores 131 /// \brief Generates geometry for a cube. Allocates memory for the vertex data and stores
131 /// the results in the arrays. Generate index list for a TRIANGLES 132 /// the results in the arrays. Generate index list for a TRIANGLES
132 /// \param scale The size of the cube, use 1.0 for a unit cube. 133 /// \param scale The size of the cube, use 1.0 for a unit cube.
133 /// \param vertices If not NULL, will contain array of float3 positions 134 /// \param vertices If not NULL, will contain array of float3 positions
134 /// \param normals If not NULL, will contain array of float3 normals 135 /// \param normals If not NULL, will contain array of float3 normals
135 /// \param texCoords If not NULL, will contain array of float2 texCoords 136 /// \param texCoords If not NULL, will contain array of float2 texCoords
136 /// \param indices If not NULL, will contain the array of indices for the triang le strip 137 /// \param indices If not NULL, will contain the array of indices for the triang le strip
137 /// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array 138 /// \return The number of indices required for rendering the buffers (the number of indices stored in the indices array
138 /// if it is not NULL ) as a GL_TRIANGLE_STRIP 139 /// if it is not NULL ) as a GL_TRIANGLE_STRIP
139 // 140 //
140 int ESUTIL_API esGenCube ( float scale, GLfloat **vertices, GLfloat **normals, 141 int esGenCube ( float scale, GLfloat **vertices, GLfloat **normals,
141 GLfloat **texCoords, GLuint **indices ) 142 GLfloat **texCoords, GLuint **indices )
142 { 143 {
143 int i; 144 int i;
144 int numVertices = 24; 145 int numVertices = 24;
145 int numIndices = 36; 146 int numIndices = 36;
146 147
147 GLfloat cubeVerts[] = 148 GLfloat cubeVerts[] =
148 { 149 {
149 -0.5f, -0.5f, -0.5f, 150 -0.5f, -0.5f, -0.5f,
150 -0.5f, -0.5f, 0.5f, 151 -0.5f, -0.5f, 0.5f,
151 0.5f, -0.5f, 0.5f, 152 0.5f, -0.5f, 0.5f,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 16, 18, 19, 270 16, 18, 19,
270 20, 23, 22, 271 20, 23, 22,
271 20, 22, 21 272 20, 22, 21
272 }; 273 };
273 274
274 *indices = malloc ( sizeof(GLuint) * numIndices ); 275 *indices = malloc ( sizeof(GLuint) * numIndices );
275 memcpy( *indices, cubeIndices, sizeof( cubeIndices ) ); 276 memcpy( *indices, cubeIndices, sizeof( cubeIndices ) );
276 } 277 }
277 278
278 return numIndices; 279 return numIndices;
279 } 280 }
OLDNEW
« no previous file with comments | « third_party/gles_book_examples/Common/Source/esShader.c ('k') | third_party/gles_book_examples/Common/Source/esTransform.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698