Moved obj and mtl file loading to main instead

This commit is contained in:
Muaz Ahmad 2023-05-04 15:43:30 +05:00
parent 22d1b57a48
commit 26336815b4
3 changed files with 5 additions and 4 deletions

View file

@ -8,6 +8,7 @@ class OPGLWidget : public QOpenGLWidget
Q_OBJECT Q_OBJECT
public: public:
OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {} OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {}
ObjectLoader obj;
public slots: public slots:
void paintGL(); void paintGL();
void update_camera(); void update_camera();
@ -29,7 +30,6 @@ protected:
float right[3] = {1, 0, 0}; float right[3] = {1, 0, 0};
float vel[3] = {0, 0, 0}; float vel[3] = {0, 0, 0};
float speed = 0; float speed = 0;
ObjectLoader obj;
bool key_states[6] = {false, false, false, false, false, false}; bool key_states[6] = {false, false, false, false, false, false};
float mouse_loc_old[2]; float mouse_loc_old[2];
}; };

View file

@ -8,6 +8,10 @@ int main(int argc, char **argv) {
QMainWindow w; QMainWindow w;
Ui::MainWindow ui; Ui::MainWindow ui;
ui.setupUi(&w); ui.setupUi(&w);
ui.openGLWidget->obj.load_mtl("untitled.mtl");
ui.openGLWidget->obj.load_obj("untitled.obj");
QTimer timer_draw; QTimer timer_draw;
QTimer timer_cam; QTimer timer_cam;
w.connect(&timer_draw, SIGNAL(timeout()), ui.openGLWidget, SLOT(paintGL())); w.connect(&timer_draw, SIGNAL(timeout()), ui.openGLWidget, SLOT(paintGL()));

View file

@ -21,9 +21,6 @@ void OPGLWidget::initializeGL() {
glLightfv(GL_LIGHT0, GL_SPECULAR, light_array); glLightfv(GL_LIGHT0, GL_SPECULAR, light_array);
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);
obj.load_mtl("untitled.mtl");
obj.load_obj("untitled.obj");
} }
void OPGLWidget::paintGL() { void OPGLWidget::paintGL() {