annotate src/paranormal/paranormal.c @ 1833:15e7d3473974

paranormal: MK2
author William Pitcock <nenolod@atheme.org>
date Mon, 24 Sep 2007 13:57:28 -0500
parents 9d802f0a55af
children 3b034150d31e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1833
15e7d3473974 paranormal: MK2
William Pitcock <nenolod@atheme.org>
parents: 1253
diff changeset
3 #include <config.h>
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
4
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
5 #include <sys/types.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
6 #include <sys/stat.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
7 #include <unistd.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
8 #include <math.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
9
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
10 #include <SDL.h>
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
11
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
12 #include <gtk/gtk.h>
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
13 #include <gdk/gdk.h>
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
14
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
15 #include "paranormal.h"
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
16 #include "actuators.h"
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
17
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
18 /* SDL stuffs */
192
a7c823478180 [svn] - add fast linedrawing code
nenolod
parents: 191
diff changeset
19 SDL_Surface *screen;
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
20
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
21 /* Globals */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
22 struct pn_rc *pn_rc;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
23 struct pn_image_data *pn_image_data;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
24 struct pn_sound_data *pn_sound_data;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
25
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
26 /* Trig Pre-Computes */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
27 float sin_val[360];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
28 float cos_val[360];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
29
302
b185ed2f8fa2 [svn] - improve beat detection
nenolod
parents: 266
diff changeset
30 gboolean pn_new_beat;
b185ed2f8fa2 [svn] - improve beat detection
nenolod
parents: 266
diff changeset
31
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
32 /* **************** drawing doodads **************** */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
33
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
34 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
35 blit_to_screen (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
36 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
37 int j;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
38
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
39 SDL_LockSurface (screen);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
40
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
41 /* FIXME: add scaling support */
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 SDL_SetPalette (screen, SDL_LOGPAL|SDL_PHYSPAL,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
44 (SDL_Color*)pn_image_data->cmap, 0, 256);
266
1613a51ca349 [svn] - make sure the alphachannel is always full
nenolod
parents: 192
diff changeset
45 SDL_SetAlpha (screen, 0, 255);
149
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 for (j=0; j<pn_image_data->height; j++)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
48 memcpy (screen->pixels + j*screen->pitch,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
49 pn_image_data->surface[0] + j*pn_image_data->width,
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
50 pn_image_data->width);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
51
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 SDL_UnlockSurface (screen);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
54
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
55 SDL_UpdateRect (screen, 0, 0, 0, 0);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
56 }
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 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
59 resize_video (guint w, guint h)
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 pn_image_data->width = w;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
62 pn_image_data->height = h;
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 if (pn_image_data->surface[0])
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
65 g_free (pn_image_data->surface[0]);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
66 if (pn_image_data->surface[1])
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
67 g_free (pn_image_data->surface[1]);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
68
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
69 pn_image_data->surface[0] = g_malloc0 (w * h);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
70 pn_image_data->surface[1] = g_malloc0 (w * h);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
71
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
72 screen = SDL_SetVideoMode (w, h, 8, SDL_HWSURFACE |
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
73 SDL_HWPALETTE | SDL_RESIZABLE);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
74 if (! screen)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
75 pn_fatal_error ("Unable to create a new SDL window: %s",
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
76 SDL_GetError ());
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
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
79 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
80 take_screenshot (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
81 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
82 char fname[32];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
83 struct stat buf;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
84 int i=0;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
85
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
86 do
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
87 sprintf (fname, "pn_%05d.bmp", ++i);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
88 while (stat (fname, &buf) == 0);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
89
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
90 SDL_SaveBMP (screen, fname);
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
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
93 /* FIXME: This should resize the video to a user-set
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
94 fullscreen res */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
95 static void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
96 toggle_fullscreen (void)
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 SDL_WM_ToggleFullScreen (screen);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
99 if (SDL_ShowCursor (SDL_QUERY) == SDL_ENABLE)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
100 SDL_ShowCursor (SDL_DISABLE);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
101 else
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
102 SDL_ShowCursor (SDL_ENABLE);
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
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
105 /* **************** basic renderer management **************** */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
106 void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
107 pn_init (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
108 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
109 int i;
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
110 #ifdef FULLSCREEN_HACK
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
111 char SDL_windowhack[32];
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
112 GdkScreen *screen;
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
113 #endif
149
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 pn_sound_data = g_new0 (struct pn_sound_data, 1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
116 pn_image_data = g_new0 (struct pn_image_data, 1);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
117
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
118 #ifdef FULLSCREEN_HACK
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
119 screen = gdk_screen_get_default();
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
120 sprintf(SDL_windowhack,"SDL_WINDOWID=%d",
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
121 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
122 putenv(SDL_windowhack);
191
6d5f164a8719 [svn] - fix warning (oops)
nenolod
parents: 190
diff changeset
123 #endif
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
124
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
125 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
126 pn_fatal_error ("Unable to initialize SDL: %s", SDL_GetError ());
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
127
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
128 #ifndef FULLSCREEN_HACK
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
129 resize_video (640, 360);
190
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
130 #else
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
131 resize_video (1280, 1024);
31f238746877 [svn] - compile with -DFULLSCREEN_HACK to get the fullscreen overlay stuff
nenolod
parents: 151
diff changeset
132 #endif
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
133
151
3c8ff183766f [svn] - fix some window titles
nenolod
parents: 149
diff changeset
134 SDL_WM_SetCaption ("Paranormal Visualization Studio " VERSION, PACKAGE);
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
135
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
136 for(i=0; i<360; i++)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
137 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
138 sin_val[i] = sin(i*(M_PI/180.0));
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
139 cos_val[i] = cos(i*(M_PI/180.0));
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
140 }
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
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
143 void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
144 pn_cleanup (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
145 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
146 SDL_FreeSurface (screen);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
147 SDL_Quit ();
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
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
150 if (pn_image_data)
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 if (pn_image_data->surface[0])
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
153 g_free (pn_image_data->surface[0]);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
154 if (pn_image_data->surface[1])
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
155 g_free (pn_image_data->surface[1]);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
156 g_free (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_sound_data)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
159 g_free (pn_sound_data);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
160 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
161
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
162 /* Renders one frame and handles the SDL window */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
163 void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
164 pn_render (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
165 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
166 SDL_Event event;
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 /* Handle window events */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
169 while (SDL_PollEvent (&event))
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
170 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
171 switch (event.type)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
172 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
173 case SDL_QUIT:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
174 pn_quit ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
175 g_assert_not_reached ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
176 case SDL_KEYDOWN:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
177 switch (event.key.keysym.sym)
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 SDLK_ESCAPE:
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 SDLK_RETURN:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
183 if (event.key.keysym.mod & (KMOD_ALT | KMOD_META))
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
184 toggle_fullscreen ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
185 break;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
186 case SDLK_BACKQUOTE:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
187 take_screenshot ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
188 break;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
189 default:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
190 break;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
191 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
192 break;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
193 case SDL_VIDEORESIZE:
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
194 resize_video (event.resize.w, event.resize.h);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
195 break;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
196 }
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
302
b185ed2f8fa2 [svn] - improve beat detection
nenolod
parents: 266
diff changeset
199 pn_new_beat = pn_is_new_beat();
b185ed2f8fa2 [svn] - improve beat detection
nenolod
parents: 266
diff changeset
200
149
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
201 if (pn_rc->actuator)
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 exec_actuator (pn_rc->actuator);
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
204 blit_to_screen ();
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
205 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
206 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
207
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
208 /* 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
209 (by the builtin, after it is done) */
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
210 void
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
211 pn_swap_surfaces (void)
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
212 {
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
213 guchar *tmp = pn_image_data->surface[0];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
214 pn_image_data->surface[0] = pn_image_data->surface[1];
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
215 pn_image_data->surface[1] = tmp;
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
216 }
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
217
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
218
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
219
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
220
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
221
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
222
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
223
fd9c0a5871ac [svn] - new and IMPROVED paranormal visualization studio
nenolod
parents:
diff changeset
224
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