├── .gitignore
├── GLPlugin.jucer
├── JuceLibraryCode
├── AppConfig.h
├── BinaryData.cpp
├── BinaryData.h
├── JuceHeader.h
├── ReadMe.txt
├── include_juce_audio_basics.cpp
├── include_juce_audio_basics.mm
├── include_juce_audio_devices.cpp
├── include_juce_audio_devices.mm
├── include_juce_audio_formats.cpp
├── include_juce_audio_formats.mm
├── include_juce_audio_plugin_client_AAX.cpp
├── include_juce_audio_plugin_client_AAX.mm
├── include_juce_audio_plugin_client_AU.r
├── include_juce_audio_plugin_client_AU_1.mm
├── include_juce_audio_plugin_client_AU_2.mm
├── include_juce_audio_plugin_client_AUv3.mm
├── include_juce_audio_plugin_client_RTAS.r
├── include_juce_audio_plugin_client_RTAS_1.cpp
├── include_juce_audio_plugin_client_RTAS_2.cpp
├── include_juce_audio_plugin_client_RTAS_3.cpp
├── include_juce_audio_plugin_client_RTAS_4.cpp
├── include_juce_audio_plugin_client_RTAS_utils.cpp
├── include_juce_audio_plugin_client_RTAS_utils.mm
├── include_juce_audio_plugin_client_Standalone.cpp
├── include_juce_audio_plugin_client_Unity.cpp
├── include_juce_audio_plugin_client_VST2.cpp
├── include_juce_audio_plugin_client_VST3.cpp
├── include_juce_audio_plugin_client_VST_utils.mm
├── include_juce_audio_plugin_client_utils.cpp
├── include_juce_audio_processors.cpp
├── include_juce_audio_processors.mm
├── include_juce_audio_utils.cpp
├── include_juce_audio_utils.mm
├── include_juce_core.cpp
├── include_juce_core.mm
├── include_juce_cryptography.cpp
├── include_juce_cryptography.mm
├── include_juce_data_structures.cpp
├── include_juce_data_structures.mm
├── include_juce_events.cpp
├── include_juce_events.mm
├── include_juce_graphics.cpp
├── include_juce_graphics.mm
├── include_juce_gui_basics.cpp
├── include_juce_gui_basics.mm
├── include_juce_gui_extra.cpp
├── include_juce_gui_extra.mm
├── include_juce_opengl.cpp
├── include_juce_opengl.mm
├── include_juce_video.cpp
└── include_juce_video.mm
├── LICENSE
├── README.md
└── Source
├── Attributes.h
├── GLUtils.h
├── PluginEditor.cpp
├── PluginEditor.h
├── PluginProcessor.cpp
├── PluginProcessor.h
├── ShaderPreset.h
├── Shape.h
├── Textures.h
├── Uniforms.h
├── Vertex.h
├── WavefrontObjParser.h
├── pianokey_rectangle.obj
├── portmeirion.jpg
└── teapot.obj
/.gitignore:
--------------------------------------------------------------------------------
1 | *.DS_Store
2 | /Builds
3 | #GLPlugin_Logic.logicx
4 | /DemoContent
5 |
--------------------------------------------------------------------------------
/GLPlugin.jucer:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
35 |
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 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/JuceLibraryCode/AppConfig.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | There's a section below where you can add your own custom code safely, and the
7 | Projucer will preserve the contents of that block, but the best way to change
8 | any of these definitions is by using the Projucer's project settings.
9 |
10 | Any commented-out settings will assume their default values.
11 |
12 | */
13 |
14 | #pragma once
15 |
16 | //==============================================================================
17 | // [BEGIN_USER_CODE_SECTION]
18 |
19 | // (You can add your own code in this section, and the Projucer will not overwrite it)
20 |
21 | // [END_USER_CODE_SECTION]
22 |
23 | /*
24 | ==============================================================================
25 |
26 | In accordance with the terms of the JUCE 5 End-Use License Agreement, the
27 | JUCE Code in SECTION A cannot be removed, changed or otherwise rendered
28 | ineffective unless you have a JUCE Indie or Pro license, or are using JUCE
29 | under the GPL v3 license.
30 |
31 | End User License Agreement: www.juce.com/juce-5-licence
32 |
33 | ==============================================================================
34 | */
35 |
36 | // BEGIN SECTION A
37 |
38 | #ifndef JUCE_DISPLAY_SPLASH_SCREEN
39 | #define JUCE_DISPLAY_SPLASH_SCREEN 1
40 | #endif
41 |
42 | #ifndef JUCE_REPORT_APP_USAGE
43 | #define JUCE_REPORT_APP_USAGE 1
44 | #endif
45 |
46 | // END SECTION A
47 |
48 | #define JUCE_USE_DARK_SPLASH_SCREEN 1
49 |
50 | #define JUCE_PROJUCER_VERSION 0x50405
51 |
52 | //==============================================================================
53 | #define JUCE_MODULE_AVAILABLE_juce_audio_basics 1
54 | #define JUCE_MODULE_AVAILABLE_juce_audio_devices 1
55 | #define JUCE_MODULE_AVAILABLE_juce_audio_formats 1
56 | #define JUCE_MODULE_AVAILABLE_juce_audio_plugin_client 1
57 | #define JUCE_MODULE_AVAILABLE_juce_audio_processors 1
58 | #define JUCE_MODULE_AVAILABLE_juce_audio_utils 1
59 | #define JUCE_MODULE_AVAILABLE_juce_core 1
60 | #define JUCE_MODULE_AVAILABLE_juce_cryptography 1
61 | #define JUCE_MODULE_AVAILABLE_juce_data_structures 1
62 | #define JUCE_MODULE_AVAILABLE_juce_events 1
63 | #define JUCE_MODULE_AVAILABLE_juce_graphics 1
64 | #define JUCE_MODULE_AVAILABLE_juce_gui_basics 1
65 | #define JUCE_MODULE_AVAILABLE_juce_gui_extra 1
66 | #define JUCE_MODULE_AVAILABLE_juce_opengl 1
67 | #define JUCE_MODULE_AVAILABLE_juce_video 1
68 |
69 | #define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED 1
70 |
71 | //==============================================================================
72 | // juce_audio_devices flags:
73 |
74 | #ifndef JUCE_USE_WINRT_MIDI
75 | //#define JUCE_USE_WINRT_MIDI 0
76 | #endif
77 |
78 | #ifndef JUCE_ASIO
79 | //#define JUCE_ASIO 0
80 | #endif
81 |
82 | #ifndef JUCE_WASAPI
83 | //#define JUCE_WASAPI 1
84 | #endif
85 |
86 | #ifndef JUCE_WASAPI_EXCLUSIVE
87 | //#define JUCE_WASAPI_EXCLUSIVE 0
88 | #endif
89 |
90 | #ifndef JUCE_DIRECTSOUND
91 | //#define JUCE_DIRECTSOUND 1
92 | #endif
93 |
94 | #ifndef JUCE_ALSA
95 | //#define JUCE_ALSA 1
96 | #endif
97 |
98 | #ifndef JUCE_JACK
99 | //#define JUCE_JACK 0
100 | #endif
101 |
102 | #ifndef JUCE_BELA
103 | //#define JUCE_BELA 0
104 | #endif
105 |
106 | #ifndef JUCE_USE_ANDROID_OBOE
107 | //#define JUCE_USE_ANDROID_OBOE 0
108 | #endif
109 |
110 | #ifndef JUCE_USE_ANDROID_OPENSLES
111 | //#define JUCE_USE_ANDROID_OPENSLES 0
112 | #endif
113 |
114 | #ifndef JUCE_DISABLE_AUDIO_MIXING_WITH_OTHER_APPS
115 | //#define JUCE_DISABLE_AUDIO_MIXING_WITH_OTHER_APPS 0
116 | #endif
117 |
118 | //==============================================================================
119 | // juce_audio_formats flags:
120 |
121 | #ifndef JUCE_USE_FLAC
122 | //#define JUCE_USE_FLAC 1
123 | #endif
124 |
125 | #ifndef JUCE_USE_OGGVORBIS
126 | //#define JUCE_USE_OGGVORBIS 1
127 | #endif
128 |
129 | #ifndef JUCE_USE_MP3AUDIOFORMAT
130 | //#define JUCE_USE_MP3AUDIOFORMAT 0
131 | #endif
132 |
133 | #ifndef JUCE_USE_LAME_AUDIO_FORMAT
134 | //#define JUCE_USE_LAME_AUDIO_FORMAT 0
135 | #endif
136 |
137 | #ifndef JUCE_USE_WINDOWS_MEDIA_FORMAT
138 | //#define JUCE_USE_WINDOWS_MEDIA_FORMAT 1
139 | #endif
140 |
141 | //==============================================================================
142 | // juce_audio_plugin_client flags:
143 |
144 | #ifndef JUCE_VST3_CAN_REPLACE_VST2
145 | //#define JUCE_VST3_CAN_REPLACE_VST2 1
146 | #endif
147 |
148 | #ifndef JUCE_FORCE_USE_LEGACY_PARAM_IDS
149 | //#define JUCE_FORCE_USE_LEGACY_PARAM_IDS 0
150 | #endif
151 |
152 | #ifndef JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE
153 | //#define JUCE_FORCE_LEGACY_PARAMETER_AUTOMATION_TYPE 0
154 | #endif
155 |
156 | #ifndef JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS
157 | //#define JUCE_USE_STUDIO_ONE_COMPATIBLE_PARAMETERS 1
158 | #endif
159 |
160 | #ifndef JUCE_STANDALONE_FILTER_WINDOW_USE_KIOSK_MODE
161 | //#define JUCE_STANDALONE_FILTER_WINDOW_USE_KIOSK_MODE 0
162 | #endif
163 |
164 | //==============================================================================
165 | // juce_audio_processors flags:
166 |
167 | #ifndef JUCE_PLUGINHOST_VST
168 | //#define JUCE_PLUGINHOST_VST 0
169 | #endif
170 |
171 | #ifndef JUCE_PLUGINHOST_VST3
172 | //#define JUCE_PLUGINHOST_VST3 0
173 | #endif
174 |
175 | #ifndef JUCE_PLUGINHOST_AU
176 | //#define JUCE_PLUGINHOST_AU 0
177 | #endif
178 |
179 | #ifndef JUCE_PLUGINHOST_LADSPA
180 | //#define JUCE_PLUGINHOST_LADSPA 0
181 | #endif
182 |
183 | //==============================================================================
184 | // juce_audio_utils flags:
185 |
186 | #ifndef JUCE_USE_CDREADER
187 | //#define JUCE_USE_CDREADER 0
188 | #endif
189 |
190 | #ifndef JUCE_USE_CDBURNER
191 | //#define JUCE_USE_CDBURNER 0
192 | #endif
193 |
194 | //==============================================================================
195 | // juce_core flags:
196 |
197 | #ifndef JUCE_FORCE_DEBUG
198 | //#define JUCE_FORCE_DEBUG 0
199 | #endif
200 |
201 | #ifndef JUCE_LOG_ASSERTIONS
202 | //#define JUCE_LOG_ASSERTIONS 0
203 | #endif
204 |
205 | #ifndef JUCE_CHECK_MEMORY_LEAKS
206 | //#define JUCE_CHECK_MEMORY_LEAKS 1
207 | #endif
208 |
209 | #ifndef JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
210 | //#define JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES 0
211 | #endif
212 |
213 | #ifndef JUCE_INCLUDE_ZLIB_CODE
214 | //#define JUCE_INCLUDE_ZLIB_CODE 1
215 | #endif
216 |
217 | #ifndef JUCE_USE_CURL
218 | //#define JUCE_USE_CURL 1
219 | #endif
220 |
221 | #ifndef JUCE_LOAD_CURL_SYMBOLS_LAZILY
222 | //#define JUCE_LOAD_CURL_SYMBOLS_LAZILY 0
223 | #endif
224 |
225 | #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS
226 | //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 0
227 | #endif
228 |
229 | #ifndef JUCE_ALLOW_STATIC_NULL_VARIABLES
230 | //#define JUCE_ALLOW_STATIC_NULL_VARIABLES 0
231 | #endif
232 |
233 | #ifndef JUCE_STRICT_REFCOUNTEDPOINTER
234 | //#define JUCE_STRICT_REFCOUNTEDPOINTER 0
235 | #endif
236 |
237 | //==============================================================================
238 | // juce_events flags:
239 |
240 | #ifndef JUCE_EXECUTE_APP_SUSPEND_ON_IOS_BACKGROUND_TASK
241 | //#define JUCE_EXECUTE_APP_SUSPEND_ON_IOS_BACKGROUND_TASK 0
242 | #endif
243 |
244 | //==============================================================================
245 | // juce_graphics flags:
246 |
247 | #ifndef JUCE_USE_COREIMAGE_LOADER
248 | //#define JUCE_USE_COREIMAGE_LOADER 1
249 | #endif
250 |
251 | #ifndef JUCE_USE_DIRECTWRITE
252 | //#define JUCE_USE_DIRECTWRITE 1
253 | #endif
254 |
255 | #ifndef JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING
256 | //#define JUCE_DISABLE_COREGRAPHICS_FONT_SMOOTHING 0
257 | #endif
258 |
259 | //==============================================================================
260 | // juce_gui_basics flags:
261 |
262 | #ifndef JUCE_ENABLE_REPAINT_DEBUGGING
263 | //#define JUCE_ENABLE_REPAINT_DEBUGGING 0
264 | #endif
265 |
266 | #ifndef JUCE_USE_XRANDR
267 | //#define JUCE_USE_XRANDR 1
268 | #endif
269 |
270 | #ifndef JUCE_USE_XINERAMA
271 | //#define JUCE_USE_XINERAMA 1
272 | #endif
273 |
274 | #ifndef JUCE_USE_XSHM
275 | //#define JUCE_USE_XSHM 1
276 | #endif
277 |
278 | #ifndef JUCE_USE_XRENDER
279 | //#define JUCE_USE_XRENDER 0
280 | #endif
281 |
282 | #ifndef JUCE_USE_XCURSOR
283 | //#define JUCE_USE_XCURSOR 1
284 | #endif
285 |
286 | #ifndef JUCE_WIN_PER_MONITOR_DPI_AWARE
287 | //#define JUCE_WIN_PER_MONITOR_DPI_AWARE 1
288 | #endif
289 |
290 | //==============================================================================
291 | // juce_gui_extra flags:
292 |
293 | #ifndef JUCE_WEB_BROWSER
294 | //#define JUCE_WEB_BROWSER 1
295 | #endif
296 |
297 | #ifndef JUCE_ENABLE_LIVE_CONSTANT_EDITOR
298 | //#define JUCE_ENABLE_LIVE_CONSTANT_EDITOR 0
299 | #endif
300 |
301 | //==============================================================================
302 | // juce_video flags:
303 |
304 | #ifndef JUCE_USE_CAMERA
305 | //#define JUCE_USE_CAMERA 0
306 | #endif
307 |
308 | #ifndef JUCE_SYNC_VIDEO_VOLUME_WITH_OS_MEDIA_VOLUME
309 | //#define JUCE_SYNC_VIDEO_VOLUME_WITH_OS_MEDIA_VOLUME 1
310 | #endif
311 |
312 | //==============================================================================
313 | // Audio plugin settings..
314 |
315 | #ifndef JucePlugin_Build_VST
316 | #define JucePlugin_Build_VST 0
317 | #endif
318 | #ifndef JucePlugin_Build_VST3
319 | #define JucePlugin_Build_VST3 0
320 | #endif
321 | #ifndef JucePlugin_Build_AU
322 | #define JucePlugin_Build_AU 1
323 | #endif
324 | #ifndef JucePlugin_Build_AUv3
325 | #define JucePlugin_Build_AUv3 0
326 | #endif
327 | #ifndef JucePlugin_Build_RTAS
328 | #define JucePlugin_Build_RTAS 0
329 | #endif
330 | #ifndef JucePlugin_Build_AAX
331 | #define JucePlugin_Build_AAX 0
332 | #endif
333 | #ifndef JucePlugin_Build_Standalone
334 | #define JucePlugin_Build_Standalone 1
335 | #endif
336 | #ifndef JucePlugin_Build_Unity
337 | #define JucePlugin_Build_Unity 0
338 | #endif
339 | #ifndef JucePlugin_Enable_IAA
340 | #define JucePlugin_Enable_IAA 0
341 | #endif
342 | #ifndef JucePlugin_Name
343 | #define JucePlugin_Name "GLPlugin"
344 | #endif
345 | #ifndef JucePlugin_Desc
346 | #define JucePlugin_Desc "GLPlugin"
347 | #endif
348 | #ifndef JucePlugin_Manufacturer
349 | #define JucePlugin_Manufacturer "yourcompany"
350 | #endif
351 | #ifndef JucePlugin_ManufacturerWebsite
352 | #define JucePlugin_ManufacturerWebsite ""
353 | #endif
354 | #ifndef JucePlugin_ManufacturerEmail
355 | #define JucePlugin_ManufacturerEmail ""
356 | #endif
357 | #ifndef JucePlugin_ManufacturerCode
358 | #define JucePlugin_ManufacturerCode 0x4d616e75 // 'Manu'
359 | #endif
360 | #ifndef JucePlugin_PluginCode
361 | #define JucePlugin_PluginCode 0x58673264 // 'Xg2d'
362 | #endif
363 | #ifndef JucePlugin_IsSynth
364 | #define JucePlugin_IsSynth 0
365 | #endif
366 | #ifndef JucePlugin_WantsMidiInput
367 | #define JucePlugin_WantsMidiInput 1
368 | #endif
369 | #ifndef JucePlugin_ProducesMidiOutput
370 | #define JucePlugin_ProducesMidiOutput 1
371 | #endif
372 | #ifndef JucePlugin_IsMidiEffect
373 | #define JucePlugin_IsMidiEffect 0
374 | #endif
375 | #ifndef JucePlugin_EditorRequiresKeyboardFocus
376 | #define JucePlugin_EditorRequiresKeyboardFocus 0
377 | #endif
378 | #ifndef JucePlugin_Version
379 | #define JucePlugin_Version 1.0.0
380 | #endif
381 | #ifndef JucePlugin_VersionCode
382 | #define JucePlugin_VersionCode 0x10000
383 | #endif
384 | #ifndef JucePlugin_VersionString
385 | #define JucePlugin_VersionString "1.0.0"
386 | #endif
387 | #ifndef JucePlugin_VSTUniqueID
388 | #define JucePlugin_VSTUniqueID JucePlugin_PluginCode
389 | #endif
390 | #ifndef JucePlugin_VSTCategory
391 | #define JucePlugin_VSTCategory kPlugCategEffect
392 | #endif
393 | #ifndef JucePlugin_Vst3Category
394 | #define JucePlugin_Vst3Category "Fx"
395 | #endif
396 | #ifndef JucePlugin_AUMainType
397 | #define JucePlugin_AUMainType 'aumf'
398 | #endif
399 | #ifndef JucePlugin_AUSubType
400 | #define JucePlugin_AUSubType JucePlugin_PluginCode
401 | #endif
402 | #ifndef JucePlugin_AUExportPrefix
403 | #define JucePlugin_AUExportPrefix GLPluginAU
404 | #endif
405 | #ifndef JucePlugin_AUExportPrefixQuoted
406 | #define JucePlugin_AUExportPrefixQuoted "GLPluginAU"
407 | #endif
408 | #ifndef JucePlugin_AUManufacturerCode
409 | #define JucePlugin_AUManufacturerCode JucePlugin_ManufacturerCode
410 | #endif
411 | #ifndef JucePlugin_CFBundleIdentifier
412 | #define JucePlugin_CFBundleIdentifier com.yourcompany.GLPlugin
413 | #endif
414 | #ifndef JucePlugin_RTASCategory
415 | #define JucePlugin_RTASCategory 0
416 | #endif
417 | #ifndef JucePlugin_RTASManufacturerCode
418 | #define JucePlugin_RTASManufacturerCode JucePlugin_ManufacturerCode
419 | #endif
420 | #ifndef JucePlugin_RTASProductId
421 | #define JucePlugin_RTASProductId JucePlugin_PluginCode
422 | #endif
423 | #ifndef JucePlugin_RTASDisableBypass
424 | #define JucePlugin_RTASDisableBypass 0
425 | #endif
426 | #ifndef JucePlugin_RTASDisableMultiMono
427 | #define JucePlugin_RTASDisableMultiMono 0
428 | #endif
429 | #ifndef JucePlugin_AAXIdentifier
430 | #define JucePlugin_AAXIdentifier com.yourcompany.GLPlugin
431 | #endif
432 | #ifndef JucePlugin_AAXManufacturerCode
433 | #define JucePlugin_AAXManufacturerCode JucePlugin_ManufacturerCode
434 | #endif
435 | #ifndef JucePlugin_AAXProductId
436 | #define JucePlugin_AAXProductId JucePlugin_PluginCode
437 | #endif
438 | #ifndef JucePlugin_AAXCategory
439 | #define JucePlugin_AAXCategory 2
440 | #endif
441 | #ifndef JucePlugin_AAXDisableBypass
442 | #define JucePlugin_AAXDisableBypass 0
443 | #endif
444 | #ifndef JucePlugin_AAXDisableMultiMono
445 | #define JucePlugin_AAXDisableMultiMono 0
446 | #endif
447 | #ifndef JucePlugin_IAAType
448 | #define JucePlugin_IAAType 0x6175726d // 'aurm'
449 | #endif
450 | #ifndef JucePlugin_IAASubType
451 | #define JucePlugin_IAASubType JucePlugin_PluginCode
452 | #endif
453 | #ifndef JucePlugin_IAAName
454 | #define JucePlugin_IAAName "yourcompany: GLPlugin"
455 | #endif
456 | #ifndef JucePlugin_VSTNumMidiInputs
457 | #define JucePlugin_VSTNumMidiInputs 16
458 | #endif
459 | #ifndef JucePlugin_VSTNumMidiOutputs
460 | #define JucePlugin_VSTNumMidiOutputs 16
461 | #endif
462 |
463 | //==============================================================================
464 | #ifndef JUCE_STANDALONE_APPLICATION
465 | #if defined(JucePlugin_Name) && defined(JucePlugin_Build_Standalone)
466 | #define JUCE_STANDALONE_APPLICATION JucePlugin_Build_Standalone
467 | #else
468 | #define JUCE_STANDALONE_APPLICATION 0
469 | #endif
470 | #endif
471 |
--------------------------------------------------------------------------------
/JuceLibraryCode/BinaryData.h:
--------------------------------------------------------------------------------
1 | /* =========================================================================================
2 |
3 | This is an auto-generated file: Any edits you make may be overwritten!
4 |
5 | */
6 |
7 | #pragma once
8 |
9 | namespace BinaryData
10 | {
11 | extern const char* portmeirion_jpg;
12 | const int portmeirion_jpgSize = 145904;
13 |
14 | extern const char* teapot_obj;
15 | const int teapot_objSize = 95004;
16 |
17 | extern const char* pianokey_rectangle_obj;
18 | const int pianokey_rectangle_objSize = 417;
19 |
20 | // Number of elements in the namedResourceList and originalFileNames arrays.
21 | const int namedResourceListSize = 3;
22 |
23 | // Points to the start of a list of resource names.
24 | extern const char* namedResourceList[];
25 |
26 | // Points to the start of a list of resource filenames.
27 | extern const char* originalFilenames[];
28 |
29 | // If you provide the name of one of the binary resource variables above, this function will
30 | // return the corresponding data and its size (or a null pointer if the name isn't found).
31 | const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes);
32 |
33 | // If you provide the name of one of the binary resource variables above, this function will
34 | // return the corresponding original, non-mangled filename (or a null pointer if the name isn't found).
35 | const char* getNamedResourceOriginalFilename (const char* resourceNameUTF8);
36 | }
37 |
--------------------------------------------------------------------------------
/JuceLibraryCode/JuceHeader.h:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | This is the header file that your files should include in order to get all the
7 | JUCE library headers. You should avoid including the JUCE headers directly in
8 | your own source files, because that wouldn't pick up the correct configuration
9 | options for your app.
10 |
11 | */
12 |
13 | #pragma once
14 |
15 | #include "AppConfig.h"
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #include "BinaryData.h"
34 |
35 | #if defined (JUCE_PROJUCER_VERSION) && JUCE_PROJUCER_VERSION < JUCE_VERSION
36 | /** If you've hit this error then the version of the Projucer that was used to generate this project is
37 | older than the version of the JUCE modules being included. To fix this error, re-save your project
38 | using the latest version of the Projucer or, if you aren't using the Projucer to manage your project,
39 | remove the JUCE_PROJUCER_VERSION define from the AppConfig.h file.
40 | */
41 | #error "This project was last saved using an outdated version of the Projucer! Re-save this project with the latest version to fix this error."
42 | #endif
43 |
44 | #if ! DONT_SET_USING_JUCE_NAMESPACE
45 | // If your code uses a lot of JUCE classes, then this will obviously save you
46 | // a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE.
47 | using namespace juce;
48 | #endif
49 |
50 | #if ! JUCE_DONT_DECLARE_PROJECTINFO
51 | namespace ProjectInfo
52 | {
53 | const char* const projectName = "GLPlugin";
54 | const char* const companyName = "";
55 | const char* const versionString = "1.0.0";
56 | const int versionNumber = 0x10000;
57 | }
58 | #endif
59 |
--------------------------------------------------------------------------------
/JuceLibraryCode/ReadMe.txt:
--------------------------------------------------------------------------------
1 |
2 | Important Note!!
3 | ================
4 |
5 | The purpose of this folder is to contain files that are auto-generated by the Projucer,
6 | and ALL files in this folder will be mercilessly DELETED and completely re-written whenever
7 | the Projucer saves your project.
8 |
9 | Therefore, it's a bad idea to make any manual changes to the files in here, or to
10 | put any of your own files in here if you don't want to lose them. (Of course you may choose
11 | to add the folder's contents to your version-control system so that you can re-merge your own
12 | modifications after the Projucer has saved its changes).
13 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_basics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_basics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_devices.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_devices.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_formats.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_formats.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AAX.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AAX.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AU.r:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AU_1.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AU_2.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_AUv3.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS.r:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_1.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_4.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_RTAS_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_Standalone.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_Unity.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_VST2.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_VST_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_plugin_client_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_processors.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_processors.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_utils.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_audio_utils.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_core.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_core.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_cryptography.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_cryptography.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_data_structures.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_data_structures.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_events.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_events.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_graphics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_graphics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_gui_basics.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_gui_basics.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_gui_extra.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_gui_extra.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_opengl.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_opengl.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_video.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/JuceLibraryCode/include_juce_video.mm:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | IMPORTANT! This file is auto-generated each time you save your
4 | project - if you alter its contents, your changes may be overwritten!
5 |
6 | */
7 |
8 | #include "AppConfig.h"
9 | #include
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Ross Hoyt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Spiral Array 3D Visualizer Plugin - C++, JUCE, OpenGL
2 |
3 | A 3D MIDI visualizer that listens to incoming MIDI and generates a 3D visualization using the helix 'Spiral-Array' model rendered with OpenGL. A full video demonstration of the plugin can be viewed [here!](https://www.youtube.com/watch?v=Tsdqzs6BkKM)
4 |
5 | 
6 |
7 | ## References:
8 | [Chew, Elaine & Chen, Y.-C. (2002). Mapping Midi to the Spiral Array: Disambiguating Pitch Spellings. 21. 10.1007/978-1-4615-1043-7_13.](https://www.academia.edu/31215169/Mapping_midi_to_the_spiral_array_Disambiguating_pitch_spellings).
9 |
--------------------------------------------------------------------------------
/Source/Attributes.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Attributes.h
6 | This class manages the attributes that the shaders use
7 | ==============================================================================
8 | */
9 |
10 | #pragma once
11 | #include "Vertex.h"
12 |
13 | //==============================================================================
14 | struct Attributes
15 | {
16 | Attributes (OpenGLContext& openGLContext, OpenGLShaderProgram& shader)
17 | {
18 | position = createAttribute (openGLContext, shader, "position");
19 | normal = createAttribute (openGLContext, shader, "normal");
20 | sourceColour = createAttribute (openGLContext, shader, "sourceColour");
21 | texureCoordIn = createAttribute (openGLContext, shader, "texureCoordIn");
22 | }
23 |
24 | void enable (OpenGLContext& openGLContext)
25 | {
26 | if (position != nullptr)
27 | {
28 | openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0);
29 | openGLContext.extensions.glEnableVertexAttribArray (position->attributeID);
30 | }
31 |
32 | if (normal != nullptr)
33 | {
34 | openGLContext.extensions.glVertexAttribPointer (normal->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), (GLvoid*) (sizeof (float) * 3));
35 | openGLContext.extensions.glEnableVertexAttribArray (normal->attributeID);
36 | }
37 |
38 | if (sourceColour != nullptr)
39 | {
40 | openGLContext.extensions.glVertexAttribPointer (sourceColour->attributeID, 4, GL_FLOAT, GL_FALSE, sizeof (Vertex), (GLvoid*) (sizeof (float) * 6));
41 | openGLContext.extensions.glEnableVertexAttribArray (sourceColour->attributeID);
42 | }
43 |
44 | if (texureCoordIn != nullptr)
45 | {
46 | openGLContext.extensions.glVertexAttribPointer (texureCoordIn->attributeID, 2, GL_FLOAT, GL_FALSE, sizeof (Vertex), (GLvoid*) (sizeof (float) * 10));
47 | openGLContext.extensions.glEnableVertexAttribArray (texureCoordIn->attributeID);
48 | }
49 | }
50 |
51 | void disable (OpenGLContext& openGLContext)
52 | {
53 | if (position != nullptr) openGLContext.extensions.glDisableVertexAttribArray (position->attributeID);
54 | if (normal != nullptr) openGLContext.extensions.glDisableVertexAttribArray (normal->attributeID);
55 | if (sourceColour != nullptr) openGLContext.extensions.glDisableVertexAttribArray (sourceColour->attributeID);
56 | if (texureCoordIn != nullptr) openGLContext.extensions.glDisableVertexAttribArray (texureCoordIn->attributeID);
57 | }
58 |
59 | ScopedPointer position, normal, sourceColour, texureCoordIn;
60 |
61 | private:
62 | static OpenGLShaderProgram::Attribute* createAttribute (OpenGLContext& openGLContext,
63 | OpenGLShaderProgram& shader,
64 | const char* attributeName)
65 | {
66 | if (openGLContext.extensions.glGetAttribLocation (shader.getProgramID(), attributeName) < 0)
67 | return nullptr;
68 |
69 | return new OpenGLShaderProgram::Attribute (shader, attributeName);
70 | }
71 | };
72 |
--------------------------------------------------------------------------------
/Source/GLUtils.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Utility.h
6 |
7 |
8 | ==============================================================================
9 | */
10 |
11 | #pragma once
12 | #include "ShaderPreset.h"
13 |
14 | static Image resizeImageToPowerOfTwo (Image image)
15 | {
16 | if (! (isPowerOfTwo (image.getWidth()) && isPowerOfTwo (image.getHeight())))
17 | return image.rescaled (jmin (1024, nextPowerOfTwo (image.getWidth())),
18 | jmin (1024, nextPowerOfTwo (image.getHeight())));
19 |
20 | return image;
21 | }
22 |
23 | static Array getShaderPresets()
24 | {
25 | ShaderPreset presets[] =
26 | {
27 | {
28 | "Spiral Array Shader",
29 |
30 | "attribute vec4 position;\n"
31 | "attribute vec4 sourceColour;\n"
32 | "attribute vec2 textureCoordIn;\n"
33 | "\n"
34 | "uniform mat4 projectionMatrix;\n"
35 | "uniform mat4 viewMatrix;\n"
36 | "\n"
37 | "varying vec4 destinationColour;\n"
38 | "varying vec2 textureCoordOut;\n"
39 | "\n"
40 | "varying float xPos;\n"
41 | "varying float yPos;\n"
42 | "varying float zPos;\n"
43 | "\n"
44 | "void main()\n"
45 | "{\n"
46 | " vec4 v = vec4 (position);\n"
47 | " xPos = clamp (v.x, 0.0, 1.0);\n"
48 | " yPos = clamp (v.y, 0.0, 1.0);\n"
49 | " zPos = clamp (v.z, 0.0, 1.0);\n"
50 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
51 | "}",
52 |
53 |
54 | #if JUCE_OPENGL_ES
55 | "varying lowp vec4 destinationColour;\n"
56 | "varying lowp vec2 textureCoordOut;\n"
57 | "varying lowp float xPos;\n"
58 | "varying lowp float yPos;\n"
59 | "varying lowp float zPos;\n"
60 | #else
61 | "varying vec4 destinationColour;\n"
62 | "varying vec2 textureCoordOut;\n"
63 | "varying float xPos;\n"
64 | "varying float yPos;\n"
65 | "varying float zPos;\n"
66 | #endif
67 | "\n"
68 | "void main()\n"
69 | "{\n"
70 | " gl_FragColor = vec4 (xPos, yPos, zPos, 1.0);\n"
71 | "}"
72 | },
73 |
74 | {
75 | "Texture + Lighting",
76 |
77 |
78 | "attribute vec4 position;\n"
79 | "attribute vec4 normal;\n"
80 | "attribute vec4 sourceColour;\n"
81 | "attribute vec2 textureCoordIn;\n"
82 | "\n"
83 | "uniform mat4 projectionMatrix;\n"
84 | "uniform mat4 viewMatrix;\n"
85 | "uniform vec4 lightPosition;\n"
86 | "\n"
87 | "varying vec4 destinationColour;\n"
88 | "varying vec2 textureCoordOut;\n"
89 | "varying float lightIntensity;\n"
90 | "\n"
91 | "void main()\n"
92 | "{\n"
93 | " destinationColour = sourceColour;\n"
94 | " textureCoordOut = textureCoordIn;\n"
95 | "\n"
96 | " vec4 light = viewMatrix * lightPosition;\n"
97 | " lightIntensity = dot (light, normal);\n"
98 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
99 | "}\n",
100 |
101 |
102 | #if JUCE_OPENGL_ES
103 | "varying lowp vec4 destinationColour;\n"
104 | "varying lowp vec2 textureCoordOut;\n"
105 | "varying highp float lightIntensity;\n"
106 | #else
107 | "varying vec4 destinationColour;\n"
108 | "varying vec2 textureCoordOut;\n"
109 | "varying float lightIntensity;\n"
110 | #endif
111 | "\n"
112 | "uniform sampler2D demoTexture;\n"
113 | "\n"
114 | "void main()\n"
115 | "{\n"
116 | #if JUCE_OPENGL_ES
117 | " highp float l = max (0.3, lightIntensity * 0.3);\n"
118 | " highp vec4 colour = vec4 (l, l, l, 1.0);\n"
119 | #else
120 | " float l = max (0.3, lightIntensity * 0.3);\n"
121 | " vec4 colour = vec4 (l, l, l, 1.0);\n"
122 | #endif
123 | " gl_FragColor = colour * texture2D (demoTexture, textureCoordOut);\n"
124 | "}\n"
125 | },
126 |
127 | {
128 | "Textured",
129 |
130 |
131 | "attribute vec4 position;\n"
132 | "attribute vec4 sourceColour;\n"
133 | "attribute vec2 textureCoordIn;\n"
134 | "\n"
135 | "uniform mat4 projectionMatrix;\n"
136 | "uniform mat4 viewMatrix;\n"
137 | "\n"
138 | "varying vec4 destinationColour;\n"
139 | "varying vec2 textureCoordOut;\n"
140 | "\n"
141 | "void main()\n"
142 | "{\n"
143 | " destinationColour = sourceColour;\n"
144 | " textureCoordOut = textureCoordIn;\n"
145 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
146 | "}\n",
147 |
148 |
149 | #if JUCE_OPENGL_ES
150 | "varying lowp vec4 destinationColour;\n"
151 | "varying lowp vec2 textureCoordOut;\n"
152 | #else
153 | "varying vec4 destinationColour;\n"
154 | "varying vec2 textureCoordOut;\n"
155 | #endif
156 | "\n"
157 | "uniform sampler2D demoTexture;\n"
158 | "\n"
159 | "void main()\n"
160 | "{\n"
161 | " gl_FragColor = texture2D (demoTexture, textureCoordOut);\n"
162 | "}\n"
163 | },
164 |
165 | {
166 | "Flat Colour",
167 |
168 |
169 | "attribute vec4 position;\n"
170 | "attribute vec4 sourceColour;\n"
171 | "attribute vec2 textureCoordIn;\n"
172 | "\n"
173 | "uniform mat4 projectionMatrix;\n"
174 | "uniform mat4 viewMatrix;\n"
175 | "\n"
176 | "varying vec4 destinationColour;\n"
177 | "varying vec2 textureCoordOut;\n"
178 | "\n"
179 | "void main()\n"
180 | "{\n"
181 | " destinationColour = sourceColour;\n"
182 | " textureCoordOut = textureCoordIn;\n"
183 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
184 | "}\n",
185 |
186 |
187 | #if JUCE_OPENGL_ES
188 | "varying lowp vec4 destinationColour;\n"
189 | "varying lowp vec2 textureCoordOut;\n"
190 | #else
191 | "varying vec4 destinationColour;\n"
192 | "varying vec2 textureCoordOut;\n"
193 | #endif
194 | "\n"
195 | "void main()\n"
196 | "{\n"
197 | " gl_FragColor = destinationColour;\n"
198 | "}\n"
199 | },
200 |
201 | {
202 | "Rainbow",
203 |
204 |
205 | "attribute vec4 position;\n"
206 | "attribute vec4 sourceColour;\n"
207 | "attribute vec2 textureCoordIn;\n"
208 | "\n"
209 | "uniform mat4 projectionMatrix;\n"
210 | "uniform mat4 viewMatrix;\n"
211 | "\n"
212 | "varying vec4 destinationColour;\n"
213 | "varying vec2 textureCoordOut;\n"
214 | "\n"
215 | "varying float xPos;\n"
216 | "varying float yPos;\n"
217 | "varying float zPos;\n"
218 | "\n"
219 | "void main()\n"
220 | "{\n"
221 | " vec4 v = vec4 (position);\n"
222 | " xPos = clamp (v.x, 0.0, 1.0);\n"
223 | " yPos = clamp (v.y, 0.0, 1.0);\n"
224 | " zPos = clamp (v.z, 0.0, 1.0);\n"
225 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
226 | "}",
227 |
228 |
229 | #if JUCE_OPENGL_ES
230 | "varying lowp vec4 destinationColour;\n"
231 | "varying lowp vec2 textureCoordOut;\n"
232 | "varying lowp float xPos;\n"
233 | "varying lowp float yPos;\n"
234 | "varying lowp float zPos;\n"
235 | #else
236 | "varying vec4 destinationColour;\n"
237 | "varying vec2 textureCoordOut;\n"
238 | "varying float xPos;\n"
239 | "varying float yPos;\n"
240 | "varying float zPos;\n"
241 | #endif
242 | "\n"
243 | "void main()\n"
244 | "{\n"
245 | " gl_FragColor = vec4 (xPos, yPos, zPos, 1.0);\n"
246 | "}"
247 | },
248 |
249 | {
250 | "Changing Colour",
251 | "attribute vec4 position;\n"
252 | "attribute vec2 textureCoordIn;\n"
253 | "\n"
254 | "uniform mat4 projectionMatrix;\n"
255 | "uniform mat4 viewMatrix;\n"
256 | "\n"
257 | "varying vec2 textureCoordOut;\n"
258 | "\n"
259 | "void main()\n"
260 | "{\n"
261 | " textureCoordOut = textureCoordIn;\n"
262 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
263 | " //(projectionMatrix + mat4(gl_InstanceID, 1, 1, 1))\n"
264 | " int id = gl_InstanceID;\n"
265 | "}\n",
266 |
267 |
268 | "#define PI 3.1415926535897932384626433832795\n"
269 | "\n"
270 | #if JUCE_OPENGL_ES
271 | "precision mediump float;\n"
272 | "varying lowp vec2 textureCoordOut;\n"
273 | #else
274 | "varying vec2 textureCoordOut;\n"
275 | #endif
276 | "uniform float bouncingNumber;\n"
277 | "\n"
278 | "void main()\n"
279 | "{\n"
280 | " float b = bouncingNumber;\n"
281 | " float n = b * PI * 2.0;\n"
282 | " float sn = (sin (n * textureCoordOut.x) * 0.5) + 0.5;\n"
283 | " float cn = (sin (n * textureCoordOut.y) * 0.5) + 0.5;\n"
284 | "\n"
285 | " vec4 col = vec4 (b, sn, cn, 1.0);\n"
286 | " gl_FragColor = col;\n"
287 | "}\n"
288 | },
289 |
290 | {
291 | "Simple Light",
292 |
293 |
294 | "attribute vec4 position;\n"
295 | "attribute vec4 normal;\n"
296 | "\n"
297 | "uniform mat4 projectionMatrix;\n"
298 | "uniform mat4 viewMatrix;\n"
299 | "uniform vec4 lightPosition;\n"
300 | "\n"
301 | "varying float lightIntensity;\n"
302 | "\n"
303 | "void main()\n"
304 | "{\n"
305 | " vec4 light = viewMatrix * lightPosition;\n"
306 | " lightIntensity = dot (light, normal);\n"
307 | "\n"
308 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
309 | "}\n",
310 |
311 |
312 | #if JUCE_OPENGL_ES
313 | "varying highp float lightIntensity;\n"
314 | #else
315 | "varying float lightIntensity;\n"
316 | #endif
317 | "\n"
318 | "void main()\n"
319 | "{\n"
320 | #if JUCE_OPENGL_ES
321 | " highp float l = lightIntensity * 0.25;\n"
322 | " highp vec4 colour = vec4 (l, l, l, 1.0);\n"
323 | #else
324 | " float l = lightIntensity * 0.25;\n"
325 | " vec4 colour = vec4 (l, l, l, 1.0);\n"
326 | #endif
327 | "\n"
328 | " gl_FragColor = colour;\n"
329 | "}\n"
330 | },
331 |
332 | {
333 | "Flattened",
334 |
335 |
336 | "attribute vec4 position;\n"
337 | "attribute vec4 normal;\n"
338 | "\n"
339 | "uniform mat4 projectionMatrix;\n"
340 | "uniform mat4 viewMatrix;\n"
341 | "uniform vec4 lightPosition;\n"
342 | "\n"
343 | "varying float lightIntensity;\n"
344 | "\n"
345 | "void main()\n"
346 | "{\n"
347 | " vec4 light = viewMatrix * lightPosition;\n"
348 | " lightIntensity = dot (light, normal);\n"
349 | "\n"
350 | " vec4 v = vec4 (position);\n"
351 | " v.z = v.z * 0.1;\n"
352 | "\n"
353 | " gl_Position = projectionMatrix * viewMatrix * v;\n"
354 | "}\n",
355 |
356 |
357 | #if JUCE_OPENGL_ES
358 | "varying highp float lightIntensity;\n"
359 | #else
360 | "varying float lightIntensity;\n"
361 | #endif
362 | "\n"
363 | "void main()\n"
364 | "{\n"
365 | #if JUCE_OPENGL_ES
366 | " highp float l = lightIntensity * 0.25;\n"
367 | " highp vec4 colour = vec4 (l, l, l, 1.0);\n"
368 | #else
369 | " float l = lightIntensity * 0.25;\n"
370 | " vec4 colour = vec4 (l, l, l, 1.0);\n"
371 | #endif
372 | "\n"
373 | " gl_FragColor = colour;\n"
374 | "}\n"
375 | },
376 |
377 | {
378 | "Toon Shader",
379 |
380 |
381 | "attribute vec4 position;\n"
382 | "attribute vec4 normal;\n"
383 | "\n"
384 | "uniform mat4 projectionMatrix;\n"
385 | "uniform mat4 viewMatrix;\n"
386 | "uniform vec4 lightPosition;\n"
387 | "\n"
388 | "varying float lightIntensity;\n"
389 | "\n"
390 | "void main()\n"
391 | "{\n"
392 | " vec4 light = viewMatrix * lightPosition;\n"
393 | " lightIntensity = dot (light, normal);\n"
394 | "\n"
395 | " gl_Position = projectionMatrix * viewMatrix * position;\n"
396 | "}\n",
397 |
398 |
399 | #if JUCE_OPENGL_ES
400 | "varying highp float lightIntensity;\n"
401 | #else
402 | "varying float lightIntensity;\n"
403 | #endif
404 | "\n"
405 | "void main()\n"
406 | "{\n"
407 | #if JUCE_OPENGL_ES
408 | " highp float intensity = lightIntensity * 0.5;\n"
409 | " highp vec4 colour;\n"
410 | #else
411 | " float intensity = lightIntensity * 0.5;\n"
412 | " vec4 colour;\n"
413 | #endif
414 | "\n"
415 | " if (intensity > 0.95)\n"
416 | " colour = vec4 (1.0, 0.5, 0.5, 1.0);\n"
417 | " else if (intensity > 0.5)\n"
418 | " colour = vec4 (0.6, 0.3, 0.3, 1.0);\n"
419 | " else if (intensity > 0.25)\n"
420 | " colour = vec4 (0.4, 0.2, 0.2, 1.0);\n"
421 | " else\n"
422 | " colour = vec4 (0.2, 0.1, 0.1, 1.0);\n"
423 | "\n"
424 | " gl_FragColor = colour;\n"
425 | "}\n"
426 | }
427 | };
428 |
429 | return Array (presets, numElementsInArray (presets));
430 | }
431 |
--------------------------------------------------------------------------------
/Source/PluginEditor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | Ross Hoyt
4 | PluginEditor.cpp
5 | ==============================================================================
6 | */
7 |
8 | #include "PluginProcessor.h"
9 | #include "PluginEditor.h"
10 | #include "WavefrontObjParser.h"
11 | #include "Shape.h"
12 | #include "Textures.h"
13 | #include "Uniforms.h"
14 | #include "Attributes.h"
15 | #include "ShaderPreset.h"
16 | #include "GLUtils.h"
17 |
18 | //==============================================================================
19 | class GLComponent : public Component, private OpenGLRenderer, public Slider::Listener
20 | {
21 | public:
22 | GLComponent(MidiKeyboardState &mKeybState, PluginEditor *par) :
23 | rotation (0.0f), scale (0.5f), rotationSpeed (0.1f),
24 | textureToUse (nullptr), lastTexture (nullptr)
25 | {
26 | parent = par;
27 |
28 | midiKeyboardState = &mKeybState;
29 | Array shaders = getShaderPresets();
30 |
31 | if (shaders.size() > 0)
32 | {
33 | newVertexShader = shaders.getReference (0).vertexShader;
34 | newFragmentShader = shaders.getReference (0).fragmentShader;
35 | }
36 |
37 | lastTexture = textureToUse = new BuiltInTexture ("Portmeirion", BinaryData::portmeirion_jpg, BinaryData::portmeirion_jpgSize);
38 |
39 | openGLContext.setComponentPaintingEnabled (false);
40 | openGLContext.setContinuousRepainting (true);
41 |
42 | openGLContext.setRenderer (this);
43 | openGLContext.attachTo (*this);
44 | }
45 |
46 | ~GLComponent()
47 | {
48 | openGLContext.detach();
49 | openGLContext.setRenderer (nullptr);
50 |
51 | if (lastTexture != nullptr)
52 | delete lastTexture;
53 | }
54 |
55 | bool drawPianoKeys = true;
56 | bool drawControlMesh = true;
57 |
58 | String newVertexShader, newFragmentShader;
59 | private:
60 |
61 | void newOpenGLContextCreated() override
62 | {
63 | freeAllContextObjects();
64 | }
65 |
66 | void renderOpenGL() override
67 | {
68 | jassert (OpenGLHelpers::isContextActive());
69 |
70 | const float desktopScale = (float) openGLContext.getRenderingScale();
71 | OpenGLHelpers::clear (Colours::cadetblue);
72 |
73 | updateShader(); // Check whether we need to compile a new shader
74 |
75 | if (shader == nullptr)
76 | return;
77 |
78 | glEnable (GL_DEPTH_TEST);
79 | glDepthFunc (GL_LESS);
80 | glEnable (GL_BLEND);
81 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
82 | openGLContext.extensions.glActiveTexture (GL_TEXTURE0);
83 | glEnable (GL_TEXTURE_2D);
84 |
85 | glViewport (0, 0, roundToInt (desktopScale * getWidth()), roundToInt (desktopScale * getHeight()));
86 | texture.bind();
87 |
88 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
89 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
90 |
91 | shader->use();
92 |
93 | if (uniforms->projectionMatrix != nullptr)
94 | uniforms->projectionMatrix->setMatrix4 (getProjectionMatrix().mat, 1, false);
95 |
96 | if (uniforms->texture != nullptr)
97 | uniforms->texture->set ((GLint) 0);
98 |
99 | if (uniforms->lightPosition != nullptr)
100 | uniforms->lightPosition->set (-15.0f, 10.0f, 15.0f, 0.0f);
101 |
102 |
103 | for(int i = 0; i < 128; i++)
104 | {
105 |
106 | if (uniforms->viewMatrix != nullptr)
107 | uniforms->viewMatrix->setMatrix4 (getViewMatrix(i).mat, 1, false);
108 |
109 | // TODO could add automatic MidiChannel Sensing
110 | if(drawPianoKeys)
111 | {
112 | if(drawControlMesh)
113 | shapePianoKey->drawControlMesh(openGLContext, *attributes);
114 | if(midiKeyboardState->isNoteOn(1, i))
115 | shapePianoKey->draw (openGLContext, *attributes);
116 | }
117 | else
118 | {
119 | if(drawControlMesh)
120 | shapeTeapot->drawControlMesh(openGLContext, *attributes);
121 | if(midiKeyboardState->isNoteOn(1, i))
122 | shapeTeapot->draw(openGLContext, *attributes);
123 | }
124 |
125 | }
126 |
127 | // Reset the element buffers so child Components draw correctly
128 | openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, 0);
129 | openGLContext.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
130 |
131 | rotation += (float) rotationSpeed;
132 | }
133 |
134 | Matrix3D getProjectionMatrix() const
135 | {
136 | auto w = 1.0f / (scale + 0.1f);
137 | auto h = w * getLocalBounds().toFloat().getAspectRatio (false);
138 | return Matrix3D::fromFrustum (-w, w, -h, h, 4.0f, 30.0f);
139 | }
140 |
141 | Matrix3D getViewMatrix(int i) const
142 | {
143 | int fundamentalPitch = i % 12;
144 | auto viewMatrix = draggableOrientation.getRotationMatrix()
145 | * Vector3D (0.0f, 1.0f, -10.0f);
146 |
147 | float angle = 360.0f / 12.0f;
148 | float rotY = degreesToRadians(angle) * ((fundamentalPitch + 9) % 12);
149 | auto rotationMatrix = Matrix3D::rotation ({ 1.55f, rotY, -1.55f });
150 | // TODO Control Cylinder Radius with Slider
151 | float cylinderRadius = 2.0f;
152 |
153 | float translateY = i * -.5f + 30.0f;
154 | float translateX = cylinderRadius * sin(degreesToRadians(fundamentalPitch * angle));
155 | float translateZ = cylinderRadius * cos(degreesToRadians(fundamentalPitch * angle));
156 | auto translationVector = Matrix3D(Vector3D ({ translateX, translateY, translateZ}));
157 |
158 | return rotationMatrix * translationVector * viewMatrix;
159 |
160 | }
161 | void openGLContextClosing() override
162 | {
163 | freeAllContextObjects();
164 |
165 | if (lastTexture != nullptr)
166 | setTexture (lastTexture);
167 | }
168 |
169 | void paint(Graphics& g) override {}
170 |
171 | void setTexture (DemoTexture* t)
172 | {
173 | lastTexture = textureToUse = t;
174 | }
175 |
176 | void freeAllContextObjects()
177 | {
178 | shapePianoKey = nullptr;
179 | shader = nullptr;
180 | attributes = nullptr;
181 | uniforms = nullptr;
182 | texture.release();
183 | }
184 |
185 | void resized() override
186 | {
187 | draggableOrientation.setViewport (getLocalBounds());
188 | }
189 |
190 | Draggable3DOrientation draggableOrientation;
191 | float rotation;
192 | float scale, rotationSpeed;
193 |
194 | ScopedPointer shader;
195 | ScopedPointer shapePianoKey;
196 | ScopedPointer shapeTeapot;
197 |
198 | ScopedPointer attributes;
199 | ScopedPointer uniforms;
200 |
201 | OpenGLTexture texture;
202 | DemoTexture* textureToUse, *lastTexture;
203 |
204 | OpenGLContext openGLContext;
205 |
206 | //==============================================================================
207 |
208 |
209 | void updateShader()
210 | {
211 | if (newVertexShader.isNotEmpty() || newFragmentShader.isNotEmpty())
212 | {
213 | ScopedPointer newShader (new OpenGLShaderProgram (openGLContext));
214 | String statusText;
215 |
216 | if (newShader->addVertexShader (OpenGLHelpers::translateVertexShaderToV3 (newVertexShader))
217 | && newShader->addFragmentShader (OpenGLHelpers::translateFragmentShaderToV3 (newFragmentShader))
218 | && newShader->link())
219 | {
220 | shapePianoKey = nullptr;
221 | shapeTeapot = nullptr;
222 | attributes = nullptr;
223 | uniforms = nullptr;
224 |
225 | shader = newShader;
226 | shader->use();
227 |
228 | shapePianoKey = new Shape (openGLContext, BinaryData::pianokey_rectangle_obj);
229 | shapeTeapot = new Shape (openGLContext, BinaryData::teapot_obj);
230 | attributes = new Attributes (openGLContext, *shader);
231 | uniforms = new Uniforms (openGLContext, *shader);
232 |
233 | statusText = "GLSL: v" + String (OpenGLShaderProgram::getLanguageVersion(), 2);
234 | }
235 | else
236 | {
237 | statusText = newShader->getLastError();
238 | }
239 |
240 | newVertexShader = String();
241 | newFragmentShader = String();
242 | }
243 | }
244 |
245 | //==============================================================================
246 | // INPUT HANDLING
247 |
248 | void sliderValueChanged (Slider*) override
249 | {
250 | scale = (float) parent->zoomSlider.getValue();
251 | }
252 |
253 | void mouseDown (const MouseEvent& e) override
254 | {
255 | draggableOrientation.mouseDown (e.getPosition());
256 | }
257 |
258 | void mouseDrag (const MouseEvent& e) override
259 | {
260 | draggableOrientation.mouseDrag (e.getPosition());
261 | }
262 | void mouseWheelMove (const MouseEvent&, const MouseWheelDetails& d) override
263 | {
264 | parent->zoomSlider.setValue(parent->zoomSlider.getValue() + d.deltaY);
265 | }
266 | MidiKeyboardState * midiKeyboardState;
267 | PluginEditor *parent;
268 | };
269 |
270 | //==============================================================================
271 | PluginEditor::PluginEditor (PluginProcessor& p, MidiKeyboardState& midiKeyboardState)
272 | : AudioProcessorEditor (&p), processor (p), midiKeyboardComponent(midiKeyboardState, MidiKeyboardComponent::horizontalKeyboard)
273 | {
274 | // TOP MIDI KEYBOARD DISPLAY
275 | addAndMakeVisible(midiKeyboardComponent);
276 |
277 | // BOTTOM RIGHT - OPENGL DISPLAY
278 | glComponent = new GLComponent(midiKeyboardState, this);
279 | addAndMakeVisible (glComponent);
280 |
281 | // LEFT - OBJ FILE SELECTOR (RADIO BOX GROUP)
282 | radioButtonsObjSelector = new GroupComponent ("OBJ Selector", "Use Obj File:");
283 | addAndMakeVisible (radioButtonsObjSelector);
284 | togglePianoKeyObj = new ToggleButton("Pianokey_rectangle.obj");
285 | toggleTeapotObj = new ToggleButton("Teapot.obj");
286 | togglePianoKeyObj->setRadioGroupId(ObjSelectorButtons);
287 | toggleTeapotObj ->setRadioGroupId(ObjSelectorButtons);
288 | togglePianoKeyObj->onClick = [this] { updateToggleState (togglePianoKeyObj, "Pianokey_rectangle.obj"); };
289 | toggleTeapotObj ->onClick = [this] { updateToggleState (toggleTeapotObj, "Teapot.obj"); };
290 | addAndMakeVisible(togglePianoKeyObj);
291 | addAndMakeVisible(toggleTeapotObj);
292 |
293 | // LEFT - ZOOM SLIDER
294 | addAndMakeVisible (zoomSlider);
295 | zoomSlider.setRange (0.0, 1.0, 0.001);
296 | zoomSlider.addListener (glComponent);
297 | zoomSlider.setSliderStyle (Slider::LinearVertical);
298 | zoomLabel.attachToComponent (&zoomSlider, false);
299 | addAndMakeVisible (zoomLabel);
300 |
301 | // LEFT RADIO BOX: Draw Points
302 | toggleDrawControlMesh = new ToggleButton("Draw Points");
303 | toggleDrawControlMesh->onClick = [this] { updateToggleState (toggleDrawControlMesh, "Draw Points"); };
304 | addAndMakeVisible(toggleDrawControlMesh);
305 |
306 |
307 | addAndMakeVisible (shaderPresetBox);
308 | shaderPresetBox.onChange = [this] { selectShaderPreset (shaderPresetBox.getSelectedItemIndex()); };
309 |
310 | auto presets = getShaderPresets();
311 |
312 | for (int i = 0; i < presets.size(); ++i)
313 | shaderPresetBox.addItem (presets[i].name, i + 1);
314 |
315 | addAndMakeVisible (shaderPresetBoxLabel);
316 | shaderPresetBoxLabel.attachToComponent (&shaderPresetBox, true);
317 |
318 | initialise();
319 |
320 | //setResizable(true, true);
321 | setSize (1000, 725);
322 | }
323 |
324 | PluginEditor::~PluginEditor()
325 | {
326 | glComponent = nullptr;
327 | }
328 |
329 | void PluginEditor::initialise()
330 | {
331 | togglePianoKeyObj->setToggleState(true, false);
332 | toggleDrawControlMesh->setToggleState(true, false);
333 | zoomSlider .setValue (0.5);
334 |
335 | }
336 |
337 | void PluginEditor::updateToggleState (Button* button, String name)
338 | {
339 | if(name == "Draw Points") glComponent->drawControlMesh = button->getToggleState();
340 | else if(button->getToggleState())
341 | {
342 | if(name == "Pianokey_rectangle.obj") glComponent->drawPianoKeys = true;
343 | else if(name == "Teapot.obj") glComponent->drawPianoKeys = false;
344 | }
345 | }
346 |
347 | void PluginEditor::selectShaderPreset (int preset)
348 | {
349 | const auto& p = getShaderPresets()[preset];
350 | setShaderProgram(p.vertexShader, p.fragmentShader);
351 | }
352 |
353 | void PluginEditor::setShaderProgram (const String& vertexShader, const String& fragmentShader)
354 | {
355 | glComponent->newVertexShader = vertexShader;
356 | glComponent->newFragmentShader = fragmentShader;
357 | }
358 | //==============================================================================
359 |
360 | //==============================================================================
361 | void PluginEditor::paint (Graphics& g)
362 | {
363 | g.fillAll(backgroundColor);
364 | }
365 |
366 | Rectangle PluginEditor::getSubdividedRegion(Rectangle region, int numer, int denom, SubdividedOrientation orientation)
367 | {
368 | int x, y, height, width;
369 | if(orientation == Vertical)
370 | {
371 | x = region.getX();
372 | width = region.getWidth();
373 | height = region.getHeight() / denom;
374 | y = region.getY() + numer * height;
375 | }
376 | else
377 | {
378 | y = region.getY();
379 | height = region.getHeight();
380 | width = region.getWidth() / denom;
381 | x = region.getX() + numer * width;
382 | }
383 | return Rectangle(x, y, width, height);
384 | }
385 |
386 | void PluginEditor::resized()
387 | {
388 | Rectangle r = getLocalBounds();
389 | float resizedKeybWidth = r.getWidth() - MARGIN * 2, resizedKeybHeight = r.getHeight() - 5;
390 | float keybWidth = resizedKeybWidth > MAX_KEYB_WIDTH ? MAX_KEYB_WIDTH : resizedKeybWidth;
391 | float keybHeight = resizedKeybHeight > MAX_KEYB_HEIGHT ? MAX_KEYB_HEIGHT : resizedKeybHeight;
392 | midiKeyboardComponent.setBounds (MARGIN, MARGIN, keybWidth, keybHeight );
393 |
394 | auto areaBelowKeyboard = r.removeFromBottom(r.getHeight() - (keybHeight + MARGIN));
395 |
396 | int leftToolbarWidth = r.getWidth() / 7;
397 |
398 | auto glArea = areaBelowKeyboard.removeFromRight(r.getWidth() - leftToolbarWidth);
399 | glComponent->setBounds(glArea);
400 |
401 | auto leftButtonToolbarArea = areaBelowKeyboard.removeFromLeft(glArea.getWidth());
402 | auto radioObjSelectorRegion = leftButtonToolbarArea.removeFromTop((BUTTON_HEIGHT * 2 + MARGIN*3));
403 | radioObjSelectorRegion.translate(0, MARGIN);
404 | radioButtonsObjSelector->setBounds (radioObjSelectorRegion);//MARGIN, keybHeight + MARGIN, 220, 140);
405 | togglePianoKeyObj->setBounds(getSubdividedRegion(radioObjSelectorRegion, 1, 3, Vertical));//
406 | toggleTeapotObj->setBounds (getSubdividedRegion(radioObjSelectorRegion, 2, 3, Vertical));
407 |
408 | int sliderRegionHeight = leftButtonToolbarArea.getHeight() / 4 + BUTTON_HEIGHT;
409 | auto sliderRegion1 = leftButtonToolbarArea.removeFromTop(sliderRegionHeight);
410 | zoomSlider.setBounds(sliderRegion1.removeFromBottom(sliderRegion1.getHeight() - BUTTON_HEIGHT));
411 | zoomSlider.setTextBoxStyle (Slider::TextBoxBelow, false, BUTTON_WIDTH, 20);
412 |
413 | toggleDrawControlMesh->setBounds(leftButtonToolbarArea.removeFromTop(radioObjSelectorRegion.getHeight()));
414 |
415 | shaderPresetBox.setBounds(leftButtonToolbarArea.removeFromTop(BUTTON_HEIGHT * 3));
416 |
417 | }
418 |
--------------------------------------------------------------------------------
/Source/PluginEditor.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 | Ross Hoyt
4 | PluginEditor.h
5 | The Plugin Window, and the GL Component are declared here.
6 | They are defined PluginEditor.h
7 |
8 | ==============================================================================
9 | */
10 |
11 | #ifndef PLUGINEDITOR_H_INCLUDED
12 | #define PLUGINEDITOR_H_INCLUDED
13 |
14 |
15 | #include "../JuceLibraryCode/JuceHeader.h"
16 | #include "PluginProcessor.h"
17 |
18 |
19 | //==============================================================================
20 | /**
21 | */
22 | class GLComponent; // forward declared
23 | class PluginEditor : public AudioProcessorEditor
24 | {
25 | public:
26 | PluginEditor (PluginProcessor&, MidiKeyboardState&);
27 | ~PluginEditor();
28 |
29 | //==============================================================================
30 | void paint (Graphics&) override;
31 | void resized() override;
32 |
33 | // SLIDERS FOR GL WINDOW PARAMS THAT NEED TO BE ACCESSED BY CHILDREN
34 | Slider zoomSlider;
35 | Slider rotationSlider;
36 |
37 | // SHADER SELECTOR
38 | ComboBox shaderPresetBox;
39 |
40 | private:
41 |
42 |
43 | // RADIO BUTTONS:
44 | enum RadioButtonIds { ObjSelectorButtons = 1001 };
45 | // RB->OBJ SELECTOR RADIO BOX
46 | GroupComponent* radioButtonsObjSelector;
47 | ToggleButton* togglePianoKeyObj;
48 | ToggleButton* toggleTeapotObj;
49 |
50 |
51 | // OBJ SELECTOR RADIO BOX
52 | ToggleButton* toggleDrawControlMesh;
53 | //ToggleButton* toggleButton_TeapotObj;
54 |
55 |
56 | // LABELS
57 | Label zoomLabel { {}, "Zoom:" };
58 | Label shaderPresetBoxLabel;
59 | //Label rotationLabel { {}, "Rotation:" };
60 |
61 |
62 | void initialise();
63 |
64 | void updateToggleState(Button*, String);
65 |
66 | void selectShaderPreset(int);
67 | void setShaderProgram(const String&, const String&);
68 | void updateShader();
69 |
70 | // class that created this class
71 | PluginProcessor& processor;
72 |
73 |
74 | MidiKeyboardComponent midiKeyboardComponent;
75 | MidiKeyboardState * midiKeyboardState;
76 |
77 | ScopedPointer glComponent;
78 |
79 | // GUI constants
80 | static const int MARGIN = 4, MAX_WINDOW_HEIGHT = 800, MAX_WINDOW_WIDTH = 1200 + 2 * MARGIN,
81 | MAX_KEYB_WIDTH = 1200, MAX_KEYB_HEIGHT = 82, BUTTON_WIDTH = 50, BUTTON_HEIGHT = 30;
82 | Colour backgroundColor { 44,54,60 }; // stock bckgrd colour
83 |
84 | // Display Helper Method
85 | enum SubdividedOrientation { Vertical, Horizontal};
86 | static Rectangle getSubdividedRegion(const Rectangle, int, int, SubdividedOrientation);
87 |
88 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginEditor)
89 | };
90 |
91 |
92 | #endif // PLUGINEDITOR_H_INCLUDED
93 |
--------------------------------------------------------------------------------
/Source/PluginProcessor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 |
5 | Ross Hoyt
6 | PluginProcessor.cpp
7 |
8 | ==============================================================================
9 | */
10 |
11 | #include "PluginProcessor.h"
12 | #include "PluginEditor.h"
13 |
14 |
15 | //==============================================================================
16 | PluginProcessor::PluginProcessor()
17 | #ifndef JucePlugin_PreferredChannelConfigurations
18 | : AudioProcessor (BusesProperties()
19 | #if ! JucePlugin_IsMidiEffect
20 | #if ! JucePlugin_IsSynth
21 | .withInput ("Input", AudioChannelSet::stereo(), true)
22 | #endif
23 | .withOutput ("Output", AudioChannelSet::stereo(), true)
24 | #endif
25 | )
26 | #endif
27 | {
28 | }
29 |
30 | PluginProcessor::~PluginProcessor()
31 | {
32 | }
33 |
34 | //==============================================================================
35 | const String PluginProcessor::getName() const
36 | {
37 | return JucePlugin_Name;
38 | }
39 |
40 | bool PluginProcessor::acceptsMidi() const
41 | {
42 | #if JucePlugin_WantsMidiInput
43 | return true;
44 | #else
45 | return false;
46 | #endif
47 | }
48 |
49 | bool PluginProcessor::producesMidi() const
50 | {
51 | #if JucePlugin_ProducesMidiOutput
52 | return true;
53 | #else
54 | return false;
55 | #endif
56 | }
57 |
58 | double PluginProcessor::getTailLengthSeconds() const
59 | {
60 | return 0.0;
61 | }
62 |
63 | int PluginProcessor::getNumPrograms()
64 | {
65 | return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
66 | // so this should be at least 1, even if you're not really implementing programs.
67 | }
68 |
69 | int PluginProcessor::getCurrentProgram()
70 | {
71 | return 0;
72 | }
73 |
74 | void PluginProcessor::setCurrentProgram (int index)
75 | {
76 | }
77 |
78 | const String PluginProcessor::getProgramName (int index)
79 | {
80 | return String();
81 | }
82 |
83 | void PluginProcessor::changeProgramName (int index, const String& newName)
84 | {
85 | }
86 |
87 | //==============================================================================
88 | void PluginProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
89 | {
90 | // Use this method as the place to do any pre-playback
91 | // initialisation that you need..
92 | }
93 |
94 | void PluginProcessor::releaseResources()
95 | {
96 | // When playback stops, you can use this as an opportunity to free up any
97 | // spare memory, etc.
98 | }
99 |
100 | #ifndef JucePlugin_PreferredChannelConfigurations
101 | bool PluginProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const
102 | {
103 | #if JucePlugin_IsMidiEffect
104 | ignoreUnused (layouts);
105 | return true;
106 | #else
107 | // This is the place where you check if the layout is supported.
108 | // In this template code we only support mono or stereo.
109 | if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono()
110 | && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo())
111 | return false;
112 |
113 | // This checks if the input layout matches the output layout
114 | #if ! JucePlugin_IsSynth
115 | if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
116 | return false;
117 | #endif
118 |
119 | return true;
120 | #endif
121 | }
122 | #endif
123 |
124 | void PluginProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
125 | {
126 | const int totalNumInputChannels = getTotalNumInputChannels();
127 | const int totalNumOutputChannels = getTotalNumOutputChannels();
128 |
129 | // MIDI Processing Occurs here
130 | int numMidiEvents = midiMessages.getNumEvents();
131 | midiKeyboardState.processNextMidiBuffer(midiMessages, midiSampleCounter, numMidiEvents, true);
132 | midiSampleCounter += numMidiEvents;
133 |
134 | // AUDIO BUFFER HANDLING (DEFAULT - DOES NOTHING BUT MUTE ANY INPUT DATA
135 | // In case we have more outputs than inputs, this code clears any output
136 | // channels that didn't contain input data, (because these aren't
137 | // guaranteed to be empty - they may contain garbage).
138 | // This is here to avoid people getting screaming feedback
139 | // when they first compile a plugin, but obviously you don't need to keep
140 | // this code if your algorithm always overwrites all the output channels.
141 | for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
142 | buffer.clear (i, 0, buffer.getNumSamples());
143 |
144 | // This is the place where you'd normally do the guts of your plugin's
145 | // audio processing...
146 | //for (int channel = 0; channel < totalNumInputChannels; ++channel)
147 | //{
148 | //float* channelData = buffer.getWritePointer (channel);
149 | // ..do something to the data...
150 | //}
151 | }
152 |
153 | //==============================================================================
154 | bool PluginProcessor::hasEditor() const
155 | {
156 | return true; // (change this to false if you choose to not supply an editor)
157 | }
158 |
159 | AudioProcessorEditor* PluginProcessor::createEditor()
160 | {
161 | return new PluginEditor (*this, midiKeyboardState);
162 | }
163 |
164 | //==============================================================================
165 | void PluginProcessor::getStateInformation (MemoryBlock& destData)
166 | {
167 | // You should use this method to store your parameters in the memory block.
168 | // You could do that either as raw data, or use the XML or ValueTree classes
169 | // as intermediaries to make it easy to save and load complex data.
170 | }
171 |
172 | void PluginProcessor::setStateInformation (const void* data, int sizeInBytes)
173 | {
174 | // You should use this method to restore your parameters from this memory block,
175 | // whose contents will have been created by the getStateInformation() call.
176 | }
177 |
178 | //==============================================================================
179 | // This creates new instances of the plugin..
180 | AudioProcessor* JUCE_CALLTYPE createPluginFilter()
181 | {
182 | return new PluginProcessor();
183 | }
184 |
--------------------------------------------------------------------------------
/Source/PluginProcessor.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | PluginProcessor.h
6 |
7 | Contains framework code for a JUCE plugin processor.
8 |
9 | ==============================================================================
10 | */
11 |
12 | //#ifndef PLUGINPROCESSOR_H_INCLUDED
13 | //#define PLUGINPROCESSOR_H_INCLUDED
14 | #pragma once
15 |
16 | #include "../JuceLibraryCode/JuceHeader.h"
17 |
18 |
19 | //==============================================================================
20 | /**
21 | */
22 | class PluginProcessor : public AudioProcessor
23 | {
24 | public:
25 | //==============================================================================
26 | PluginProcessor();
27 | ~PluginProcessor();
28 |
29 | //==============================================================================
30 | void prepareToPlay (double sampleRate, int samplesPerBlock) override;
31 | void releaseResources() override;
32 |
33 | #ifndef JucePlugin_PreferredChannelConfigurations
34 | bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
35 | #endif
36 |
37 | void processBlock (AudioSampleBuffer&, MidiBuffer&) override;
38 |
39 | //==============================================================================
40 | AudioProcessorEditor* createEditor() override;
41 | bool hasEditor() const override;
42 |
43 | //==============================================================================
44 | const String getName() const override;
45 |
46 | bool acceptsMidi() const override;
47 | bool producesMidi() const override;
48 | double getTailLengthSeconds() const override;
49 |
50 | //==============================================================================
51 | int getNumPrograms() override;
52 | int getCurrentProgram() override;
53 | void setCurrentProgram (int index) override;
54 | const String getProgramName (int index) override;
55 | void changeProgramName (int index, const String& newName) override;
56 |
57 | //==============================================================================
58 | void getStateInformation (MemoryBlock& destData) override;
59 | void setStateInformation (const void* data, int sizeInBytes) override;
60 |
61 | private:
62 | //==============================================================================
63 | MidiKeyboardState midiKeyboardState;
64 | int midiSampleCounter;
65 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginProcessor)
66 | };
67 |
68 |
69 | //#endif // PLUGINPROCESSOR_H_INCLUDED
70 |
--------------------------------------------------------------------------------
/Source/ShaderPreset.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | ShaderPreset.h
6 | Each Shader is stored with a Name (for dispay in the selector box),
7 | a vertexShader, and a Fragment Shader.
8 | ==============================================================================
9 | */
10 |
11 | #pragma once
12 |
13 | struct ShaderPreset
14 | {
15 | const char* name;
16 | const char* vertexShader;
17 | const char* fragmentShader;
18 | };
19 |
--------------------------------------------------------------------------------
/Source/Shape.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Shape.h
6 |
7 | ==============================================================================
8 | */
9 |
10 | #pragma once
11 | #include "Attributes.h"
12 | #include "WavefrontObjParser.h"
13 | #include "Vertex.h"
14 |
15 | //==============================================================================
16 | /** This loads a 3D model from an OBJ file and converts it into some vertex buffers
17 | that we can draw.
18 | */
19 | struct Shape
20 | {
21 | Shape (OpenGLContext& openGLContext, const String& objFileContent)
22 | {
23 | if (shapeFile.load (objFileContent).wasOk())
24 | for (int i = 0; i < shapeFile.shapes.size(); ++i)
25 | vertexBuffers.add (new VertexBuffer (openGLContext, *shapeFile.shapes.getUnchecked(i)));
26 |
27 | }
28 |
29 | void draw (OpenGLContext& openGLContext, Attributes& attributes)
30 | {
31 | for (int i = 0; i < vertexBuffers.size(); ++i)
32 | {
33 | VertexBuffer& vertexBuffer = *vertexBuffers.getUnchecked (i);
34 | vertexBuffer.bind();
35 |
36 | attributes.enable (openGLContext);
37 |
38 | glDrawElements (GL_TRIANGLES, vertexBuffer.numIndices, GL_UNSIGNED_INT, 0);
39 |
40 | attributes.disable (openGLContext);
41 | }
42 | }
43 |
44 | void drawControlMesh(OpenGLContext& openGLContext, Attributes& attributes)
45 | {
46 | glLineWidth(1);
47 |
48 | for (int i = 0; i < vertexBuffers.size(); ++i)
49 | {
50 | VertexBuffer& vertexBuffer = *vertexBuffers.getUnchecked (i);
51 | vertexBuffer.bind();
52 |
53 | attributes.enable (openGLContext);
54 |
55 | glDrawArrays(GL_LINE_LOOP, vertexBuffer.indexBuffer, vertexBuffer.numIndices);
56 |
57 | attributes.disable (openGLContext);
58 |
59 | }
60 |
61 | glFlush();
62 | }
63 |
64 | private:
65 | struct VertexBuffer
66 | {
67 | VertexBuffer (OpenGLContext& context, WavefrontObjFile::Shape& shape) : openGLContext (context)
68 | {
69 | numIndices = shape.mesh.indices.size();
70 |
71 | openGLContext.extensions.glGenBuffers (1, &vertexBuffer);
72 | openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, vertexBuffer);
73 |
74 | Array vertices;
75 | createVertexListFromMesh (shape.mesh, vertices, Colours::green);
76 |
77 | openGLContext.extensions.glBufferData (GL_ARRAY_BUFFER, vertices.size() * (int) sizeof (Vertex),
78 | vertices.getRawDataPointer(), GL_STATIC_DRAW);
79 |
80 | openGLContext.extensions.glGenBuffers (1, &indexBuffer);
81 | openGLContext.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
82 | openGLContext.extensions.glBufferData (GL_ELEMENT_ARRAY_BUFFER, numIndices * (int) sizeof (juce::uint32),
83 | shape.mesh.indices.getRawDataPointer(), GL_STATIC_DRAW);
84 | }
85 |
86 | ~VertexBuffer()
87 | {
88 | openGLContext.extensions.glDeleteBuffers (1, &vertexBuffer);
89 | openGLContext.extensions.glDeleteBuffers (1, &indexBuffer);
90 | }
91 |
92 | void bind()
93 | {
94 | openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, vertexBuffer);
95 | openGLContext.extensions.glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
96 | }
97 |
98 | GLuint vertexBuffer, indexBuffer;
99 | int numIndices;
100 | OpenGLContext& openGLContext;
101 |
102 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VertexBuffer)
103 | };
104 |
105 | WavefrontObjFile shapeFile;
106 | OwnedArray vertexBuffers;
107 |
108 | static void createVertexListFromMesh (const WavefrontObjFile::Mesh& mesh, Array& list, Colour colour)
109 | {
110 | const float scale = 0.2f;
111 | WavefrontObjFile::TextureCoord defaultTexCoord = { 0.5f, 0.5f };
112 | WavefrontObjFile::Vertex defaultNormal = { 0.5f, 0.5f, 0.5f };
113 |
114 | for (int i = 0; i < mesh.vertices.size(); ++i)
115 | {
116 | const WavefrontObjFile::Vertex& v = mesh.vertices.getReference (i);
117 |
118 | const WavefrontObjFile::Vertex& n
119 | = i < mesh.normals.size() ? mesh.normals.getReference (i) : defaultNormal;
120 |
121 | const WavefrontObjFile::TextureCoord& tc
122 | = i < mesh.textureCoords.size() ? mesh.textureCoords.getReference (i) : defaultTexCoord;
123 |
124 | Vertex vert =
125 | {
126 | { scale * v.x, scale * v.y, scale * v.z, },
127 | { scale * n.x, scale * n.y, scale * n.z, },
128 | { colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue(), colour.getFloatAlpha() },
129 | { tc.x, tc.y }
130 | };
131 |
132 | list.add (vert);
133 | }
134 | }
135 | };
136 |
137 |
--------------------------------------------------------------------------------
/Source/Textures.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Textures.h
6 | ==============================================================================
7 | */
8 |
9 | #pragma once
10 | #include "GLUtils.h"
11 |
12 | struct DemoTexture
13 | {
14 | virtual ~DemoTexture() {}
15 | virtual bool applyTo (OpenGLTexture&) = 0;
16 |
17 | String name;
18 | };
19 |
20 | struct BuiltInTexture : public DemoTexture
21 | {
22 | BuiltInTexture (const char* nm, const void* imageData, size_t imageSize)
23 | : image (resizeImageToPowerOfTwo (ImageFileFormat::loadFrom (imageData, imageSize)))
24 | {
25 | name = nm;
26 | }
27 |
28 | Image image;
29 |
30 | bool applyTo (OpenGLTexture& texture) override
31 | {
32 | texture.loadImage (image);
33 | return false;
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/Source/Uniforms.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Uniforms.h
6 | ==============================================================================
7 | */
8 |
9 | #pragma once
10 |
11 | //==============================================================================
12 | // Class that manages the uniform values that the shaders use.
13 | struct Uniforms
14 | {
15 | Uniforms (OpenGLContext& openGLContext, OpenGLShaderProgram& shader)
16 | {
17 | projectionMatrix = createUniform (openGLContext, shader, "projectionMatrix");
18 | viewMatrix = createUniform (openGLContext, shader, "viewMatrix");
19 | texture = createUniform (openGLContext, shader, "demoTexture");
20 | lightPosition = createUniform (openGLContext, shader, "lightPosition");
21 | }
22 |
23 | ScopedPointer projectionMatrix, viewMatrix, texture, lightPosition;
24 |
25 | private:
26 | static OpenGLShaderProgram::Uniform* createUniform (OpenGLContext& openGLContext,
27 | OpenGLShaderProgram& shader,
28 | const char* uniformName)
29 | {
30 | if (openGLContext.extensions.glGetUniformLocation (shader.getProgramID(), uniformName) < 0)
31 | return nullptr;
32 |
33 | return new OpenGLShaderProgram::Uniform (shader, uniformName);
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/Source/Vertex.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | Ross Hoyt
5 | Vertex.h
6 |
7 |
8 | ==============================================================================
9 | */
10 |
11 | #pragma once
12 |
13 | /**
14 | Vertex data to be passed to the shaders.
15 | Each Vertex has a 3D position, a colour and a 2D texture co-ordinate
16 | */
17 | struct Vertex
18 | {
19 | float position[3];
20 | float normal[3];
21 | float colour[4];
22 | float texCoord[2];
23 | };
24 |
--------------------------------------------------------------------------------
/Source/WavefrontObjParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | ==============================================================================
3 |
4 | This file is part of the JUCE examples.
5 | Copyright (c) 2017 - ROLI Ltd.
6 |
7 | The code included in this file is provided under the terms of the ISC license
8 | http://www.isc.org/downloads/software-support-policy/isc-license. Permission
9 | To use, copy, modify, and/or distribute this software for any purpose with or
10 | without fee is hereby granted provided that the above copyright notice and
11 | this permission notice appear in all copies.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES,
14 | WHETHER EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR
15 | PURPOSE, ARE DISCLAIMED.
16 |
17 | ==============================================================================
18 | */
19 |
20 | #pragma once
21 |
22 | #include