annotate src/paranormal-ng/general.c @ 3203:f5456241bff9 default tip

changed include path from audacious to audlegacy.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 10 Nov 2009 05:19:25 +0900
parents f1b6f1b2cdb3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * paranormal: iterated pipeline-driven visualization plugin
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 * the Free Software Foundation; under version 2 of the License.
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * GNU General Public License for more details.
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 *
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2081
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 /* FIXME: what to name this file? */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 #include <config.h>
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 #include "paranormal.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 #include "actuators.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 #include "pn_utils.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27 #include "libcalc/calc.h"
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 /* **************** general_fade **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 static struct pn_actuator_option_desc general_fade_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32 { "amount", "The amount by which the color index of each "
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 "pixel should be decreased by each frame (MAX 255)",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34 OPT_TYPE_INT, { ival: 3 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 general_fade_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 int amt = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 3 : opts[0].val.ival;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 int i, j;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 for (j=0; j<pn_image_data->height; j++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 for (i=0; i<pn_image_data->width; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 CAPLO (pn_image_data->surface[0][PN_IMG_INDEX (i, j)]
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 - amt, 0);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 struct pn_actuator_desc builtin_general_fade =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54 "general_fade", "Fade-out", "Decreases the color index of each pixel",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 0, general_fade_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56 NULL, NULL, general_fade_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
59 /* thanks to feelgood_ICBM @ freenode for this */
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
60 #define glError() { GLenum err; for(err = glGetError(); err; err = glGetError()) { fprintf(stderr, "glError: %s caught at %s:%u\n", \
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
61 (GLchar*)gluErrorString(err), __FILE__, __LINE__); } }
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
62
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 /* **************** general_blur **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 general_blur_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 {
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
68 GLuint texture_id;
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
69
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
70 glGenTextures(1, &texture_id);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
71 glBindTexture(GL_TEXTURE_2D, texture_id);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
72
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
73 glError();
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
74
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
75 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_BYTE, NULL);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
76
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
77 glError();
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
79 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, -1, -1, 1, 1, 0);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
80
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
81 glError();
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
82
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
83 glBindTexture(GL_TEXTURE_2D, 0);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
84
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
85 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
86
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
87 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
88 glBindTexture(GL_TEXTURE_2D, texture_id);
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
90 glError();
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
91
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
92 glBegin(GL_QUADS);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
93
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
94 glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
95 glTexCoord2f(0, 1);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
96 glVertex2i(-1, -1);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
97 glVertex2i(-1, 1);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
98 glVertex2i(1, 1);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
99 glVertex2i(1, -1);
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
101 glEnd();
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
102 glBindTexture(GL_TEXTURE_2D, 0);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
103
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
104 glError();
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
106 glDeleteTextures(1, &texture_id);
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
107
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
108 glFlush();
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
109
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
110 glError();
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 struct pn_actuator_desc builtin_general_blur =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 {
2081
William Pitcock <nenolod@atheme.org>
parents: 2079
diff changeset
115 "general_blur", "Blur", "A simple radial blur",
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 NULL, NULL, general_blur_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 /* **************** general_mosaic **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 /* FIXME: add a variable radius */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 /* FIXME: SPEEEED */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 static struct pn_actuator_option_desc general_mosaic_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 { "radius", "The pixel radius that should be used for the effect.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 OPT_TYPE_INT, { ival: 6 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 general_mosaic_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134 int i,j;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 register guchar *srcptr = pn_image_data->surface[0];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 register guchar *destptr = pn_image_data->surface[1];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 register int sum;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 int radius = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 6 : opts[0].val.ival;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140 for (j=0; j<pn_image_data->height; j += radius)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141 for (i=0; i<pn_image_data->width; i += radius)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 int ii = 0, jj = 0;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 guchar bval = 0;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 /* find the brightest colour */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 guchar val = srcptr[PN_IMG_INDEX(i + ii, j + jj)];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 if (val > bval)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 bval = val;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 for (jj = 0; jj < radius && (j + jj < pn_image_data->height); jj++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157 for (ii = 0; ii < radius && (i + ii < pn_image_data->width); ii++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 destptr[PN_IMG_INDEX(i + ii, j + jj)] = bval;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 pn_swap_surfaces ();
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 struct pn_actuator_desc builtin_general_mosaic =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 "general_mosaic", "Mosaic", "A simple mosaic effect.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 0, general_mosaic_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 NULL, NULL, general_mosaic_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 /* **************** general_clear **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 general_clear_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181 struct pn_actuator_desc builtin_general_clear =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183 "general_clear", "Clear Surface", "Clears the surface.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 NULL, NULL, general_clear_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187
2079
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
188 /* **************** general_setalpha **************** */
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
189 static struct pn_actuator_option_desc general_setalpha_opts[] =
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
190 {
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
191 { "blend_colour", "The colour which should be used for blending.",
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
192 OPT_TYPE_COLOR, { cval: {255, 255, 255} } },
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
193 { "alpha", "The alpha value.",
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
194 OPT_TYPE_COLOR_INDEX, { ival: 128 } },
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
195 { NULL }
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
196 };
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
197
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
198 static void
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
199 general_setalpha_exec (const struct pn_actuator_option *opts,
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
200 gpointer data)
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
201 {
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
202 GLubyte colour[] = { opts[0].val.cval.r, opts[0].val.cval.g, opts[0].val.cval.b,
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
203 opts[1].val.ival };
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
204
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
205 glColor4ubv(colour);
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
206 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
207 }
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
208
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
209 struct pn_actuator_desc builtin_general_setalpha =
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
210 {
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
211 "general_setalpha", "Change Blend Setting", "Changes the blending setting (alpha transparency mask).",
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
212 0, general_setalpha_opts,
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
213 NULL, NULL, general_setalpha_exec
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
214 };
551862ab5d86 add alpha blending shit
William Pitcock <nenolod@atheme.org>
parents: 2078
diff changeset
215
2078
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 /* **************** general_noop **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 general_noop_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 return;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224 struct pn_actuator_desc builtin_general_noop =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226 "general_noop", "Do Nothing", "Does absolutely nothing.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 NULL, NULL, general_noop_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 /* **************** general_invert **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 general_invert_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
236 int i, j;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 for (j=0; j < pn_image_data->height; j++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239 for (i=0; i < pn_image_data->width; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 255 - pn_image_data->surface[0][PN_IMG_INDEX (i, j)];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 struct pn_actuator_desc builtin_general_invert =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246 "general_invert", "Value Invert", "Performs a value invert.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248 NULL, NULL, general_invert_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251 /* **************** general_replace **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252 static struct pn_actuator_option_desc general_replace_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254 { "start", "The beginning colour value that should be replaced by the value of out.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255 OPT_TYPE_INT, { ival: 250 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 { "end", "The ending colour value that should be replaced by the value of out.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257 OPT_TYPE_INT, { ival: 255 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
258 { "out", "The colour value that in is replaced with.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
259 OPT_TYPE_INT, { ival: 0 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
261 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
262
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
263 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
264 general_replace_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
265 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
266 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
267 register int i, j;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
268 register guchar val;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
269 guchar begin = opts[0].val.ival > 255 || opts[0].val.ival < 0 ? 250 : opts[0].val.ival;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
270 guchar end = opts[1].val.ival > 255 || opts[1].val.ival < 0 ? 255 : opts[1].val.ival;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
271 guchar out = opts[2].val.ival > 255 || opts[2].val.ival < 0 ? 0 : opts[2].val.ival;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
272
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
273 for (j=0; j < pn_image_data->height; j++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
274 for (i=0; i < pn_image_data->width; i++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
275 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
276 val = pn_image_data->surface[0][PN_IMG_INDEX (i, j)];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
277 if (val >= begin && val <= end)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
278 pn_image_data->surface[0][PN_IMG_INDEX (i, j)] = out;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
279 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
280 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
281
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282 struct pn_actuator_desc builtin_general_replace =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
283 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
284 "general_replace", "Value Replace", "Performs a value replace on a range of values.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
285 0, general_replace_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286 NULL, NULL, general_replace_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
288
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
289 /* **************** general_swap **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
291 general_swap_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
292 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
293 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
294 pn_swap_surfaces ();
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
295 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
296
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 struct pn_actuator_desc builtin_general_swap =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299 "general_swap", "Swap Surface", "Swaps the surface.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
301 NULL, NULL, general_swap_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
302 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
304 /* **************** general_copy **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
305 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 general_copy_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
307 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
308 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309 memcpy(pn_image_data->surface[1], pn_image_data->surface[0],
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
310 (pn_image_data->width * pn_image_data->height));
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 struct pn_actuator_desc builtin_general_copy =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
314 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
315 "general_copy", "Copy Surface", "Copies the surface to the other surface.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
316 0, NULL,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 NULL, NULL, general_copy_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
318 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
319
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320 /* **************** general_flip **************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 static struct pn_actuator_option_desc general_flip_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
323 { "direction", "Negative is horizontal, positive is vertical.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
324 OPT_TYPE_INT, { ival: -1 } },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
326 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
327
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
329 general_flip_exec (const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 gpointer data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
332 gint x, y;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334 if (opts[0].val.ival < 0)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
335 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
336 for (y = 0; y < pn_image_data->height; y++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
337 for (x = 0; x < pn_image_data->width; x++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
338 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339 pn_image_data->surface[1][PN_IMG_INDEX(pn_image_data->width - x, y)] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
340 pn_image_data->surface[0][PN_IMG_INDEX(x, y)];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343 else
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
345 for (y = 0; y < pn_image_data->height; y++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
346 for (x = 0; x < pn_image_data->width; x++)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
347 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
348 pn_image_data->surface[1][PN_IMG_INDEX(x, pn_image_data->height - y)] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
349 pn_image_data->surface[0][PN_IMG_INDEX(x, y)];
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
350 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
351 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
352
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
353 pn_swap_surfaces ();
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
354 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
355
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
356 struct pn_actuator_desc builtin_general_flip =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
357 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
358 "general_flip", "Flip Surface", "Flips the surface.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
359 0, general_flip_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
360 NULL, NULL, general_flip_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
361 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
362
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
363 /* ***************** general_evaluate ***************** */
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
364
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
365 static struct pn_actuator_option_desc general_evaluate_opts[] =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
366 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
367 { "init_script", "Script to run on start.", OPT_TYPE_STRING, {sval: "global_reg0 = 27;"} },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
368 { "frame_script", "Script to run.", OPT_TYPE_STRING, {sval: "global_reg0 = global_reg0 + 1;"} },
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
369 { NULL }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
370 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
371
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
372 struct pn_evaluate_ctx
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
373 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
374 expression_t *expr_on_init, *expr_on_frame;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
375 symbol_dict_t *dict;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
376 gboolean reset;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
377 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
378
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
379 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
380 general_evaluate_init(gpointer *data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
381 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
382 *data = g_new0(struct pn_evaluate_ctx, 1);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
383
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
384 ((struct pn_evaluate_ctx *)*data)->reset = TRUE;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
385 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
386
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
387 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
388 general_evaluate_cleanup(gpointer op_data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
389 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
390 struct pn_evaluate_ctx *data = (struct pn_evaluate_ctx *) op_data;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
391
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
392 g_return_if_fail(data != NULL);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
393
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
394 if (data->expr_on_init)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
395 expr_free(data->expr_on_init);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
396
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
397 if (data->expr_on_frame)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
398 expr_free(data->expr_on_frame);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
399
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
400 if (data->dict)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
401 dict_free(data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
402
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
403 if (data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
404 g_free(data);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
405 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
406
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
407 static void
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
408 general_evaluate_exec(const struct pn_actuator_option *opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
409 gpointer op_data)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
410 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
411 struct pn_evaluate_ctx *data = (struct pn_evaluate_ctx *) op_data;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
412
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
413 if (data->reset)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
414 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
415 if (data->dict)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
416 dict_free(data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
417
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
418 data->dict = dict_new();
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
419
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
420 if (opts[0].val.sval != NULL);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
421 data->expr_on_init = expr_compile_string(opts[0].val.sval, data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
422
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
423 if (opts[1].val.sval != NULL);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
424 data->expr_on_frame = expr_compile_string(opts[1].val.sval, data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
425
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
426 if (data->expr_on_init != NULL)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
427 expr_execute(data->expr_on_init, data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
428
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
429 data->reset = FALSE;
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
430 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
431
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
432 if (data->expr_on_frame != NULL)
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
433 expr_execute(data->expr_on_frame, data->dict);
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
434 }
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
435
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
436 struct pn_actuator_desc builtin_general_evaluate =
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
437 {
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
438 "general_evaluate", "Evalulate VM Code",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
439 "Evaluates arbitrary VM code. Does not draw anything.",
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
440 0, general_evaluate_opts,
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
441 general_evaluate_init, general_evaluate_cleanup, general_evaluate_exec
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
442 };
1fa3c8cd366a paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
443