Mercurial > audlegacy-plugins
annotate src/rovascope/paranormal.c @ 1263:458d46e65a86
wav-sndfile: in is_our_file, ensure that filename is not NULL before passing it to sf_open
author | Giacomo Lozito <james@develia.org> |
---|---|
date | Fri, 13 Jul 2007 20:55:42 +0200 |
parents | f305ebcc8136 |
children |
rev | line source |
---|---|
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
1 /* FIXME: add fullscreen / screenshots */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
2 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
3 #ifdef HAVE_CONFIG_H |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
4 # include <config.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
5 #endif |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
6 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
7 #include <sys/types.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
8 #include <sys/stat.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
9 #include <unistd.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
10 #include <math.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
11 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
12 #include <SDL.h> |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
13 |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
14 #include <gtk/gtk.h> |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
15 #include <gdk/gdk.h> |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
16 #include <gdk/gdkx.h> |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
17 |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
18 #include "paranormal.h" |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
19 #include "actuators.h" |
1059 | 20 #include "containers.h" |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
21 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
22 /* SDL stuffs */ |
192 | 23 SDL_Surface *screen; |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
24 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
25 /* Globals */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
26 struct pn_rc *pn_rc; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
27 struct pn_image_data *pn_image_data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
28 struct pn_sound_data *pn_sound_data; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
29 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
30 /* Trig Pre-Computes */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
31 float sin_val[360]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
32 float cos_val[360]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
33 |
302 | 34 gboolean pn_new_beat; |
35 | |
408
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
36 extern SDL_mutex *config_mutex; |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
37 |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
38 /* **************** drawing doodads **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
39 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
40 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
41 blit_to_screen (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
42 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
43 int j; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
44 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
45 SDL_LockSurface (screen); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
46 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
47 /* FIXME: add scaling support */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
48 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
49 SDL_SetPalette (screen, SDL_LOGPAL|SDL_PHYSPAL, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
50 (SDL_Color*)pn_image_data->cmap, 0, 256); |
266 | 51 SDL_SetAlpha (screen, 0, 255); |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
52 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
53 for (j=0; j<pn_image_data->height; j++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
54 memcpy (screen->pixels + j*screen->pitch, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
55 pn_image_data->surface[0] + j*pn_image_data->width, |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
56 pn_image_data->width); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
57 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
58 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
59 SDL_UnlockSurface (screen); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
60 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
61 SDL_UpdateRect (screen, 0, 0, 0, 0); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
62 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
63 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
64 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
65 resize_video (guint w, guint h) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
66 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
67 pn_image_data->width = w; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
68 pn_image_data->height = h; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
69 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
70 if (pn_image_data->surface[0]) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
71 g_free (pn_image_data->surface[0]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
72 if (pn_image_data->surface[1]) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
73 g_free (pn_image_data->surface[1]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
74 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
75 pn_image_data->surface[0] = g_malloc0 (w * h); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
76 pn_image_data->surface[1] = g_malloc0 (w * h); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
77 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
78 screen = SDL_SetVideoMode (w, h, 8, SDL_HWSURFACE | |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
79 SDL_HWPALETTE | SDL_RESIZABLE); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
80 if (! screen) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
81 pn_fatal_error ("Unable to create a new SDL window: %s", |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
82 SDL_GetError ()); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
83 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
84 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
85 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
86 take_screenshot (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
87 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
88 char fname[32]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
89 struct stat buf; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
90 int i=0; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
91 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
92 do |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
93 sprintf (fname, "pn_%05d.bmp", ++i); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
94 while (stat (fname, &buf) == 0); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
95 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
96 SDL_SaveBMP (screen, fname); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
97 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
98 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
99 /* FIXME: This should resize the video to a user-set |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
100 fullscreen res */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
101 static void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
102 toggle_fullscreen (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
103 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
104 SDL_WM_ToggleFullScreen (screen); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
105 if (SDL_ShowCursor (SDL_QUERY) == SDL_ENABLE) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
106 SDL_ShowCursor (SDL_DISABLE); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
107 else |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
108 SDL_ShowCursor (SDL_ENABLE); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
109 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
110 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
111 /* **************** basic renderer management **************** */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
112 void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
113 pn_init (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
114 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
115 int i; |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
116 #ifdef FULLSCREEN_HACK |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
117 char SDL_windowhack[32]; |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
118 GdkScreen *screen; |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
119 #endif |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
120 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
121 pn_sound_data = g_new0 (struct pn_sound_data, 1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
122 pn_image_data = g_new0 (struct pn_image_data, 1); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
123 |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
124 #ifdef FULLSCREEN_HACK |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
125 screen = gdk_screen_get_default(); |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
126 sprintf(SDL_windowhack,"SDL_WINDOWID=%d", |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
127 GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(screen))); |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
128 putenv(SDL_windowhack); |
191 | 129 #endif |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
130 |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
131 if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) < 0) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
132 pn_fatal_error ("Unable to initialize SDL: %s", SDL_GetError ()); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
133 |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
134 #ifndef FULLSCREEN_HACK |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
135 resize_video (640, 360); |
190
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
136 #else |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
137 resize_video (1280, 1024); |
31f238746877
[svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents:
151
diff
changeset
|
138 #endif |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
139 |
408
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
140 SDL_WM_SetCaption ("Rovascope " VERSION, PACKAGE); |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
141 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
142 for(i=0; i<360; i++) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
143 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
144 sin_val[i] = sin(i*(M_PI/180.0)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
145 cos_val[i] = cos(i*(M_PI/180.0)); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
146 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
147 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
148 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
149 void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
150 pn_cleanup (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
151 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
152 SDL_FreeSurface (screen); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
153 SDL_Quit (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
154 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
155 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
156 if (pn_image_data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
157 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
158 if (pn_image_data->surface[0]) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
159 g_free (pn_image_data->surface[0]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
160 if (pn_image_data->surface[1]) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
161 g_free (pn_image_data->surface[1]); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
162 g_free (pn_image_data); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
163 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
164 if (pn_sound_data) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
165 g_free (pn_sound_data); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
166 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
167 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
168 /* Renders one frame and handles the SDL window */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
169 void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
170 pn_render (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
171 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
172 SDL_Event event; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
173 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
174 /* Handle window events */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
175 while (SDL_PollEvent (&event)) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
176 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
177 switch (event.type) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
178 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
179 case SDL_QUIT: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
180 pn_quit (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
181 g_assert_not_reached (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
182 case SDL_KEYDOWN: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
183 switch (event.key.keysym.sym) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
184 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
185 case SDLK_ESCAPE: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
186 pn_quit (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
187 g_assert_not_reached (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
188 case SDLK_RETURN: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
189 if (event.key.keysym.mod & (KMOD_ALT | KMOD_META)) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
190 toggle_fullscreen (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
191 break; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
192 case SDLK_BACKQUOTE: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
193 take_screenshot (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
194 break; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
195 default: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
196 break; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
197 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
198 break; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
199 case SDL_VIDEORESIZE: |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
200 resize_video (event.resize.w, event.resize.h); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
201 break; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
202 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
203 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
204 |
302 | 205 pn_new_beat = pn_is_new_beat(); |
206 | |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
207 if (pn_rc->actuator) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
208 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
209 exec_actuator (pn_rc->actuator); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
210 blit_to_screen (); |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
211 } |
408
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
212 |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
213 if (pn_new_beat && (rand() % 4 == 0)) |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
214 { |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
215 struct pn_actuator *a; |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
216 GSList *list = *(GSList **)pn_rc->actuator->data; |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
217 |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
218 container_remove_actuator (pn_rc->actuator, list->data); |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
219 |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
220 SDL_mutexP(config_mutex); |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
221 a = rovascope_get_random_actuator(); |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
222 container_add_actuator (pn_rc->actuator, a); |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
223 SDL_mutexV(config_mutex); |
290588854a9d
[svn] - rovascope -- a variant of the paranormal visualization engine that is
nenolod
parents:
302
diff
changeset
|
224 } |
149
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
225 } |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
226 |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
227 /* this MUST be called if a builtin's output is to surface[1] |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
228 (by the builtin, after it is done) */ |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
229 void |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
230 pn_swap_surfaces (void) |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
231 { |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
232 guchar *tmp = pn_image_data->surface[0]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
233 pn_image_data->surface[0] = pn_image_data->surface[1]; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
234 pn_image_data->surface[1] = tmp; |
fd9c0a5871ac
[svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff
changeset
|
235 } |