|
| 1 | +/* |
| 2 | +Copyright (c) 2012, Broadcom Europe Ltd |
| 3 | +All rights reserved. |
| 4 | +
|
| 5 | +Redistribution and use in source and binary forms, with or without |
| 6 | +modification, are permitted provided that the following conditions are met: |
| 7 | + * Redistributions of source code must retain the above copyright |
| 8 | + notice, this list of conditions and the following disclaimer. |
| 9 | + * Redistributions in binary form must reproduce the above copyright |
| 10 | + notice, this list of conditions and the following disclaimer in the |
| 11 | + documentation and/or other materials provided with the distribution. |
| 12 | + * Neither the name of the copyright holder nor the |
| 13 | + names of its contributors may be used to endorse or promote products |
| 14 | + derived from this software without specific prior written permission. |
| 15 | +
|
| 16 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | +*/ |
| 27 | + |
| 28 | +// Spatial coordinates for the cube |
| 29 | + |
| 30 | +static const GLbyte quadx[6*4*3] = { |
| 31 | + /* FRONT */ |
| 32 | + -10, -10, 10, |
| 33 | + 10, -10, 10, |
| 34 | + -10, 10, 10, |
| 35 | + 10, 10, 10, |
| 36 | + |
| 37 | + /* BACK */ |
| 38 | + -10, -10, -10, |
| 39 | + -10, 10, -10, |
| 40 | + 10, -10, -10, |
| 41 | + 10, 10, -10, |
| 42 | + |
| 43 | + /* LEFT */ |
| 44 | + -10, -10, 10, |
| 45 | + -10, 10, 10, |
| 46 | + -10, -10, -10, |
| 47 | + -10, 10, -10, |
| 48 | + |
| 49 | + /* RIGHT */ |
| 50 | + 10, -10, -10, |
| 51 | + 10, 10, -10, |
| 52 | + 10, -10, 10, |
| 53 | + 10, 10, 10, |
| 54 | + |
| 55 | + /* TOP */ |
| 56 | + -10, 10, 10, |
| 57 | + 10, 10, 10, |
| 58 | + -10, 10, -10, |
| 59 | + 10, 10, -10, |
| 60 | + |
| 61 | + /* BOTTOM */ |
| 62 | + -10, -10, 10, |
| 63 | + -10, -10, -10, |
| 64 | + 10, -10, 10, |
| 65 | + 10, -10, -10, |
| 66 | +}; |
| 67 | + |
| 68 | +/** Texture coordinates for the quad. */ |
| 69 | +static const GLfloat texCoords[6 * 4 * 2] = { |
| 70 | + 0.f, 0.f, |
| 71 | + 0.f, 1.f, |
| 72 | + 1.f, 0.f, |
| 73 | + 1.f, 1.f, |
| 74 | + |
| 75 | + 0.f, 0.f, |
| 76 | + 0.f, 1.f, |
| 77 | + 1.f, 0.f, |
| 78 | + 1.f, 1.f, |
| 79 | + |
| 80 | + 0.f, 0.f, |
| 81 | + 0.f, 1.f, |
| 82 | + 1.f, 0.f, |
| 83 | + 1.f, 1.f, |
| 84 | + |
| 85 | + 0.f, 0.f, |
| 86 | + 0.f, 1.f, |
| 87 | + 1.f, 0.f, |
| 88 | + 1.f, 1.f, |
| 89 | + |
| 90 | + 0.f, 0.f, |
| 91 | + 0.f, 1.f, |
| 92 | + 1.f, 0.f, |
| 93 | + 1.f, 1.f, |
| 94 | + |
| 95 | + 0.f, 0.f, |
| 96 | + 0.f, 1.f, |
| 97 | + 1.f, 0.f, |
| 98 | + 1.f, 1.f |
| 99 | +}; |
| 100 | + |
| 101 | +// Colors are invisible when textures appear on all 6 faces. |
| 102 | +// If textures are disabled, e.g. by commenting out glEnable(GL_TEXTURE_2D), |
| 103 | +// the colours will appear. |
| 104 | + |
| 105 | +static const GLfloat colorsf[6*4*4] = { |
| 106 | + 1.f, 0.f, 0.f, 1.f, //red |
| 107 | + 1.f, 0.f, 0.f, 1.f, |
| 108 | + 1.f, 0.f, 0.f, 1.f, |
| 109 | + 1.f, 0.f, 0.f, 1.f, |
| 110 | + |
| 111 | + 0.f, 1.f, 0.f, 1.f, // blue |
| 112 | + 0.f, 1.f, 0.f, 1.f, |
| 113 | + 0.f, 1.f, 0.f, 1.f, |
| 114 | + 0.f, 1.f, 0.f, 1.f, |
| 115 | + |
| 116 | + 0.f, 0.f, 1.f, 1.f, // green |
| 117 | + 0.f, 0.f, 1.f, 1.f, |
| 118 | + 0.f, 0.f, 1.f, 1.f, |
| 119 | + 0.f, 0.f, 1.f, 1.f, |
| 120 | + |
| 121 | + 0.f, 0.5f, 0.5f, 1.f, // teal |
| 122 | + 0.f, 0.5f, 0.5f, 1.f, |
| 123 | + 0.f, 0.5f, 0.5f, 1.f, |
| 124 | + 0.f, 0.5f, 0.5f, 1.f, |
| 125 | + |
| 126 | + 0.5f, 0.5f, 0.f, 1.f, // yellow |
| 127 | + 0.5f, 0.5f, 0.f, 1.f, |
| 128 | + 0.5f, 0.5f, 0.f, 1.f, |
| 129 | + 0.5f, 0.5f, 0.f, 1.f, |
| 130 | + |
| 131 | + 0.5f, 0.f, 0.5f, 1.f, // purple |
| 132 | + 0.5f, 0.f, 0.5f, 1.f, |
| 133 | + 0.5f, 0.f, 0.5f, 1.f, |
| 134 | + 0.5f, 0.f, 0.5f, 1.f |
| 135 | +}; |
0 commit comments