Mercurial > audlegacy-plugins
annotate src/projectm-1.0/main.cxx @ 2102:42a16b5e5151 audacious-plugins-1.4.0-beta3
try to fill in MAD_CFLAGS/MAD_LIBS with sensible defaults. enforce AC_SUBST().
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 19 Oct 2007 05:44:42 -0500 |
parents | 47a4e93ed7ce |
children | 0edf1cb262c0 |
rev | line source |
---|---|
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
1 /* |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
2 projectM v1.01 - xmms-projectm.sourceforge.net |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
3 -------------------------------------------------- |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
4 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
5 Lead Developers: Carmelo Piccione (carmelo.piccione@gmail.com) & |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
6 Peter Sperl (peter@sperl.com) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
7 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
8 We have also been advised by some professors at CMU, namely Roger B. Dannenberg. |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
9 http://www-2.cs.cmu.edu/~rbd/ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
10 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
11 The inspiration for this program was Milkdrop by Ryan Geiss. Obviously. |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
12 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
13 This code is distributed under the GPL. |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
14 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
15 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
16 THANKS FOR THE CODE!!! |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
17 ------------------------------------------------- |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
18 The base for this program was andy@nobugs.org's XMMS plugin tutorial |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
19 http://www.xmms.org/docs/vis-plugin.html |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
20 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
21 We used some FFT code by Takuya OOURA instead of XMMS' built-in fft code |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
22 fftsg.c - http://momonga.t.u-tokyo.ac.jp/~ooura/fft.html |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
23 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
24 and some beat detection code was inspired by Frederic Patin @ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
25 www.gamedev.net/reference/programming/features/beatdetection/ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
26 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
27 */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
28 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
29 #include <stdio.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
30 #include <string.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
31 #include <string> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
32 #include <stdlib.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
33 #include <unistd.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
34 #include <fcntl.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
35 #include <SDL/SDL.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
36 #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
|
37 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
38 extern "C" { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
39 #include <audacious/util.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
40 #include <audacious/plugin.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
41 #include <audacious/auddrct.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
42 } |
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
|
43 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
44 #include <math.h> |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
45 #include "ConfigFile.h" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
46 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
47 #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
|
48 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
49 #include "sdltoprojectM.h" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
50 #include "video_init.h" |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
51 |
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
|
52 #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
|
53 #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
|
54 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
55 // Forward declarations |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
56 extern "C" void projectM_xmms_init(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
57 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
|
58 extern "C" void projectM_about(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
59 extern "C" void projectM_configure(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
60 extern "C" void projectM_playback_start(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
61 extern "C" void projectM_playback_stop(void); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
62 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
|
63 extern "C" void projectM_render_freq(gint16 pcm_data[2][256]); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
64 extern "C" int worker_func(void*); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
65 std::string read_config(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
66 void saveSnapshotToFile(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
67 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
68 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
|
69 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
70 //extern preset_t * active_preset; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
71 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
72 //FILE * debugFile = fopen("./dwrite-dump", "wb"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
73 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
74 // Our worker thread |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
75 SDL_Thread *worker_thread = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
76 SDL_sem *sem = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
77 SDL_Event event; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
78 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
79 SDL_Surface *screen; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
80 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
81 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
82 projectM * globalPM = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
83 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
84 int maxsamples=512; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
85 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
86 int texsize=512; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
87 int gx=32,gy=24; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
88 int wvw=400,wvh=400; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
89 int fvw=1024,fvh=768; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
90 int fps=35, fullscreen=0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
91 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
92 // char *title; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
93 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
94 gint disable_projectm(void *something) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
95 projectM_vtable.disable_plugin(&projectM_vtable); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
96 return 0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
97 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
98 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
99 Uint32 get_xmms_title(Uint32 something, void *somethingelse) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
100 static char check_title = 1; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
101 static int last_pos; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
102 static char *last_title = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
103 int pos; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
104 char *title = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
105 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
106 //Nice optimization, but we want the title no matter what so I can display it when the song changes |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
107 #if 0 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
108 if(!(globalPM->showtitle%2)) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
109 /* Repeat less often when not showing title */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
110 return 1000; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
111 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
112 #endif |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
113 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
114 pos = audacious_drct_pl_get_pos(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
115 /* Only check every 1 second for title change, otherwise check pos */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
116 if(check_title || pos != last_pos) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
117 title = audacious_drct_pl_get_title(pos); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
118 if(title && (!last_title || strcmp(last_title,title))) { |
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
|
119 //globalPM->renderer->title = title; |
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
|
120 //globalPM->renderer->drawtitle = 1; |
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
|
121 |
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
|
122 std::string titlepp(title); |
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
|
123 globalPM->projectM_setTitle(titlepp); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
124 g_free(last_title); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
125 last_title = title; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
126 } else if(title && last_title != title) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
127 /* New copy of last title */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
128 g_free(title); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
129 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
130 check_title = !check_title; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
131 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
132 last_pos = pos; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
133 /* Repeat every 500ms */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
134 return 500; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
135 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
136 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
137 int capture = 0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
138 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
139 int worker_func(void*) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
140 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
141 // char projectM_data[1024]; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
142 SDL_TimerID title_timer = NULL; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
143 std::string config_file; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
144 config_file = read_config(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
145 ConfigFile config(config_file); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
146 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
147 int wvw = config.read<int>( "Window Width", 512 ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
148 int wvh = config.read<int>( "Window Height", 512 ); |
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
|
149 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
150 int fullscreen = 0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
151 if (config.read("Fullscreen", true)) fullscreen = 1; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
152 else fullscreen = 0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
153 |
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
|
154 init_display(wvw,wvh,&fvw,&fvh,fullscreen); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
155 SDL_WM_SetCaption("projectM v1.00", "projectM v1.00"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
156 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
157 /** Initialise projectM */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
158 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
159 globalPM = new projectM(config_file); |
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
|
160 SDL_SemPost(sem); |
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
|
161 title_timer = SDL_AddTimer(500, get_xmms_title, NULL); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
162 /** Initialise the thread */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
163 // SDL_SemTryWait(sem); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
164 while ( SDL_SemValue(sem)==1 ) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
165 projectMEvent evt; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
166 projectMKeycode key; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
167 projectMModifier mod; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
168 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
169 /** Process SDL events */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
170 SDL_Event event; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
171 while ( SDL_PollEvent( &event ) ) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
172 /** Translate into projectM codes and process */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
173 evt = sdl2pmEvent( event ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
174 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
175 key = sdl2pmKeycode( event.key.keysym.sym ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
176 mod = sdl2pmModifier( event.key.keysym.mod ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
177 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
178 if ( evt == PROJECTM_KEYDOWN ) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
179 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
180 if(key == PROJECTM_K_c) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
181 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
182 //SDL_SaveBMP(screen, "/home/pete/1.bmp"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
183 saveSnapshotToFile(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
184 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
185 if(key == PROJECTM_K_v) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
186 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
187 // capture++; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
188 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
189 if(key == PROJECTM_K_f) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
190 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
191 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
192 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
193 int w, h; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
194 if (fullscreen == 0) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
195 w = fvw; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
196 h = fvh; |
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
|
197 fullscreen = 1; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
198 } else { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
199 w = wvw; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
200 h = wvh; |
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
|
201 fullscreen = 0; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
202 } |
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
|
203 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
204 resize_display(w, h, fullscreen); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
205 globalPM->projectM_resetGL( w, h ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
206 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
207 else globalPM->key_handler(evt,key,mod); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
208 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
209 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
210 else if ( evt == PROJECTM_VIDEORESIZE ) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
211 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
212 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
213 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
214 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
215 wvw=event.resize.w; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
216 wvh=event.resize.h; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
217 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
218 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
219 resize_display(wvw,wvh,fullscreen); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
220 globalPM->projectM_resetGL( wvw, wvh ); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
221 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
222 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
223 else if ( evt == PROJECTM_VIDEOQUIT ) { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
224 |
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
|
225 (void) g_idle_add ((GSourceFunc) disable_projectm, NULL); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
226 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
227 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
228 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
229 /** Add the waveform data */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
230 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
231 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
232 /** Render the new frame */ |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
233 // strcpy(title,xmms_remote_get_playlist_title(projectM_vtable.xmms_session, xmms_remote_get_playlist_pos(projectM_vtable.xmms_session))); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
234 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
235 //printf("%s\n",title); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
236 // strcpy(globalPM->title,title); |
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
|
237 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
238 globalPM->renderFrame(); |
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
|
239 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
240 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
241 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
242 SDL_GL_SwapBuffers(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
243 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
244 if (capture % 2 == 1) saveSnapshotToFile(); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
245 // SDL_SemPost(sem); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
246 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
247 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
248 if(title_timer) |
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
|
249 SDL_RemoveTimer(title_timer); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
250 delete globalPM; |
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
|
251 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
252 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
253 return 0; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
254 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
255 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
256 extern "C" void projectM_xmms_init(void) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
257 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
258 |
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
|
259 /* First, initialize SDL's video subsystem. */ |
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
|
260 // std::cerr << "sdl init begin" << std::endl; |
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
|
261 if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 ) { |
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
|
262 /* Failed, exit. */ |
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
|
263 fprintf( stderr, "Video initialization failed: %s\n", |
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
|
264 SDL_GetError( ) ); |
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
|
265 //projectM_vtable.disable_plugin (&projectM_vtable); |
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
|
266 return; |
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
|
267 |
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
|
268 } |
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
|
269 sem = SDL_CreateSemaphore(0); |
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
|
270 // printf("projectM plugin: Initializing\n"); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
271 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
272 SDL_EnableUNICODE(1); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
273 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
274 worker_thread = SDL_CreateThread ( *worker_func, NULL); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
275 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
276 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
277 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
278 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
279 |
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
|
280 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
|
281 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
282 |
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
|
283 if(!sem) return; |
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
|
284 SDL_SemWait(sem); |
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
|
285 if(worker_thread) SDL_WaitThread(worker_thread, NULL); |
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
|
286 // SDL_KillThread(worker_thread); |
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
|
287 //printf("killed thread\n"); |
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
|
288 |
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
|
289 SDL_DestroySemaphore(sem); |
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
|
290 //printf("Destroy Mutex\n"); |
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
|
291 SDL_Quit(); |
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
|
292 |
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
|
293 sem = NULL; |
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
|
294 worker_thread = NULL; |
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
|
295 |
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
|
296 // printf("projectM plugin: Cleanup completed\n"); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
297 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
298 extern "C" void projectM_about(void) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
299 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
300 printf("projectM plugin: About\n"); |
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 extern "C" void projectM_configure(void) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
303 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
304 printf("projectM plugin: Configure\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
305 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
306 extern "C" void projectM_playback_start(void) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
307 {//thread_control = GO; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
308 printf("projectM plugin: Playback starting\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
309 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
310 extern "C" void projectM_playback_stop(void) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
311 {//thread_control = STOP; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
312 printf("projectM plugin: Playback stopping\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
313 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
314 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
|
315 { |
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
|
316 //SDL_mutexP(mutex); while ( SDL_SemValue(sem)==1 ) |
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
|
317 if ( SDL_SemValue(sem)==1 ) |
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
|
318 globalPM->pcm->addPCM16(pcm_data); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
319 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
320 //SDL_mutexV(mutex); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
321 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
322 } |
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 extern "C" void projectM_render_freq(gint16 freq_data[2][256]) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
325 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
326 printf("NO GOOD\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
327 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
328 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
329 std::string read_config() |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
330 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
331 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
332 // int n; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
333 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
334 char num[512]; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
335 FILE *in; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
336 FILE *out; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
337 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
338 char* home; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
339 char projectM_home[1024]; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
340 char projectM_config[1024]; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
341 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
342 strcpy(projectM_config, PROJECTM_PREFIX); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
343 strcpy(projectM_config+strlen(PROJECTM_PREFIX), CONFIG_FILE); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
344 projectM_config[strlen(PROJECTM_PREFIX)+strlen(CONFIG_FILE)]='\0'; |
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
|
345 //printf("dir:%s \n",projectM_config); |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
346 home=getenv("HOME"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
347 strcpy(projectM_home, home); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
348 strcpy(projectM_home+strlen(home), "/.projectM/config.inp"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
349 projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0'; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
350 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
351 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
352 if ((in = fopen(projectM_home, "r")) != 0) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
353 { |
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
|
354 //printf("reading ~/.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
|
355 fclose(in); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
356 return std::string(projectM_home); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
357 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
358 else |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
359 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
360 printf("trying to create ~/.projectM/config.inp \n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
361 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
362 strcpy(projectM_home, home); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
363 strcpy(projectM_home+strlen(home), "/.projectM"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
364 projectM_home[strlen(home)+strlen("/.projectM")]='\0'; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
365 mkdir(projectM_home,0755); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
366 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
367 strcpy(projectM_home, home); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
368 strcpy(projectM_home+strlen(home), "/.projectM/config.inp"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
369 projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0'; |
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
|
370 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
371 if((out = fopen(projectM_home,"w"))!=0) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
372 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
373 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
374 if ((in = fopen(projectM_config, "r")) != 0) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
375 { |
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 while(fgets(num,80,in)!=NULL) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
378 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
379 fputs(num,out); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
380 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
381 fclose(in); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
382 fclose(out); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
383 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
384 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
385 if ((in = fopen(projectM_home, "r")) != 0) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
386 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
387 printf("created ~/.projectM/config.inp successfully\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
388 fclose(in); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
389 return std::string(projectM_home); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
390 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
391 else{printf("This shouldn't happen, using implementation defualts\n");abort();} |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
392 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
393 else{printf("Cannot find projectM default config, using implementation defaults\n");abort();} |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
394 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
395 else |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
396 { |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
397 printf("Cannot create ~/.projectM/config.inp, using default config file\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
398 if ((in = fopen(projectM_config, "r")) != 0) |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
399 { printf("Successfully opened default config file\n"); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
400 fclose(in); |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
401 return std::string(projectM_config);} |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
402 else{ printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); abort();} |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
403 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
404 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
405 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
406 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
407 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
|
408 } |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
409 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
410 int frame = 1; |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
411 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
412 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
413 void saveSnapshotToFile() |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
414 { |
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 char dumpPath[512]; |
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
|
416 char Home[512]; |
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
|
417 //char *home; |
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
|
418 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
419 SDL_Surface * bitmap; |
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
|
420 |
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
|
421 GLint viewport[4]; |
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
|
422 long bytewidth; |
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
|
423 GLint width, height; |
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
|
424 long bytes; |
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
|
425 |
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
|
426 glReadBuffer(GL_FRONT); |
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
|
427 glGetIntegerv(GL_VIEWPORT, viewport); |
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
|
428 |
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
|
429 width = viewport[2]; |
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
|
430 height = viewport[3]; |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
431 |
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
|
432 bytewidth = width * 4; |
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
|
433 bytewidth = (bytewidth + 3) & ~3; |
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
|
434 bytes = bytewidth * height; |
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
|
435 |
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
|
436 /* |
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
|
437 glFinish(); |
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
|
438 glPixelStorei(GL_PACK_ALIGNMENT, 4); |
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
|
439 glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
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
|
440 glPixelStorei(GL_PACK_SKIP_ROWS, 0); |
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
|
441 glPixelStorei(GL_PACK_SKIP_PIXELS, 0); |
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
|
442 */ |
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
|
443 |
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
|
444 |
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
|
445 bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,0,0,0,0); |
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
|
446 glReadPixels(0, 0, width, height, |
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
|
447 GL_BGRA, |
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
|
448 GL_UNSIGNED_INT_8_8_8_8_REV, |
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
|
449 bitmap->pixels); |
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
|
450 |
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
|
451 sprintf(dumpPath, "/.projectM/%.8d.bmp", frame++); |
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
|
452 // home=getenv("HOME"); |
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
|
453 strcpy(Home, getenv("HOME")); |
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
|
454 strcpy(Home+strlen(Home), dumpPath); |
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
|
455 Home[strlen(Home)]='\0'; |
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
|
456 SDL_SaveBMP(bitmap, Home); |
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
|
457 |
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
|
458 SDL_FreeSurface(bitmap); |
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
|
459 |
1920
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
460 |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
461 } |
a6d84a2cfaa7
projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff
changeset
|
462 |