comparison gldragon.cpp @ 48:0ae1ff609626

Implement diffuse setting for models in scenefile. Also refactor parsing/handling of ambient/diffuse/specular values and unify it for both models and lights.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Dec 2019 01:12:23 +0200
parents 9909014498f0
children 2e2c3fe311da
comparison
equal deleted inserted replaced
47:9909014498f0 48:0ae1ff609626
245 } 245 }
246 246
247 // Set the material of the model 247 // Set the material of the model
248 glEnable(GL_COLOR_MATERIAL); 248 glEnable(GL_COLOR_MATERIAL);
249 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); 249 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
250 glMateriali(GL_FRONT, GL_SHININESS, model.shininess); 250 glMateriali(GL_FRONT, GL_SHININESS, model.material.shininess);
251 glMaterialfv(GL_FRONT, GL_SPECULAR, model.specular.values); 251 glMaterialfv(GL_FRONT, GL_SPECULAR, model.material.specular.values);
252 glColor4fv(model.diffuse.values); 252 glColor4fv(model.material.diffuse.values);
253 253
254 // Render the model 254 // Render the model
255 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); 255 glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices);
256 256
257 // Add transforms 257 // Add transforms
378 378
379 379
380 void dmSetupLight(const int n, const DMLight &light) 380 void dmSetupLight(const int n, const DMLight &light)
381 { 381 {
382 glEnable(GL_LIGHT0 + n); 382 glEnable(GL_LIGHT0 + n);
383 glLightfv(GL_LIGHT0 + n, GL_AMBIENT, light.ambient.values); 383 glLightfv(GL_LIGHT0 + n, GL_AMBIENT, light.color.ambient.values);
384 glLightfv(GL_LIGHT0 + n, GL_DIFFUSE, light.diffuse.values); 384 glLightfv(GL_LIGHT0 + n, GL_DIFFUSE, light.color.diffuse.values);
385 glLightfv(GL_LIGHT0 + n, GL_SPECULAR, light.specular.values); 385 glLightfv(GL_LIGHT0 + n, GL_SPECULAR, light.color.specular.values);
386 glLightfv(GL_LIGHT0 + n, GL_POSITION, light.position.values); 386 glLightfv(GL_LIGHT0 + n, GL_POSITION, light.position.values);
387 } 387 }
388 388
389 389
390 int main(int argc, char *argv[]) 390 int main(int argc, char *argv[])