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 <math.h>
|
|
21 #include <GL/gl.h>
|
|
22 #include <audacious/configdb.h>
|
|
23 #include "iris.h"
|
|
24
|
|
25
|
|
26 static struct
|
|
27 {
|
|
28 }
|
|
29 conf_private, conf_private_new;
|
|
30
|
|
31 static config_theme conf = {
|
|
32 NULL,
|
|
33 &conf_private
|
|
34 };
|
|
35
|
|
36 static config_theme conf_new = {
|
|
37 NULL,
|
|
38 &conf_private_new
|
|
39 };
|
|
40
|
|
41
|
|
42 static GLfloat get_x_angle (void);
|
|
43 static void draw_one_frame (gboolean);
|
|
44
|
|
45
|
|
46 iris_theme theme_pyramid = {
|
|
47 "Pyramid",
|
|
48 "Pyramid shaped spectrum",
|
|
49 "Marinus Schraal (foser@sesmar.eu.org)",
|
|
50 "pyramid",
|
|
51 &conf,
|
|
52 &conf_new,
|
|
53 sizeof (conf_private),
|
|
54 NULL,
|
|
55 NULL,
|
|
56 NULL,
|
|
57 NULL,
|
|
58 NULL,
|
|
59 NULL,
|
|
60 NULL,
|
|
61 get_x_angle,
|
|
62 draw_one_frame,
|
|
63 };
|
|
64
|
|
65
|
|
66 static GLfloat
|
|
67 get_x_angle ()
|
|
68 {
|
|
69 return (10.0 + (int) (30.0 * rand () / (RAND_MAX + 1.0)));
|
|
70 }
|
|
71
|
|
72
|
|
73 static void
|
|
74 draw_one_frame (gboolean beat)
|
|
75 {
|
|
76 GLfloat scale = 2.0; // scales the whole squares, higher is bigger
|
|
77 GLfloat x, height = -4, oldheight;
|
|
78 GLfloat red, green, blue;
|
|
79 static GLfloat data[16]; // where the spectrum values are stored
|
|
80 int l;
|
|
81
|
|
82 for (l = 0; l < 16; l++)
|
|
83 {
|
|
84 if (datas.data1[l] > data[l])
|
|
85 data[l] = datas.data1[l];
|
|
86 else
|
|
87 data[l] -= 0.015;
|
|
88 if (data[l] < 0.0)
|
|
89 data[l] = 0.0;
|
|
90 }
|
|
91
|
|
92 glBegin (GL_QUADS);
|
|
93 for (l = 0; l < 16; l++)
|
|
94 {
|
|
95 x = data[l] * scale;
|
|
96 oldheight = height;
|
|
97 height = height + 0.4;
|
|
98
|
|
99 if (data[l] > 0.0)
|
|
100 {
|
|
101 get_color (&red, &green, &blue, &data[l]);
|
|
102 glColor4f (red, green, blue, 0.75);
|
|
103
|
|
104 /* sides */
|
|
105 //top right
|
|
106 glVertex3f (x, height, x); // top right (front)
|
|
107 glVertex3f (x, oldheight, x); //bottom right
|
|
108 glVertex3f (x, oldheight, -x); //bottom left
|
|
109 glVertex3f (x, height, -x); // top left
|
|
110 //top left
|
|
111 glVertex3f (x, height, -x); // top right (front)
|
|
112 glVertex3f (x, oldheight, -x); //bottom right
|
|
113 glVertex3f (-x, oldheight, -x); //bottom left
|
|
114 glVertex3f (-x, height, -x); // top left
|
|
115 //bottom left
|
|
116 glVertex3f (-x, height, -x); // top right (front)
|
|
117 glVertex3f (-x, oldheight, -x); //bottom right
|
|
118 glVertex3f (-x, oldheight, x); //bottom left
|
|
119 glVertex3f (-x, height, x); // top left
|
|
120
|
|
121 //bottom right
|
|
122 glVertex3f (-x, height, x); // top right (front)
|
|
123 glVertex3f (-x, oldheight, x); //bottom right
|
|
124 glVertex3f (x, oldheight, x); //bottom left
|
|
125 glVertex3f (x, height, x); // top left
|
|
126
|
|
127 get_color (&red, &green, &blue, &data[l]);
|
|
128 glColor4f (red, green, blue, 0.5);
|
|
129 /* top */
|
|
130 glVertex3f (x, height, x); // Top Right Of The Quad (Bottom)
|
|
131 glVertex3f (x, height, -x); // Top Left Of The Quad (Bottom)
|
|
132 glVertex3f (-x, height, -x); // Bottom Left Of The Quad (Bottom)
|
|
133 glVertex3f (-x, height, x); // Bottom Right Of The Quad (Bottom)
|
|
134
|
|
135 }
|
|
136 }
|
|
137
|
|
138 glEnd ();
|
|
139
|
|
140 }
|