2
* Copyright 1994-2012 Olivier Girondel
4
* This file is part of lebiniou.
6
* lebiniou is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 2 of the License, or
9
* (at your option) any later version.
11
* lebiniou is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
23
u_long id = 1328382269;
25
u_long options = BE_GFX;
26
u_long mode = OVERLAY;
28
char dname[] = "GLCube";
29
char desc[] = "OpenGL cube";
31
static u_char faces[6];
36
#define NORMAL(X) do { \
37
glEnable(GL_COLOR_LOGIC_OP); \
41
glDisable(GL_COLOR_LOGIC_OP); \
44
#define INVERT(X) do { \
45
glEnable(GL_COLOR_LOGIC_OP); \
46
glLogicOp(GL_COPY_INVERTED); \
49
glDisable(GL_COLOR_LOGIC_OP); \
54
/* many things shamefully backported from the EC_cube project */
58
static float CUBE[8][3] =
59
{{ ONE, ONE, -ONE}, // 1
60
{ ONE, -ONE, -ONE}, // 2
62
{-ONE, ONE, -ONE}, // 4
64
{ ONE, ONE, ONE}, // 6
68
#define CE(x) glVertex3fv(CUBE[x-1])
70
#define coucou(X) face(ctx, X)
74
create(__attribute__ ((unused)) Context_t *ctx)
77
const float ar = WIDTH / (float)HEIGHT;
80
for (e = 0; e < 8; e++)
81
for (v = 0; v < 3; v++)
85
CUBE[e][v] *= 1.15; /* FIXME empirical tuning */
90
destroy(__attribute__ ((unused)) Context_t *ctx)
98
glDisable(GL_TEXTURE_2D);
102
CE(1); CE(2); CE(2); CE(3); CE(3); CE(4);
103
CE(4); CE(5); CE(5); CE(8); CE(8); CE(3);
104
CE(1); CE(6); CE(6); CE(7); CE(7); CE(2);
105
CE(6); CE(5); CE(5); CE(8); CE(8); CE(7);
106
CE(6); CE(1); CE(1); CE(4); CE(4); CE(5);
107
CE(7); CE(2); CE(3); CE(8);
112
static inline void t1() {
113
glTexCoord2f(ZERO, ZERO);
115
static inline void t2() {
116
glTexCoord2f(ZERO, ONE);
118
static inline void t3() {
119
glTexCoord2f(ONE, ONE);
121
static inline void t4() {
122
glTexCoord2f(ONE, ZERO);
127
get_texture(Context_t *ctx, const u_char face, const u_char rgba)
130
Context_make_GL_RGBA_texture(ctx, face);
133
Context_make_GL_gray_texture(ctx, face);
135
Context_make_GL_RGBA_texture(ctx, face);
142
face(__attribute__ ((unused)) Context_t *ctx, const char f)
145
case 0: // front face
146
get_texture(ctx, ACTIVE_BUFFER, 1);
155
get_texture(ctx, ACTIVE_BUFFER, 1);
165
get_texture(ctx, (webcams >= 2) ? 1 : 0, 0);
167
get_texture(ctx, 0, 0);
176
case 3: // right face
177
get_texture(ctx, 0, 0);
209
case 5: // bottom face
221
textures(Context_t *ctx)
225
for (ibou = 0; ibou < 6; ibou++)
226
coucou(ibou); /* :) again */
233
memset(&faces, 0, 6*sizeof(u_char));