|
116
|
1 /* Iris - visualization plugin for XMMS
|
|
|
2 * Copyright (C) 2000-2002 Cédric DELFOSSE (cdelfosse@free.fr)
|
|
|
3 *
|
|
|
4 * This program is free software; you can redistribute it and/or modify
|
|
|
5 * it under the terms of the GNU General Public License as published by
|
|
|
6 * the Free Software Foundation; either version 2 of the License, or
|
|
|
7 * (at your option) any later version.
|
|
|
8 *
|
|
|
9 * This program is distributed in the hope that it will be useful,
|
|
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 * GNU General Public License for more details.
|
|
|
13 *
|
|
|
14 * You should have received a copy of the GNU General Public License
|
|
|
15 * along with this program; if not, write to the Free Software
|
|
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
17 */
|
|
|
18
|
|
|
19 #include <stdlib.h>
|
|
|
20 #include <string.h>
|
|
|
21 #include <math.h>
|
|
|
22 #include <GL/gl.h>
|
|
|
23 #include <audacious/configdb.h>
|
|
|
24 #include "iris.h"
|
|
|
25
|
|
|
26
|
|
|
27 static struct
|
|
|
28 {
|
|
|
29 }
|
|
|
30 conf_private, conf_private_new;
|
|
|
31
|
|
|
32 static config_theme conf = {
|
|
|
33 NULL,
|
|
|
34 &conf_private
|
|
|
35 };
|
|
|
36
|
|
|
37 static config_theme conf_new = {
|
|
|
38 NULL,
|
|
|
39 &conf_private_new
|
|
|
40 };
|
|
|
41
|
|
|
42
|
|
|
43 static GLfloat get_x_angle (void);
|
|
|
44 static void draw_one_frame (gboolean);
|
|
|
45
|
|
|
46
|
|
|
47 iris_theme theme_squarefield = {
|
|
|
48 "SquareField",
|
|
|
49 "Waving square field",
|
|
|
50 "Marinus Schraal (foser@sesmar.eu.org)",
|
|
|
51 "squarefield",
|
|
|
52 &conf,
|
|
|
53 &conf_new,
|
|
|
54 sizeof (conf_private),
|
|
|
55 NULL,
|
|
|
56 NULL,
|
|
|
57 NULL,
|
|
|
58 NULL,
|
|
|
59 NULL,
|
|
|
60 NULL,
|
|
|
61 NULL,
|
|
|
62 get_x_angle,
|
|
|
63 draw_one_frame,
|
|
|
64 };
|
|
|
65
|
|
|
66
|
|
|
67 GLfloat dataSquare[NUM_BANDS][NUM_BANDS]; // internal sounddata structure
|
|
|
68
|
|
|
69
|
|
|
70 static GLfloat
|
|
|
71 get_x_angle ()
|
|
|
72 {
|
|
|
73 return (10.0 + (int) (80.0 * rand () / (RAND_MAX + 1.0)));
|
|
|
74 }
|
|
|
75
|
|
|
76
|
|
|
77 static void
|
|
|
78 draw_one_frame (gboolean beat)
|
|
|
79 {
|
|
|
80 int t1, t2; // loop vars
|
|
|
81 GLfloat x1, y1;
|
|
|
82 GLfloat red, green, blue;
|
|
|
83 GLfloat z = 0.0;
|
|
|
84 GLfloat scale = 4.5; // scales the whole field - lower is bigger
|
|
|
85 GLfloat scaleh = 3; // scales height of the bar - lower is smaller
|
|
|
86 GLfloat maxfalloff = 0.05;
|
|
|
87
|
|
|
88 /* internal routine to shift all data when a new datarow arrives */
|
|
|
89 for (t1 = 15; t1 > 0; t1--)
|
|
|
90 {
|
|
|
91 for (t2 = 0; t2 < 16; t2++)
|
|
|
92 {
|
|
|
93 dataSquare[t1][t2] = dataSquare[t1 - 1][t2];
|
|
|
94 }
|
|
|
95 }
|
|
|
96 for (t2 = 0; t2 < 16; t2++)
|
|
|
97 {
|
|
|
98 if (dataSquare[0][t2] > datas.data1[t2]
|
|
|
99 && ((dataSquare[0][t2] - datas.data1[t2]) > maxfalloff))
|
|
|
100 {
|
|
|
101 dataSquare[0][t2] = dataSquare[0][t2] - maxfalloff;
|
|
|
102 }
|
|
|
103 else
|
|
|
104 {
|
|
|
105 dataSquare[0][t2] = datas.data1[t2];
|
|
|
106 }
|
|
|
107 }
|
|
|
108
|
|
|
109 /* some kinda random base i started out on
|
|
|
110 turned out to be too big thats why i added scaling vars
|
|
|
111 */
|
|
|
112 x1 = 11.75f;
|
|
|
113 y1 = 11.75f;
|
|
|
114
|
|
|
115 glBegin (GL_QUADS);
|
|
|
116
|
|
|
117 for (t1 = 0; t1 < 16; t1++)
|
|
|
118 {
|
|
|
119 x1 = 11.75f;
|
|
|
120 for (t2 = 0; t2 < 16; t2++)
|
|
|
121 {
|
|
|
122 /* bottom : turned off */
|
|
|
123
|
|
|
124 /* get_color (&red, &green, &blue, &z);
|
|
|
125 glColor4f (red/2 , green/2 , blue/2 , 0.5);
|
|
|
126 glVertex3f( (x1-1)/scale , 0, (y1-1)/scale); // Top Right Of The Quad (Bottom)
|
|
|
127 glVertex3f( x1/scale, 0, (y1-1)/scale); // Top Left Of The Quad (Bottom)
|
|
|
128 glVertex3f( x1/scale, 0, y1/scale); // Bottom Left Of The Quad (Bottom)
|
|
|
129 glVertex3f( (x1-1)/scale, 0, y1/scale); // Bottom Right Of The Quad (Bottom)
|
|
|
130 */
|
|
|
131
|
|
|
132 /* sides */
|
|
|
133 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
134 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
135 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // top right (front)
|
|
|
136 get_color (&red, &green, &blue, &z);
|
|
|
137 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
138 glVertex3f ((x1 - 1) / scale, 0, (y1 - 1) / scale); //bottom right
|
|
|
139 glVertex3f (x1 / scale, 0, (y1 - 1) / scale); //bottom left
|
|
|
140 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
141 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
142 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // top left
|
|
|
143
|
|
|
144 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
145 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
146 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // top fron (left)
|
|
|
147 get_color (&red, &green, &blue, &z);
|
|
|
148 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
149 glVertex3f (x1 / scale, 0, (y1 - 1) / scale); // bottom fron (left)
|
|
|
150 glVertex3f (x1 / scale, 0, y1 / scale); // back bottom (left)
|
|
|
151 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
152 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
153 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // top back (left)
|
|
|
154
|
|
|
155 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
156 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
157 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // top front (right)
|
|
|
158 get_color (&red, &green, &blue, &z);
|
|
|
159 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
160 glVertex3f ((x1 - 1) / scale, 0, (y1 - 1) / scale); // bottom front (right)
|
|
|
161 glVertex3f ((x1 - 1) / scale, 0, y1 / scale); // bottom back (right)
|
|
|
162 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
163 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
164 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // top back(right)
|
|
|
165
|
|
|
166 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
167 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
168 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // right top (back)
|
|
|
169 get_color (&red, &green, &blue, &z);
|
|
|
170 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
171 glVertex3f ((x1 - 1) / scale, 0, y1 / scale); // right bottom (back)
|
|
|
172 glVertex3f (x1 / scale, 0, y1 / scale); // left bottom (back)
|
|
|
173 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
174 glColor4f (red / 2, green / 2, blue / 2, 0.5);
|
|
|
175 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // left top (back)
|
|
|
176
|
|
|
177 /* top */
|
|
|
178 get_color (&red, &green, &blue, &dataSquare[t1][t2]);
|
|
|
179 glColor4f (red, green, blue, 0.5);
|
|
|
180 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // Top Right Of The Quad (Bottom)
|
|
|
181 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, (y1 - 1) / scale); // Top Left Of The Quad (Bottom)
|
|
|
182 glVertex3f (x1 / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // Bottom Left Of The Quad (Bottom)
|
|
|
183 glVertex3f ((x1 - 1) / scale, dataSquare[t1][t2] * scaleh, y1 / scale); // Bottom Right Of The Quad (Bottom)
|
|
|
184
|
|
|
185 x1 -= 1.5;
|
|
|
186 }
|
|
|
187 y1 -= 1.5;
|
|
|
188 }
|
|
|
189
|
|
|
190 glEnd ();
|
|
|
191
|
|
|
192 }
|