-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVisFramework.h
202 lines (155 loc) · 5.12 KB
/
VisFramework.h
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
/*
Tiny3D 'Minimalistic' (OpenGL) Visualizer Framework for Winamp v0.02
Description:
Cleaned up Justin's stuff, added new types, OpenGL support,
made it more object oriented, etc -- most of the code was
written from scratch, or copied and modified from my Nympho3D
and Lily3D engines (neither of them is finished or presentable) :P
Last FrameWork Revision: 11/18/2007
How to use?
Make a copy of this project and modify as needed.
Hints?
... to add more interactivity modify the WndProc :)
... if you just want to render something add the code to the visRender
... you can call getVisInstance() anytime you wish :)
... everything else should be self explanatory :P
... DEMO Embed :))
Compiles with both VC++ Express 2005 (most probably also 2008) and GCC, possibly others :P
pS: code blocks marked :P
gcc compile command:
gcc visframework.c font3d.c -lopengl32 -lglu32 -lgdi32 -shared -o vis_love1.dll
Copyright (C) 2007, Mihail Szabolcs
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*/
#ifndef __VisFramework_h__
#define __VisFramework_h__
#include "common.h"
// TODO: change these as needed
#define VIS_USER_TITLE "Razer Visualization Demo"
#define VIS_USER_MODULE_TITLE "Razer Visualization Demo Module"
#define VIS_USER_CLASS "RazerVizDemo"
#define VIS_HDRVER 0x101
// TODO: change these as needed
#define VIS_SCENE_WIDTH 1 // 800x600
#define VIS_SCENE_HEIGHT 1
#define VIS_SCENE_FOV 1000.0f
typedef struct winampVisModule
{
char *description;
HWND hwndParent;
HINSTANCE hDllInstance;
int sRate;
int nCh;
int latencyMs;
int delayMs;
int spectrumNch;
int waveformNch;
unsigned char spectrumData[2][576];
unsigned char waveformData[2][576];
void (*Config)(struct winampVisModule *this_mod);
int (*Init)(struct winampVisModule *this_mod);
int (*Render)(struct winampVisModule *this_mod);
void (*Quit)(struct winampVisModule *this_mod);
void *userData;
} winampVisModule;
typedef struct
{
int version;
char *description;
winampVisModule* (*getModule)(int);
} winampVisHeader;
// exported symbols
typedef winampVisHeader* (*winampVisGetHeaderType)();
// prototypes
void visConfig (struct winampVisModule *this_mod);
int visInit (struct winampVisModule *this_mod);
int visRender (struct winampVisModule *this_mod);
void visQuit (struct winampVisModule *this_mod);
winampVisModule *getVisModule(int which);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void resizeGLWindow(int width, int height);
typedef struct
{
winampVisHeader hdr; //
winampVisModule this_mod; //
HDC hDC; // holds the "canvas" of the window
HGLRC hRC; // holds the 3D OpenGL canvas of the window
HWND hWnd; // holds the handle of the window
bool keys[256]; // array of pressed keys at a certain point :0
embedWindowState myWindowState;
} winampGLVisualizer;
static winampGLVisualizer g_sVis =
{
{
VIS_HDRVER,
VIS_USER_TITLE,
getVisModule
},
{
VIS_USER_MODULE_TITLE,
NULL, // hwndParent
NULL, // hDllInstance
0, // sRate
0, // nCh
20, // latencyMS ( TODO: mess with this to fit your needs )
70, // delayMS ( TODO: mess with this to fit your needs )
2, // spectrumNch ( TODO: you can also mess with this )
2, // waveformNch ( TODO: you can also mess with this )
{ 0, }, // spectrumData
{ 0, }, // waveformData
visConfig,
visInit,
visRender,
visQuit
},
NULL,
NULL,
NULL,
{ 0, }, // keys
// embedWindowState struct
{NULL, 0, {0,0,0,0}, NULL, {0, }}
};
static winampGLVisualizer *g_pVis = &g_sVis;
winampGLVisualizer *getVisInstance()
{
return g_pVis;
}
winampVisModule *getVisModule(int which)
{
switch (which)
{
case 0: return &getVisInstance()->this_mod;
default:return NULL;
}
}
#ifdef __cplusplus
extern "C" {
#endif
__declspec( dllexport ) winampVisHeader *winampVisGetHeader()
{
return &getVisInstance()->hdr;
}
#ifdef __cplusplus
}
#endif
void resizeGLWindow(int width, int height)
{
if (height==0)
{
height=1;
}
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(float)width/(float)height,0.1f,VIS_SCENE_FOV);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
#endif /* !__VisFramework_h__ */