Mercurial > audlegacy-plugins
annotate src/projectm-1.0/main.cxx @ 2245:0edf1cb262c0
projectm-1.0: rewrite the plugin.
(I have no internet connection at the moment because my ISP is a bunch
of incompetent bastards, so this was the only thing to do to spend/waste
some time.)
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Mon, 17 Dec 2007 15:23:30 -0600 |
parents | 47a4e93ed7ce |
children | f06b48381052 |
rev | line source |
---|---|
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
1 /* |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
2 * main.cxx: plugin glue to libprojectm |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
3 * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk> |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
4 * Portions copyright (c) 2004-2006 Peter Sperl |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
5 * |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
6 * This program is free software; you may distribute it under the terms |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
7 * of the GNU General Public License; version 2. |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
8 */ |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
9 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
10 #include <stdio.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
11 #include <string.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
12 #include <string> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
13 #include <stdlib.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
14 #include <unistd.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
15 #include <fcntl.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
16 #include <SDL/SDL.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
17 #include <SDL/SDL_thread.h> |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
18 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
19 extern "C" |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
20 { |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
21 #include <audacious/util.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
22 #include <audacious/plugin.h> |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
23 #include <audacious/playlist.h> |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
24 #include <audacious/auddrct.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
25 } |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
26 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
27 #include <math.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
28 #include "ConfigFile.h" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
29 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
30 #include <libprojectM/projectM.hpp> |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
31 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
32 #include "sdltoprojectM.h" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
33 |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
34 #include <GL/gl.h> |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
35 #define CONFIG_FILE "/share/projectM/config.inp" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
36 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
37 // Forward declarations |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
38 extern "C" void projectM_xmms_init(void); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
39 extern "C" void projectM_cleanup(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
40 extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]); |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
41 extern "C" int worker_func(void *); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
42 std::string read_config(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
43 void saveSnapshotToFile(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
44 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
45 extern "C" VisPlugin projectM_vtable; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
46 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
47 int SDLThreadWrapper(void *); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
48 void handle_playback_trigger(void *, void *); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
49 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
50 class projectMPlugin |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
51 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
52 private: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
53 projectM *pm; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
54 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
55 gint wvw, wvh, fvw, fvh; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
56 gboolean fullscreen; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
57 gboolean error; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
58 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
59 SDL_Event event; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
60 SDL_Surface *screen; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
61 SDL_Thread *worker_thread; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
62 SDL_sem *sem; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
63 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
64 protected: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
65 projectMPlugin() |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
66 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
67 std::string configFile = read_config(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
68 ConfigFile config(configFile); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
69 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
70 this->wvw = config.read<int>("Window Width", 512); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
71 this->wvh = config.read<int>("Window Height", 512); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
72 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
73 this->fullscreen = FALSE; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
74 if (config.read("Fullscreen", true)) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
75 this->fullscreen = TRUE; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
76 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
77 /* initialise SDL */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
78 if (SDL_Init(SDL_INIT_VIDEO) < 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
79 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
80 this->error++; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
81 return; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
82 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
83 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
84 SDL_WM_SetCaption("projectM", "audacious"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
85 SDL_EnableUNICODE(1); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
86 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
87 this->sem = SDL_CreateSemaphore(0); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
88 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
89 /* XXX */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
90 aud_hook_associate("playback begin", handle_playback_trigger, NULL); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
91 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
92 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
93 ~projectMPlugin() |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
94 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
95 if (!this->sem) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
96 return; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
97 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
98 SDL_SemWait(this->sem); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
99 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
100 if (this->worker_thread) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
101 SDL_WaitThread(this->worker_thread, NULL); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
102 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
103 SDL_DestroySemaphore(this->sem); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
104 SDL_Quit(); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
105 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
106 this->sem = 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
107 this->worker_thread = 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
108 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
109 delete this->pm; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
110 this->pm = 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
111 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
112 aud_hook_dissociate("playback begin", handle_playback_trigger); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
113 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
114 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
115 public: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
116 int run(void *unused) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
117 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
118 if (error) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
119 return -1; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
120 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
121 std::string configFile = read_config(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
122 this->initDisplay(this->wvw, this->wvh, &this->fvw, &this->fvh, this->fullscreen); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
123 this->pm = new projectM(configFile); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
124 this->pm->projectM_resetGL(this->wvw, this->wvh); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
125 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
126 SDL_SemPost(this->sem); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
127 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
128 while (SDL_SemValue(this->sem) == 1) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
129 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
130 projectMEvent evt; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
131 projectMKeycode key; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
132 projectMModifier mod; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
133 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
134 SDL_Event event; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
135 while (SDL_PollEvent(&event)) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
136 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
137 evt = sdl2pmEvent(event); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
138 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
139 key = sdl2pmKeycode(event.key.keysym.sym); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
140 mod = sdl2pmModifier(event.key.keysym.mod); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
141 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
142 switch (evt) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
143 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
144 case PROJECTM_KEYDOWN: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
145 switch (key) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
146 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
147 case PROJECTM_K_c: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
148 saveSnapshotToFile(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
149 break; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
150 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
151 case PROJECTM_K_f: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
152 int w, h; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
153 if (fullscreen == 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
154 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
155 w = fvw; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
156 h = fvh; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
157 fullscreen = 1; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
158 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
159 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
160 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
161 w = wvw; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
162 h = wvh; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
163 fullscreen = 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
164 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
165 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
166 this->resizeDisplay(w, h, fullscreen); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
167 this->pm->projectM_resetGL(w, h); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
168 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
169 break; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
170 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
171 default: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
172 this->pm->key_handler(evt, key, mod); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
173 break; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
174 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
175 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
176 break; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
177 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
178 case PROJECTM_VIDEORESIZE: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
179 wvw = event.resize.w; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
180 wvh = event.resize.h; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
181 this->resizeDisplay(wvw, wvh, fullscreen); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
182 this->pm->projectM_resetGL(wvw, wvh); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
183 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
184 break; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
185 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
186 case PROJECTM_VIDEOQUIT: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
187 std::cerr << "XXX: PROJECTM_VIDEOQUIT is not implemented yet!" << std::endl; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
188 break; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
189 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
190 default: |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
191 break; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
192 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
193 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
194 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
195 this->pm->renderFrame(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
196 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
197 SDL_GL_SwapBuffers(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
198 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
199 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
200 return 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
201 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
202 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
203 void launchThread() |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
204 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
205 /* SDL sucks and won't let you use C++ functors... */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
206 this->worker_thread = SDL_CreateThread(SDLThreadWrapper, NULL); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
207 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
208 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
209 void addPCMData(gint16 pcm_data[2][512]) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
210 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
211 if (SDL_SemValue(this->sem) == 1) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
212 this->pm->pcm->addPCM16(pcm_data); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
213 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
214 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
215 void initDisplay(gint width, gint height, gint *rwidth, gint *rheight, gboolean fullscreen) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
216 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
217 this->wvw = width; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
218 this->wvh = height; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
219 this->fvw = *rwidth; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
220 this->fvw = *rheight; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
221 this->fullscreen = fullscreen; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
222 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
223 const SDL_VideoInfo *info = NULL; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
224 int bpp; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
225 int flags; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
226 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
227 info = SDL_GetVideoInfo(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
228 if (!info) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
229 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
230 this->error++; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
231 return; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
232 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
233 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
234 /* initialize fullscreen resolution to something "sane" */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
235 *rwidth = width; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
236 *rheight = height; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
237 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
238 bpp = info->vfmt->BitsPerPixel; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
239 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
240 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
241 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
242 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
243 if (this->fullscreen) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
244 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
245 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
246 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
247 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
248 this->screen = SDL_SetVideoMode(width, height, bpp, flags); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
249 if (!this->screen) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
250 this->error++; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
251 } |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
252 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
253 void resizeDisplay(gint width, gint height, gboolean fullscreen) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
254 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
255 this->fullscreen = fullscreen; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
256 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
257 int flags; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
258 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
259 if (this->fullscreen) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
260 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
261 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
262 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
263 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
264 this->screen = SDL_SetVideoMode(width, height, 0, flags); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
265 if (this->screen == 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
266 return; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
267 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
268 SDL_ShowCursor(this->fullscreen ? SDL_DISABLE : SDL_ENABLE); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
269 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
270 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
271 void triggerPlaybackBegin(PlaylistEntry *entry) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
272 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
273 std::string title(entry->title); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
274 this->pm->projectM_setTitle(title); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
275 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
276 }; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
277 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
278 /* glue to implementation section */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
279 projectMPlugin *thePlugin = 0; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
280 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
281 /* SDL sucks and won't let you use proper C++ functors. :( */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
282 int SDLThreadWrapper(void *unused) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
283 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
284 return thePlugin->run(unused); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
285 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
286 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
287 void handle_playback_trigger(gpointer plentry_p, gpointer unused) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
288 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
289 PlaylistEntry *entry = reinterpret_cast<PlaylistEntry *>(plentry_p); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
290 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
291 if (!thePlugin) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
292 return; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
293 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
294 thePlugin->triggerPlaybackBegin(entry); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
295 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
296 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
297 extern "C" void projectM_xmms_init(void) |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
298 { |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
299 thePlugin = new projectMPlugin; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
300 thePlugin->launchThread(); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
301 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
302 |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
303 extern "C" void projectM_cleanup(void) |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
304 { |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
305 if (!thePlugin) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
306 return; |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
307 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
308 delete thePlugin; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
309 } |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
310 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
311 extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
312 { |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
313 if (!thePlugin) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
314 return; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
315 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
316 thePlugin->addPCMData(pcm_data); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
317 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
318 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
319 /******************************************************************************** |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
320 * XXX: This code is from projectM and still needs to be rewritten! * |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
321 ********************************************************************************/ |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
322 std::string read_config() |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
323 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
324 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
325 // int n; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
326 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
327 char num[512]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
328 FILE *in; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
329 FILE *out; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
330 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
331 char *home; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
332 char projectM_home[1024]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
333 char projectM_config[1024]; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
334 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
335 strcpy(projectM_config, PROJECTM_PREFIX); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
336 strcpy(projectM_config + strlen(PROJECTM_PREFIX), CONFIG_FILE); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
337 projectM_config[strlen(PROJECTM_PREFIX) + strlen(CONFIG_FILE)] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
338 //printf("dir:%s \n",projectM_config); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
339 home = getenv("HOME"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
340 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
341 strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
342 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
343 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
344 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
345 if ((in = fopen(projectM_home, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
346 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
347 //printf("reading ~/.projectM/config.inp \n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
348 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
349 return std::string(projectM_home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
350 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
351 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
352 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
353 printf("trying to create ~/.projectM/config.inp \n"); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
354 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
355 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
356 strcpy(projectM_home + strlen(home), "/.projectM"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
357 projectM_home[strlen(home) + strlen("/.projectM")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
358 mkdir(projectM_home, 0755); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
359 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
360 strcpy(projectM_home, home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
361 strcpy(projectM_home + strlen(home), "/.projectM/config.inp"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
362 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
363 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
364 if ((out = fopen(projectM_home, "w")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
365 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
366 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
367 if ((in = fopen(projectM_config, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
368 { |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
369 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
370 while (fgets(num, 80, in) != NULL) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
371 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
372 fputs(num, out); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
373 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
374 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
375 fclose(out); |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
376 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
377 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
378 if ((in = fopen(projectM_home, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
379 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
380 printf("created ~/.projectM/config.inp successfully\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
381 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
382 return std::string(projectM_home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
383 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
384 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
385 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
386 printf("This shouldn't happen, using implementation defualts\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
387 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
388 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
389 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
390 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
391 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
392 printf("Cannot find projectM default config, using implementation defaults\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
393 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
394 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
395 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
396 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
397 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
398 printf("Cannot create ~/.projectM/config.inp, using default config file\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
399 if ((in = fopen(projectM_config, "r")) != 0) |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
400 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
401 printf("Successfully opened default config file\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
402 fclose(in); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
403 return std::string(projectM_config); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
404 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
405 else |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
406 { |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
407 printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
408 abort(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
409 } |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
410 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
411 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
412 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
413 |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
414 abort(); |
2028
47a4e93ed7ce
projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
1920
diff
changeset
|
415 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
416 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
417 int frame = 1; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
418 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
419 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
420 void saveSnapshotToFile() |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
421 { |
2245
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
422 char dumpPath[512]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
423 char Home[512]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
424 //char *home; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
425 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
426 SDL_Surface *bitmap; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
427 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
428 GLint viewport[4]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
429 long bytewidth; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
430 GLint width, height; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
431 long bytes; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
432 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
433 glReadBuffer(GL_FRONT); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
434 glGetIntegerv(GL_VIEWPORT, viewport); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
435 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
436 width = viewport[2]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
437 height = viewport[3]; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
438 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
439 bytewidth = width * 4; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
440 bytewidth = (bytewidth + 3) & ~3; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
441 bytes = bytewidth * height; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
442 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
443 /* |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
444 glFinish(); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
445 glPixelStorei(GL_PACK_ALIGNMENT, 4); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
446 glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
447 glPixelStorei(GL_PACK_SKIP_ROWS, 0); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
448 glPixelStorei(GL_PACK_SKIP_PIXELS, 0); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
449 */ |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
450 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
451 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
452 bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
453 glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bitmap->pixels); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
454 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
455 sprintf(dumpPath, "/.projectM/%.8d.bmp", frame++); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
456 // home=getenv("HOME"); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
457 strcpy(Home, getenv("HOME")); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
458 strcpy(Home + strlen(Home), dumpPath); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
459 Home[strlen(Home)] = '\0'; |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
460 SDL_SaveBMP(bitmap, Home); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
461 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
462 SDL_FreeSurface(bitmap); |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
463 |
0edf1cb262c0
projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents:
2028
diff
changeset
|
464 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
465 } |