aboutsummaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/docs/html/classmingfx_1_1_default_shader.html
blob: 169b627747e39a3e9ceeeedcb47429ee4deb0beb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>MinGfx Toolkit: mingfx::DefaultShader Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">MinGfx Toolkit
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacemingfx.html">mingfx</a></li><li class="navelem"><a class="el" href="classmingfx_1_1_default_shader.html">DefaultShader</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="classmingfx_1_1_default_shader-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">mingfx::DefaultShader Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A simple GLSL shader for textured per-fragment Phong shading with multiple light sources. </p>
<p>This can be used to draw 3D models stored in a <a class="el" href="classmingfx_1_1_mesh.html" title="A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.">mingfx::Mesh</a> data structure or you can use it with your own geometry data structures. Lighting properties are stored within the class itself since these are considered part of the shading model. Material properties are considered properties of the meshes or other materials you wish to draw so these are stored outside of the class and passed into the <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a> or <a class="el" href="classmingfx_1_1_default_shader.html#a053599d8c7acd9920461aab8ce945ab0" title="Only needed if you do not want to draw a Mesh. This does all of the same setup for drawing that the D...">UseProgram()</a> functions.</p>
<p>An example of using <a class="el" href="classmingfx_1_1_default_shader.html" title="A simple GLSL shader for textured per-fragment Phong shading with multiple light sources.">DefaultShader</a> to render a mesh: </p><div class="fragment"><div class="line"><a class="code" href="classmingfx_1_1_default_shader.html#ac030575fd76a6076262bdd09bbb93428">DefaultShader</a> phong_shader;</div>
<div class="line">Mesh teapot;</div>
<div class="line">DefaultShader::MaterialProperties teapot_material;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3">Init</a>() {</div>
<div class="line">   <span class="comment">// initialize the shader</span></div>
<div class="line">   DefaultShader::LightProperties red_light;</div>
<div class="line">   red_light.position = Point3(-10, 5, 5);</div>
<div class="line">   red_light.diffuseIntensity = Color(1,0,0);</div>
<div class="line">   phong_shader.AddLight(red_light);</div>
<div class="line"> </div>
<div class="line">   <span class="comment">// initialize the mesh</span></div>
<div class="line">   teapot.LoadFromOBJ(<a class="code" href="classmingfx_1_1_platform.html#a2c36ca57a246efa218a49a942c8c4a3b">Platform::FindMinGfxDataFile</a>(<span class="stringliteral">&quot;teapot.obj&quot;</span>));</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> DrawUsingOpenGL() {</div>
<div class="line">   Matrix4 M;</div>
<div class="line">   Matrix4 V = <a class="code" href="classmingfx_1_1_matrix4.html#a4543695a6dfc996d0312b70c2eaa00de">Matrix4::LookAt</a>(Point3(0,0,3), Point3(0,0,0), Vector3(0,1,0));</div>
<div class="line">   Matrix4 P = <a class="code" href="classmingfx_1_1_matrix4.html#a0e34aee86758a0397074590b87712c5e">Matrix4::Perspective</a>(60.0, aspect_ratio(), 0.1, 10.0);</div>
<div class="line">   phong_shader.Draw(M, V, P, teapot, teapot_material);</div>
<div class="line">}</div>
<div class="ttc" id="aclassmingfx_1_1_default_shader_html_a5cb9f0a1709452268858ec338448a4c3"><div class="ttname"><a href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3">mingfx::DefaultShader::Init</a></div><div class="ttdeci">void Init()</div><div class="ttdoc">This loads vertex and fragment shaders from files, compiles them, and links them. So,...</div></div>
<div class="ttc" id="aclassmingfx_1_1_default_shader_html_ac030575fd76a6076262bdd09bbb93428"><div class="ttname"><a href="classmingfx_1_1_default_shader.html#ac030575fd76a6076262bdd09bbb93428">mingfx::DefaultShader::DefaultShader</a></div><div class="ttdeci">DefaultShader(bool add_default_light=true)</div><div class="ttdoc">The constructor defaults to adding a single white light to the scene at (10,10,10)....</div></div>
<div class="ttc" id="aclassmingfx_1_1_matrix4_html_a0e34aee86758a0397074590b87712c5e"><div class="ttname"><a href="classmingfx_1_1_matrix4.html#a0e34aee86758a0397074590b87712c5e">mingfx::Matrix4::Perspective</a></div><div class="ttdeci">static Matrix4 Perspective(float fov_y_in_degrees, float aspect_ratio, float near_plane_dist, float far_plane_dist)</div><div class="ttdoc">Returns a perspective projection matrix equivalent to the one gluPerspective creates.</div></div>
<div class="ttc" id="aclassmingfx_1_1_matrix4_html_a4543695a6dfc996d0312b70c2eaa00de"><div class="ttname"><a href="classmingfx_1_1_matrix4.html#a4543695a6dfc996d0312b70c2eaa00de">mingfx::Matrix4::LookAt</a></div><div class="ttdeci">static Matrix4 LookAt(Point3 eye, Point3 target, Vector3 up)</div><div class="ttdoc">Returns a view matrix that centers the camera at the 'eye' position and orients it to look at the des...</div></div>
<div class="ttc" id="aclassmingfx_1_1_platform_html_a2c36ca57a246efa218a49a942c8c4a3b"><div class="ttname"><a href="classmingfx_1_1_platform.html#a2c36ca57a246efa218a49a942c8c4a3b">mingfx::Platform::FindMinGfxDataFile</a></div><div class="ttdeci">static std::string FindMinGfxDataFile(const std::string &amp;basename)</div><div class="ttdoc">Searches for a data file that ships with MinGfx.</div></div>
</div><!-- fragment --> 
<p class="definition">Definition at line <a class="el" href="default__shader_8h_source.html#l00062">62</a> of file <a class="el" href="default__shader_8h_source.html">default_shader.h</a>.</p>
</div>
<p><code>#include &lt;<a class="el" href="default__shader_8h_source.html">default_shader.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Small data structure to hold per-light properties.  <a href="classmingfx_1_1_default_shader_1_1_light_properties.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader_1_1_material_properties.html">MaterialProperties</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Small data structure to hold properties of the material to be lit.  <a href="classmingfx_1_1_default_shader_1_1_material_properties.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ac030575fd76a6076262bdd09bbb93428"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#ac030575fd76a6076262bdd09bbb93428">DefaultShader</a> (bool add_default_light=true)</td></tr>
<tr class="memdesc:ac030575fd76a6076262bdd09bbb93428"><td class="mdescLeft">&#160;</td><td class="mdescRight">The constructor defaults to adding a single white light to the scene at (10,10,10). Change this by passing it 'false'. The constructor does not load and compile the shader right away. This is done inside <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>.  <a href="classmingfx_1_1_default_shader.html#ac030575fd76a6076262bdd09bbb93428">More...</a><br /></td></tr>
<tr class="separator:ac030575fd76a6076262bdd09bbb93428"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0fe7d605d039ecdbf17837bc5bbe0aba"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a0fe7d605d039ecdbf17837bc5bbe0aba">~DefaultShader</a> ()</td></tr>
<tr class="separator:a0fe7d605d039ecdbf17837bc5bbe0aba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af54a8e489d9fb34cfceb1c07562c6e2c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#af54a8e489d9fb34cfceb1c07562c6e2c">AddLight</a> (<a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a> <a class="el" href="classmingfx_1_1_default_shader.html#aa2ed33efad35aefbb400be45250cd316">light</a>)</td></tr>
<tr class="memdesc:af54a8e489d9fb34cfceb1c07562c6e2c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Multiple lights are supported, this adds one to the end of the list. Up to MAX_LIGHTS can be added.  <a href="classmingfx_1_1_default_shader.html#af54a8e489d9fb34cfceb1c07562c6e2c">More...</a><br /></td></tr>
<tr class="separator:af54a8e489d9fb34cfceb1c07562c6e2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a41e74fb8af72a6b22c72b0916726b6d6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a41e74fb8af72a6b22c72b0916726b6d6">SetLight</a> (int i, <a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a> <a class="el" href="classmingfx_1_1_default_shader.html#aa2ed33efad35aefbb400be45250cd316">light</a>)</td></tr>
<tr class="memdesc:a41e74fb8af72a6b22c72b0916726b6d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Changes the properties for a light that was already added.  <a href="classmingfx_1_1_default_shader.html#a41e74fb8af72a6b22c72b0916726b6d6">More...</a><br /></td></tr>
<tr class="separator:a41e74fb8af72a6b22c72b0916726b6d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5cb9f0a1709452268858ec338448a4c3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3">Init</a> ()</td></tr>
<tr class="memdesc:a5cb9f0a1709452268858ec338448a4c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">This loads vertex and fragment shaders from files, compiles them, and links them. So, it must be called from within an active OpenGL context, for example, from within GraphicsApp::Init() or <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>. If you call <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a> before calling <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>, then <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a> will be called as the first step within <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a>. So, if you do not mind a slowdown on the very first frame of your program, it is fine to skip calling <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>.  <a href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3">More...</a><br /></td></tr>
<tr class="separator:a5cb9f0a1709452268858ec338448a4c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a652b3d00bb6ae2a806b1ca3e3d42242b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b">Draw</a> (const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;model, const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;view, const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;projection, <a class="el" href="classmingfx_1_1_mesh.html">Mesh</a> *mesh, const <a class="el" href="classmingfx_1_1_default_shader_1_1_material_properties.html">MaterialProperties</a> &amp;material)</td></tr>
<tr class="memdesc:a652b3d00bb6ae2a806b1ca3e3d42242b"><td class="mdescLeft">&#160;</td><td class="mdescRight">This starts the shader and sets its uniform variables based upon the current set of lights, the material properties passed in, and the model, view, and projection matrices. Then, it calls mesh-&gt;<a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a>. After drawing, it disables the shader.  <a href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b">More...</a><br /></td></tr>
<tr class="separator:a652b3d00bb6ae2a806b1ca3e3d42242b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a053599d8c7acd9920461aab8ce945ab0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a053599d8c7acd9920461aab8ce945ab0">UseProgram</a> (const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;model, const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;view, const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;projection, const <a class="el" href="classmingfx_1_1_default_shader_1_1_material_properties.html">MaterialProperties</a> &amp;material)</td></tr>
<tr class="memdesc:a053599d8c7acd9920461aab8ce945ab0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Only needed if you do not want to draw a <a class="el" href="classmingfx_1_1_mesh.html" title="A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.">Mesh</a>. This does all of the same setup for drawing that the <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a> function does and then it returns so that you may draw your own geometry however you want. After doing your draw must call <a class="el" href="classmingfx_1_1_default_shader.html#a2c188bc0fc5f7fc7405f04b036bd4d67" title="Only needed if you do not want to draw a Mesh. Call this after UseProgram() and after drawing your ge...">StopProgram()</a> to turn off the shader.  <a href="classmingfx_1_1_default_shader.html#a053599d8c7acd9920461aab8ce945ab0">More...</a><br /></td></tr>
<tr class="separator:a053599d8c7acd9920461aab8ce945ab0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c188bc0fc5f7fc7405f04b036bd4d67"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a2c188bc0fc5f7fc7405f04b036bd4d67">StopProgram</a> ()</td></tr>
<tr class="memdesc:a2c188bc0fc5f7fc7405f04b036bd4d67"><td class="mdescLeft">&#160;</td><td class="mdescRight">Only needed if you do not want to draw a <a class="el" href="classmingfx_1_1_mesh.html" title="A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.">Mesh</a>. Call this after <a class="el" href="classmingfx_1_1_default_shader.html#a053599d8c7acd9920461aab8ce945ab0" title="Only needed if you do not want to draw a Mesh. This does all of the same setup for drawing that the D...">UseProgram()</a> and after drawing your geometry to turn off the shader.  <a href="classmingfx_1_1_default_shader.html#a2c188bc0fc5f7fc7405f04b036bd4d67">More...</a><br /></td></tr>
<tr class="separator:a2c188bc0fc5f7fc7405f04b036bd4d67"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac5b779672a983df8aa67c9cbe026e0c2"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#ac5b779672a983df8aa67c9cbe026e0c2">num_lights</a> ()</td></tr>
<tr class="separator:ac5b779672a983df8aa67c9cbe026e0c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa2ed33efad35aefbb400be45250cd316"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#aa2ed33efad35aefbb400be45250cd316">light</a> (int i)</td></tr>
<tr class="separator:aa2ed33efad35aefbb400be45250cd316"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr class="memitem:a21c1fd93273eaf643e7ac9b05ba0fb24"><td class="memItemLeft" align="right" valign="top">static const unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmingfx_1_1_default_shader.html#a21c1fd93273eaf643e7ac9b05ba0fb24">MAX_LIGHTS</a> = 10</td></tr>
<tr class="memdesc:a21c1fd93273eaf643e7ac9b05ba0fb24"><td class="mdescLeft">&#160;</td><td class="mdescRight">If changed, this needs to also be changed in the glsl shader code.  <a href="classmingfx_1_1_default_shader.html#a21c1fd93273eaf643e7ac9b05ba0fb24">More...</a><br /></td></tr>
<tr class="separator:a21c1fd93273eaf643e7ac9b05ba0fb24"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="ac030575fd76a6076262bdd09bbb93428"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac030575fd76a6076262bdd09bbb93428">&#9670;&nbsp;</a></span>DefaultShader()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">mingfx::DefaultShader::DefaultShader </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>add_default_light</em> = <code>true</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The constructor defaults to adding a single white light to the scene at (10,10,10). Change this by passing it 'false'. The constructor does not load and compile the shader right away. This is done inside <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>. </p>

