aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/lib/projectM/projectM.pas
blob: 1c699e2bf80328349a9bdb959aa0bca7ff14ba42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
unit projectM;

{$IFDEF FPC}
  {$IFNDEF win32}
  {$LINKLIB libprojectM}
  {$ENDIF}
  {$MODE DELPHI}
  {$PACKENUM 4}
  {$PACKRECORDS C}
{$ENDIF}

interface

uses
{$IFNDEF win32}
  baseunix,
{$ENDIF}
  OpenGL12;

const
{$IFDEF win32}
  libprojectM = 'libprojectM.dll';
{$ELSE}
  libprojectM = 'libprojectM.so';
{$ENDIF}

const
  PROJECTM_VERSION = '0.99';
  PROJECTM_TITLE   = 'projectM 0.99';

type
  FLOAT = Single;
  PFLOAT = ^FLOAT;
  PPFLOAT = ^PFLOAT;
  INT = Integer;
  SHORT = Smallint;
  LONG = Longint;

type
  // 16bit interleaved data
  TPCM16Data = array[0..511, 0..1] of SHORT;
  PPCM16Data = ^TPCM16Data;
  // 16bit non-interleaved data
  TPCM16 = array[0..1, 0..511] of SHORT;
  PPCM16 = ^TPCM16;
  // 8bit non-interleaved data
  TPCM8  = array[0..1, 0..511] of byte;
  PPCM8  = ^TPCM8;

type
  TTextureScale = INT;
const
  SCALE_NEAREST   = 0;
  SCALE_MAGNIFY   = 1;
  SCALE_MINIFY    = 2;

type
  TContextType = INT;
const
  AGL_CONTEXT   = 0;
  CGL_CONTEXT   = 1;
  NSGL_CONTEXT  = 2;
  GLX_CONTEXT   = 3;
  WGL_CONTEXT   = 4;

type
  TPBufferPass = INT;
const  
  PBUFFER_PASS1 = 0;
  PBUFFER_PASS2 = 1;

