/usr/share/doc/libgtkglext1-dev/examples/logo-model.c is in libgtkglext1-dev 1.2.0-3.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | /*
* logo-model.c:
* Functions for drawing GtkGLExt logo models.
*
* written by Naofumi Yasufuku <naofumi@users.sourceforge.net>
*/
#include <math.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#include <GL/gl.h>
#include "logo-model.h"
void
logo_draw_cube (void)
{
static GLfloat n[6][3] = {
{ -1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 1.0, 0.0, 0.0 },
{ 0.0, -1.0, 0.0 },
{ 0.0, 0.0, 1.0 },
{ 0.0, 0.0, -1.0 }
};
static GLint faces[6][4] = {
{ 0, 1, 2, 3 },
{ 3, 2, 6, 7 },
{ 7, 6, 5, 4 },
{ 4, 5, 1, 0 },
{ 5, 6, 2, 1 },
{ 7, 4, 0, 3 }
};
static GLfloat v[8][3] = {
{ -5.5, -5.5, -5.5 },
{ -5.5, -5.5, 5.5 },
{ -5.5, 5.5, 5.5 },
{ -5.5, 5.5, -5.5 },
{ 5.5, -5.5, -5.5 },
{ 5.5, -5.5, 5.5 },
{ 5.5, 5.5, 5.5 },
{ 5.5, 5.5, -5.5 }
};
GLint i;
for (i = 5; i >= 0; i--)
{
glBegin(GL_QUADS);
glNormal3fv(&n[i][0]);
glVertex3fv(&v[faces[i][0]][0]);
glVertex3fv(&v[faces[i][1]][0]);
glVertex3fv(&v[faces[i][2]][0]);
glVertex3fv(&v[faces[i][3]][0]);
glEnd();
}
}
void
logo_draw_g_plane (void)
{
static GLfloat n[3] = {
0.0, 1.0, 0.0
};
static GLfloat v[4][3] = {
{ -5.0, 6.5, -5.0 },
{ -5.0, 6.5, 5.0 },
{ 5.0, 6.5, 5.0 },
{ 5.0, 6.5, -5.0 }
};
glBegin(GL_QUADS);
glNormal3f(n[0], n[1], n[2]);
glVertex3f(v[0][0], v[0][1], v[0][2]);
glVertex3f(v[1][0], v[1][1], v[1][2]);
glVertex3f(v[2][0], v[2][1], v[2][2]);
glVertex3f(v[3][0], v[3][1], v[3][2]);
glEnd();
}
void
logo_draw_t_plane (void)
{
static GLfloat n[3] = {
0.0, 0.0, 1.0
};
static GLfloat v[4][3] = {
{ -5.0, 5.0, 6.5 },
{ -5.0, -5.0, 6.5 },
{ 5.0, -5.0, 6.5 },
{ 5.0, 5.0, 6.5 }
};
glBegin(GL_QUADS);
glNormal3f(n[0], n[1], n[2]);
glVertex3f(v[0][0], v[0][1], v[0][2]);
glVertex3f(v[1][0], v[1][1], v[1][2]);
glVertex3f(v[2][0], v[2][1], v[2][2]);
glVertex3f(v[3][0], v[3][1], v[3][2]);
glEnd();
}
void
logo_draw_k_plane ()
{
static GLfloat n[3] = {
1.0, 0.0, 0.0
};
static GLfloat v[4][3] = {
{ 6.5, 5.0, 5.0 },
{ 6.5, -5.0, 5.0 },
{ 6.5, -5.0, -5.0 },
{ 6.5, 5.0, -5.0 }
};
glBegin(GL_QUADS);
glNormal3f(n[0], n[1], n[2]);
glVertex3f(v[0][0], v[0][1], v[0][2]);
glVertex3f(v[1][0], v[1][1], v[1][2]);
glVertex3f(v[2][0], v[2][1], v[2][2]);
glVertex3f(v[3][0], v[3][1], v[3][2]);
glEnd();
}
static void
logo_draw_triangle (GLfloat *v0,
GLfloat *v1,
GLfloat *v2)
{
GLfloat w0[3], w1[3];
GLfloat n[3], m;
w0[0] = v1[0] - v0[0];
w0[1] = v1[1] - v0[1];
w0[2] = v1[2] - v0[2];
w1[0] = v2[0] - v1[0];
w1[1] = v2[1] - v1[1];
w1[2] = v2[2] - v1[2];
n[0] = w0[1]*w1[2] - w0[2]*w1[1];
n[1] = w0[2]*w1[0] - w0[0]*w1[2];
n[2] = w0[0]*w1[1] - w0[1]*w1[0];
m = n[0]*n[0] + n[1]*n[1] + n[2]*n[2];
if (m > 0.0)
{
m = 1.0 / sqrt(m);
n[0] *= m;
n[1] *= m;
n[2] *= m;
}
glBegin(GL_TRIANGLES);
glNormal3fv(&n[0]);
glVertex3fv(&v0[0]);
glVertex3fv(&v1[0]);
glVertex3fv(&v2[0]);
glEnd();
}
/* AC3D triangle data */
#include "logo-g.c"
void
logo_draw_g (void)
{
GLint i;
for (i = 0; i < LOGO_G_V_SIZE; i++)
logo_draw_triangle(&logo_g_v[i][2][0],
&logo_g_v[i][1][0],
&logo_g_v[i][0][0]);
}
/* AC3D triangle data */
#include "logo-t.c"
void
logo_draw_t (void)
{
GLint i;
for (i = 0; i < LOGO_T_V_SIZE; i++)
logo_draw_triangle(&logo_t_v[i][2][0],
&logo_t_v[i][1][0],
&logo_t_v[i][0][0]);
}
/* AC3D triangle data */
#include "logo-k.c"
void
logo_draw_k (void)
{
GLint i;
for (i = 0; i < LOGO_K_V_SIZE; i++)
logo_draw_triangle(&logo_k_v[i][2][0],
&logo_k_v[i][1][0],
&logo_k_v[i][0][0]);
}
|