</div>
</div>
<a id="a0fe7d605d039ecdbf17837bc5bbe0aba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0fe7d605d039ecdbf17837bc5bbe0aba">&#9670;&nbsp;</a></span>~DefaultShader()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual mingfx::DefaultShader::~DefaultShader </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="af54a8e489d9fb34cfceb1c07562c6e2c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af54a8e489d9fb34cfceb1c07562c6e2c">&#9670;&nbsp;</a></span>AddLight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::AddLight </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a>&#160;</td>
          <td class="paramname"><em>light</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Multiple lights are supported, this adds one to the end of the list. Up to MAX_LIGHTS can be added. </p>

</div>
</div>
<a id="a652b3d00bb6ae2a806b1ca3e3d42242b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a652b3d00bb6ae2a806b1ca3e3d42242b">&#9670;&nbsp;</a></span>Draw()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::Draw </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>model</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>view</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>projection</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classmingfx_1_1_mesh.html">Mesh</a> *&#160;</td>
          <td class="paramname"><em>mesh</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_default_shader_1_1_material_properties.html">MaterialProperties</a> &amp;&#160;</td>
          <td class="paramname"><em>material</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This starts the shader and sets its uniform variables based upon the current set of lights, the material properties passed in, and the model, view, and projection matrices. Then, it calls mesh-&gt;<a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a>. After drawing, it disables the shader. </p>

