OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Cube.h
Go to the documentation of this file.
1 /* Copyright (c) 2012-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef CUBE_H
22 #define CUBE_H
23 
24 #define GLES_VERSION 2
25 
26 #include <GLES2/gl2.h>
27 
28 /* 3D data. Vertex range -0.5..0.5 in all axes.
29 * Z -0.5 is near, 0.5 is far. */
30 const float vertices[] =
31 {
32  /* Front face. */
33  /* Bottom left */
34  -0.5, 0.5, -0.5,
35  0.5, -0.5, -0.5,
36  -0.5, -0.5, -0.5,
37  /* Top right */
38  -0.5, 0.5, -0.5,
39  0.5, 0.5, -0.5,
40  0.5, -0.5, -0.5,
41  /* Left face */
42  /* Bottom left */
43  -0.5, 0.5, 0.5,
44  -0.5, -0.5, -0.5,
45  -0.5, -0.5, 0.5,
46  /* Top right */
47  -0.5, 0.5, 0.5,
48  -0.5, 0.5, -0.5,
49  -0.5, -0.5, -0.5,
50  /* Top face */
51  /* Bottom left */
52  -0.5, 0.5, 0.5,
53  0.5, 0.5, -0.5,
54  -0.5, 0.5, -0.5,
55  /* Top right */
56  -0.5, 0.5, 0.5,
57  0.5, 0.5, 0.5,
58  0.5, 0.5, -0.5,
59  /* Right face */
60  /* Bottom left */
61  0.5, 0.5, -0.5,
62  0.5, -0.5, 0.5,
63  0.5, -0.5, -0.5,
64  /* Top right */
65  0.5, 0.5, -0.5,
66  0.5, 0.5, 0.5,
67  0.5, -0.5, 0.5,
68  /* Back face */
69  /* Bottom left */
70  0.5, 0.5, 0.5,
71  -0.5, -0.5, 0.5,
72  0.5, -0.5, 0.5,
73  /* Top right */
74  0.5, 0.5, 0.5,
75  -0.5, 0.5, 0.5,
76  -0.5, -0.5, 0.5,
77  /* Bottom face */
78  /* Bottom left */
79  -0.5, -0.5, -0.5,
80  0.5, -0.5, 0.5,
81  -0.5, -0.5, 0.5,
82  /* Top right */
83  -0.5, -0.5, -0.5,
84  0.5, -0.5, -0.5,
85  0.5, -0.5, 0.5,
86 };
87 
88 const float colors[] =
89 {
90  /* Front face */
91  /* Bottom left */
92  1.0, 0.0, 0.0, /* red */
93  0.0, 0.0, 1.0, /* blue */
94  0.0, 1.0, 0.0, /* green */
95  /* Top right */
96  1.0, 0.0, 0.0, /* red */
97  1.0, 1.0, 0.0, /* yellow */
98  0.0, 0.0, 1.0, /* blue */
99  /* Left face */
100  /* Bottom left */
101  1.0, 1.0, 1.0, /* white */
102  0.0, 1.0, 0.0, /* green */
103  0.0, 1.0, 1.0, /* cyan */
104  /* Top right */
105  1.0, 1.0, 1.0, /* white */
106  1.0, 0.0, 0.0, /* red */
107  0.0, 1.0, 0.0, /* green */
108  /* Top face */
109  /* Bottom left */
110  1.0, 1.0, 1.0, /* white */
111  1.0, 1.0, 0.0, /* yellow */
112  1.0, 0.0, 0.0, /* red */
113  /* Top right */
114  1.0, 1.0, 1.0, /* white */
115  0.0, 0.0, 0.0, /* black */
116  1.0, 1.0, 0.0, /* yellow */
117  /* Right face */
118  /* Bottom left */
119  1.0, 1.0, 0.0, /* yellow */
120  1.0, 0.0, 1.0, /* magenta */
121  0.0, 0.0, 1.0, /* blue */
122  /* Top right */
123  1.0, 1.0, 0.0, /* yellow */
124  0.0, 0.0, 0.0, /* black */
125  1.0, 0.0, 1.0, /* magenta */
126  /* Back face */
127  /* Bottom left */
128  0.0, 0.0, 0.0, /* black */
129  0.0, 1.0, 1.0, /* cyan */
130  1.0, 0.0, 1.0, /* magenta */
131  /* Top right */
132  0.0, 0.0, 0.0, /* black */
133  1.0, 1.0, 1.0, /* white */
134  0.0, 1.0, 1.0, /* cyan */
135  /* Bottom face */
136  /* Bottom left */
137  0.0, 1.0, 0.0, /* green */
138  1.0, 0.0, 1.0, /* magenta */
139  0.0, 1.0, 1.0, /* cyan */
140  /* Top right */
141  0.0, 1.0, 0.0, /* green */
142  0.0, 0.0, 1.0, /* blue */
143  1.0, 0.0, 1.0, /* magenta */
144 };
145 
146 #endif /* CUBE_H */
const float vertices[]
Definition: Cube.h:30
const float colors[]
Definition: Cube.h:88