Mercurial > hg > forks > gldragon
comparison gldragon.cpp @ 32:1215fdd0a8ab
Add support for specifying specular and shininess values per model.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 22 Nov 2019 22:57:14 +0200 |
parents | 6847715b46cd |
children | d640f2a34031 |
comparison
equal
deleted
inserted
replaced
31:6847715b46cd | 32:1215fdd0a8ab |
---|---|
163 | 163 |
164 | 164 |
165 void dmDrawModel(const DMModel &model) | 165 void dmDrawModel(const DMModel &model) |
166 { | 166 { |
167 int maxIndices; | 167 int maxIndices; |
168 | |
169 glEnable(GL_COLOR_MATERIAL); | |
170 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); | |
171 glMateriali(GL_FRONT, GL_SHININESS, model.shininess); | |
172 glMaterialfv(GL_FRONT, GL_SPECULAR, model.specular.values); | |
168 | 173 |
169 // Render the model | 174 // Render the model |
170 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); | 175 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); |
171 | 176 |
172 // Add transforms | 177 // Add transforms |
466 | 471 |
467 dmLinkModelShaders(model); | 472 dmLinkModelShaders(model); |
468 } | 473 } |
469 } | 474 } |
470 | 475 |
471 // ... | |
472 { | |
473 float specReflection[] = { 0.8f, 0.8f, 0.8f, 1.0f }; | |
474 glEnable(GL_COLOR_MATERIAL); | |
475 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); | |
476 glMateriali(GL_FRONT, GL_SHININESS, 96); | |
477 glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection); | |
478 } | |
479 | |
480 // Setup lights | 476 // Setup lights |
481 for (size_t n = 0; n < scene.lights.size(); n++) | 477 for (size_t n = 0; n < scene.lights.size(); n++) |
482 dmSetupLight(n, scene.lights[n]); | 478 dmSetupLight(n, scene.lights[n]); |
483 | 479 |
484 // Define the camera | 480 // Define the camera |