</div>
</div>
<a id="a5cb9f0a1709452268858ec338448a4c3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5cb9f0a1709452268858ec338448a4c3">&#9670;&nbsp;</a></span>Init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::Init </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This loads vertex and fragment shaders from files, compiles them, and links them. So, it must be called from within an active OpenGL context, for example, from within GraphicsApp::Init() or <a class="el" href="classmingfx_1_1_graphics_app.html#a5a858fd10651f7617491f37b49dbf8ca" title="Override this to draw graphics using raw OpenGL 2D or 3D graphics calls.">GraphicsApp::DrawUsingOpenGL()</a>. If you call <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a> before calling <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>, then <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a> will be called as the first step within <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a>. So, if you do not mind a slowdown on the very first frame of your program, it is fine to skip calling <a class="el" href="classmingfx_1_1_default_shader.html#a5cb9f0a1709452268858ec338448a4c3" title="This loads vertex and fragment shaders from files, compiles them, and links them. So,...">Init()</a>. </p>

</div>
</div>
<a id="aa2ed33efad35aefbb400be45250cd316"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa2ed33efad35aefbb400be45250cd316">&#9670;&nbsp;</a></span>light()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a> mingfx::DefaultShader::light </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>i</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="ac5b779672a983df8aa67c9cbe026e0c2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac5b779672a983df8aa67c9cbe026e0c2">&#9670;&nbsp;</a></span>num_lights()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int mingfx::DefaultShader::num_lights </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="a41e74fb8af72a6b22c72b0916726b6d6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a41e74fb8af72a6b22c72b0916726b6d6">&#9670;&nbsp;</a></span>SetLight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::SetLight </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>i</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classmingfx_1_1_default_shader_1_1_light_properties.html">LightProperties</a>&#160;</td>
          <td class="paramname"><em>light</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Changes the properties for a light that was already added. </p>

