Iterators now use size_t, light parameters changed
This commit is contained in:
parent
3fb63a2887
commit
509e94ac58
2 changed files with 13 additions and 8 deletions
|
@ -86,9 +86,11 @@ void ObjectLoader::load_obj(string filename) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Material* ObjectLoader::get_mtl_ptr(string mtl_name) {
|
Material* ObjectLoader::get_mtl_ptr(string mtl_name) {
|
||||||
for (int i = 0; i < mtls.size(); i++) {
|
for (size_t i = 0; i < mtls.size(); i++) {
|
||||||
if (mtls[i].name == mtl_name) {
|
if (mtls[i].name == mtl_name) {
|
||||||
return &(mtls[i]);
|
return &(mtls[i]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,13 @@ void OPGLWidget::initializeGL() {
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
GLfloat light_array[] = {0.4, 0.4, 0.4, 0.4};
|
GLfloat light_ambient[] = {0.0, 0.0, 0.0, 1.0};
|
||||||
GLfloat light_position[] = {10.0, 20.0, 10.0, 1.0};
|
GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, light_array);
|
GLfloat light_specular[] = {0.0, 0.5, 0.5, 0.2};
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_array);
|
GLfloat light_position[] = {4.0, 1.0, 6.0, 1.0};
|
||||||
glLightfv(GL_LIGHT0, GL_SPECULAR, light_array);
|
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
|
||||||
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
|
||||||
|
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
|
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
@ -27,9 +29,10 @@ void OPGLWidget::paintGL() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
reorient();
|
reorient();
|
||||||
|
glShadeModel(GL_SMOOTH);
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
glPolygonMode(GL_FRONT, GL_FILL);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
for (int i = 0; i < obj.faces.size(); i++) {
|
for (size_t i = 0; i < obj.faces.size(); i++) {
|
||||||
Material* mtl_ptr = obj.faces[i].mtl;
|
Material* mtl_ptr = obj.faces[i].mtl;
|
||||||
if (mtl_idx != mtl_ptr->idx) {
|
if (mtl_idx != mtl_ptr->idx) {
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT, mtl_ptr -> ambient);
|
glMaterialfv(GL_FRONT, GL_AMBIENT, mtl_ptr -> ambient);
|
||||||
|
|
Loading…
Reference in a new issue