Iterators now use size_t, light parameters changed

This commit is contained in:
Muaz Ahmad 2023-08-03 13:55:58 +05:00
parent 3fb63a2887
commit 509e94ac58
2 changed files with 13 additions and 8 deletions

View file

@ -86,9 +86,11 @@ void ObjectLoader::load_obj(string filename) {
};
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) {
return &(mtls[i]);
};
};
};
}

View file

@ -14,11 +14,13 @@ void OPGLWidget::initializeGL() {
glMatrixMode(GL_MODELVIEW);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
GLfloat light_array[] = {0.4, 0.4, 0.4, 0.4};
GLfloat light_position[] = {10.0, 20.0, 10.0, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, light_array);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_array);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_array);
GLfloat light_ambient[] = {0.0, 0.0, 0.0, 1.0};
GLfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat light_specular[] = {0.0, 0.5, 0.5, 0.2};
GLfloat light_position[] = {4.0, 1.0, 6.0, 1.0};
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);
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);
glLoadIdentity();
reorient();
glShadeModel(GL_SMOOTH);
glPolygonMode(GL_FRONT, GL_FILL);
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;
if (mtl_idx != mtl_ptr->idx) {
glMaterialfv(GL_FRONT, GL_AMBIENT, mtl_ptr -> ambient);