</div>
</div>
<a id="a2c188bc0fc5f7fc7405f04b036bd4d67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c188bc0fc5f7fc7405f04b036bd4d67">&#9670;&nbsp;</a></span>StopProgram()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::StopProgram </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Only needed if you do not want to draw a <a class="el" href="classmingfx_1_1_mesh.html" title="A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.">Mesh</a>. Call this after <a class="el" href="classmingfx_1_1_default_shader.html#a053599d8c7acd9920461aab8ce945ab0" title="Only needed if you do not want to draw a Mesh. This does all of the same setup for drawing that the D...">UseProgram()</a> and after drawing your geometry to turn off the shader. </p>

</div>
</div>
<a id="a053599d8c7acd9920461aab8ce945ab0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a053599d8c7acd9920461aab8ce945ab0">&#9670;&nbsp;</a></span>UseProgram()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mingfx::DefaultShader::UseProgram </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>model</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>view</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_matrix4.html">Matrix4</a> &amp;&#160;</td>
          <td class="paramname"><em>projection</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classmingfx_1_1_default_shader_1_1_material_properties.html">MaterialProperties</a> &amp;&#160;</td>
          <td class="paramname"><em>material</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Only needed if you do not want to draw a <a class="el" href="classmingfx_1_1_mesh.html" title="A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.">Mesh</a>. This does all of the same setup for drawing that the <a class="el" href="classmingfx_1_1_default_shader.html#a652b3d00bb6ae2a806b1ca3e3d42242b" title="This starts the shader and sets its uniform variables based upon the current set of lights,...">Draw()</a> function does and then it returns so that you may draw your own geometry however you want. After doing your draw must call <a class="el" href="classmingfx_1_1_default_shader.html#a2c188bc0fc5f7fc7405f04b036bd4d67" title="Only needed if you do not want to draw a Mesh. Call this after UseProgram() and after drawing your ge...">StopProgram()</a> to turn off the shader. </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a21c1fd93273eaf643e7ac9b05ba0fb24"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a21c1fd93273eaf643e7ac9b05ba0fb24">&#9670;&nbsp;</a></span>MAX_LIGHTS</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">const unsigned int mingfx::DefaultShader::MAX_LIGHTS = 10</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>If changed, this needs to also be changed in the glsl shader code. </p>

<p class="definition">Definition at line <a class="el" href="default__shader_8h_source.html#l00066">66</a> of file <a class="el" href="default__shader_8h_source.html">default_shader.h</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/<a class="el" href="default__shader_8h_source.html">default_shader.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.9.1
</small></address>
</body>
</html>