type
  PRenderTarget = ^TRenderTarget;
  TRenderTarget = record
    { Texture size }
    texsize: INT;

    { Application context }
    origContextType: TContextType;

    usePbuffers: INT;

    {$ifdef LINUX}
      lock_func: procedure(); cdecl;
      unlock_func: procedure(); cdecl;
    {$endif}

    { Opaque pbuffer context and pbuffer }
    {$ifdef MACOS}
      origContext: Pointer;
      pbufferContext: Pointer;
      pbuffer: Pointer;
    {$endif}

  { Render target texture ID for non-pbuffer systems }
    textureID: array[0..2] of TGLuint;
  end;

  {
  procedure createPBuffers( width, height: INT; target: PRenderTarget );
  procedure lockPBuffer( target: PRenderTarget; pass: PBufferPass );
  procedure unlockPBuffer( target: PRenderTarget );
  function nearestPower2( value: INT; scaleRule: TTextureScale ): INT;
  }

  PProjectM = ^TProjectM;
  TProjectM = record
    presetURL: PChar;
    presetName: PChar;
    fontURL: PChar;

    hasInit: INT;

    noSwitch: INT;
    pcmframes: INT;
    freqframes: INT;
    totalframes: INT;

    showfps: INT;
    showtitle: INT;
    showpreset: INT;
    showhelp: INT;
    showstats: INT;

    studio: INT;

    fbuffer: PGLubyte;

    {$ifndef Win32}
    { The first ticks value of the application }
    startTime: timeval;
    {$else}
    startTime: LONG;
    {$endif Win32}
    Time: FLOAT;

    { Render target texture ID }
    renderTarget: PRenderTarget;

    disp: array[0..79] of Char;

    wave_o: FLOAT;

    //int texsize=1024;   //size of texture to do actual graphics
    fvw: INT;   //fullscreen dimensions
    fvh: INT;
    wvw: INT;   //windowed dimensions
    wvh: INT;
    vw: INT;    //runtime dimensions
    vh: INT;
    fullscreen: INT;

    maxsamples: INT;  //size of PCM buffer
    numsamples: INT;  //size of new PCM info
    pcmdataL: PFLOAT;     //holder for most recent pcm data
    pcmdataR: PFLOAT;     //holder for most recent pcm data

    avgtime: INT;     //# frames per preset
    
    title: PChar;
    drawtitle: INT;

    correction: INT;

    vol: FLOAT;

    //per pixel equation variables
    gridx: PPFLOAT;     //grid containing interpolated mesh
    gridy: PPFLOAT;
    origtheta: PPFLOAT; //grid containing interpolated mesh reference values
    origrad: PPFLOAT;
    origx: PPFLOAT;     //original mesh
    origy: PPFLOAT;
    origx2: PPFLOAT;    //original mesh
    origy2: PPFLOAT;

    { Timing information }
    mspf: INT;
    timed: INT;
    timestart: INT;
    nohard: INT;
    count: INT;
    realfps,
      fpsstart: FLOAT;

    { PCM data }
    vdataL: array[0..511] of FLOAT;  //holders for FFT data (spectrum)
    vdataR: array[0..511] of FLOAT;

    { Various toggles }
    doPerPixelEffects: INT;
    doIterative: INT;

    { ENGINE VARIABLES }
    { From engine_vars.h }
    preset_name: array[0..255] of Char;

    { PER FRAME CONSTANTS BEGIN }
    zoom: FLOAT;
    zoomexp: FLOAT;
    rot: FLOAT;
    warp: FLOAT;

    sx: FLOAT;
    sy: FLOAT;
    dx: FLOAT;
    dy: FLOAT;
    cx: FLOAT;
    cy: FLOAT;

    gy: INT;
    gx: INT;

    decay: FLOAT;

    wave_r: FLOAT;
    wave_g: FLOAT;
    wave_b: FLOAT;
    wave_x: FLOAT;
    wave_y: FLOAT;
    wave_mystery: FLOAT;

    ob_size: FLOAT;
    ob_r: FLOAT;
    ob_g: FLOAT;
    ob_b: FLOAT;
    ob_a: FLOAT;

    ib_size: FLOAT;
    ib_r: FLOAT;
    ib_g: FLOAT;
    ib_b: FLOAT;
    ib_a: FLOAT;

    meshx: INT;
    meshy: INT;

    mv_a: FLOAT;
    mv_r: FLOAT;
    mv_g: FLOAT;
    mv_b: FLOAT;
    mv_l: FLOAT;
    mv_x: FLOAT;
    mv_y: FLOAT;
    mv_dy: FLOAT;
    mv_dx: FLOAT;

    treb: FLOAT;
    mid: FLOAT;
    bass: FLOAT;
    bass_old: FLOAT;
    beat_sensitivity: FLOAT;
    treb_att: FLOAT;
    mid_att: FLOAT;
    bass_att: FLOAT;
    progress: FLOAT;
    frame: INT;

    { PER_FRAME CONSTANTS END }

    { PER_PIXEL CONSTANTS BEGIN }

    x_per_pixel: FLOAT;
    y_per_pixel: FLOAT;
    rad_per_pixel: FLOAT;
    ang_per_pixel: FLOAT;

    { PER_PIXEL CONSTANT END }


    fRating: FLOAT;
    fGammaAdj: FLOAT;
    fVideoEchoZoom: FLOAT;
    fVideoEchoAlpha: FLOAT;

    nVideoEchoOrientation: INT;
    nWaveMode: INT;
    bAdditiveWaves: INT;
    bWaveDots: INT;
    bWaveThick: INT;
    bModWaveAlphaByVolume: INT;
    bMaximizeWaveColor: INT;
    bTexWrap: INT;
    bDarkenCenter: INT;
    bRedBlueStereo: INT;
    bBrighten: INT;
    bDarken: INT;
    bSolarize: INT;
    bInvert: INT;
    bMotionVectorsOn: INT;
    fps: INT;

    fWaveAlpha: FLOAT;
    fWaveScale: FLOAT;
    fWaveSmoothing: FLOAT;
    fWaveParam: FLOAT;
    fModWaveAlphaStart: FLOAT;
    fModWaveAlphaEnd: FLOAT;
    fWarpAnimSpeed: FLOAT;
    fWarpScale: FLOAT;
    fShader: FLOAT;

    
    { Q VARIABLES START }

    q1: FLOAT;
    q2: FLOAT;
    q3: FLOAT;
    q4: FLOAT;
    q5: FLOAT;
    q6: FLOAT;
    q7: FLOAT;
    q8: FLOAT;


    { Q VARIABLES END }

    zoom_mesh: PPFLOAT;
    zoomexp_mesh: PPFLOAT;
    rot_mesh: PPFLOAT;

    sx_mesh: PPFLOAT;
    sy_mesh: PPFLOAT;
    dx_mesh: PPFLOAT;
    dy_mesh: PPFLOAT;
    cx_mesh: PPFLOAT;
    cy_mesh: PPFLOAT;

    x_mesh: PPFLOAT;
    y_mesh: PPFLOAT;
    rad_mesh: PPFLOAT;
    theta_mesh: PPFLOAT;
  end;

  { Functions }
  procedure projectM_init(pm: PProjectM); cdecl; external libprojectM;
  procedure projectM_reset(pm: PProjectM); cdecl; external libprojectM;
  procedure projectM_resetGL(pm: PProjectM; width: INT; height: INT); cdecl; external libprojectM;
  procedure projectM_setTitle(pm: PProjectM; title: PChar); cdecl; external libprojectM;
  procedure renderFrame(pm: PProjectM); cdecl; external libprojectM;

  {
  procedure draw_help(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_fps(pm: PProjectM; fps: Single); cdecl; external libprojectM;
  procedure draw_preset(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_title(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_stats(pm: PProjectM); cdecl; external libprojectM;

  procedure modulate_opacity_by_volume(pm: PProjectM); cdecl; external libprojectM;
  procedure maximize_colors(pm: PProjectM); cdecl; external libprojectM;
  procedure do_per_pixel_math(pm: PProjectM); cdecl; external libprojectM;
  procedure do_per_frame(pm: PProjectM); cdecl; external libprojectM;
  procedure darken_center(pm: PProjectM); cdecl; external libprojectM;

  procedure render_interpolation(pm: PProjectM); cdecl; external libprojectM;
  procedure render_texture_to_screen(pm: PProjectM); cdecl; external libprojectM;
  procedure render_texture_to_studio(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_motion_vectors(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_borders(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_shapes(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_waveform(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_custom_waves(pm: PProjectM); cdecl; external libprojectM;

  procedure draw_title_to_screen(pm: PProjectM); cdecl; external libprojectM;
  procedure draw_title_to_texture(pm: PProjectM); cdecl; external libprojectM;
  procedure get_title(pm: PProjectM); cdecl; external libprojectM;

  procedure reset_per_pixel_matrices(pm: PProjectM); cdecl; external libprojectM;
  procedure init_per_pixel_matrices(pm: PProjectM); cdecl; external libprojectM;
  procedure rescale_per_pixel_matrices(pm: PProjectM); cdecl; external libprojectM;
  }
  
  { PCM.h declarations }
  procedure addPCMfloat(pcm_data: PSingle; samples: integer); cdecl; external libprojectM;
  procedure addPCM16(pcm_data: PPCM16); cdecl; external libprojectM;
  procedure addPCM16Data(pcm_data: PPCM16Data; samples: Smallint); cdecl; external libprojectM;
  procedure addPCM8(pcm_data: PPCM8); cdecl; external libprojectM;

implementation

end.