From 26336815b4c976c1da393a71078dc6e93adef3da Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Thu, 4 May 2023 15:43:30 +0500 Subject: [PATCH] Moved obj and mtl file loading to main instead --- include/opglwidget.h | 2 +- src/main.cpp | 4 ++++ src/opglwidget.cpp | 3 --- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/opglwidget.h b/include/opglwidget.h index 10f6908..b4179ca 100644 --- a/include/opglwidget.h +++ b/include/opglwidget.h @@ -8,6 +8,7 @@ class OPGLWidget : public QOpenGLWidget Q_OBJECT public: OPGLWidget(QWidget *parent) : QOpenGLWidget(parent) {} + ObjectLoader obj; public slots: void paintGL(); void update_camera(); @@ -29,7 +30,6 @@ protected: float right[3] = {1, 0, 0}; float vel[3] = {0, 0, 0}; float speed = 0; - ObjectLoader obj; bool key_states[6] = {false, false, false, false, false, false}; float mouse_loc_old[2]; }; diff --git a/src/main.cpp b/src/main.cpp index b9945c2..e1a7d0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,10 @@ int main(int argc, char **argv) { QMainWindow w; Ui::MainWindow ui; ui.setupUi(&w); + + ui.openGLWidget->obj.load_mtl("untitled.mtl"); + ui.openGLWidget->obj.load_obj("untitled.obj"); + QTimer timer_draw; QTimer timer_cam; w.connect(&timer_draw, SIGNAL(timeout()), ui.openGLWidget, SLOT(paintGL())); diff --git a/src/opglwidget.cpp b/src/opglwidget.cpp index ad038f2..23731be 100644 --- a/src/opglwidget.cpp +++ b/src/opglwidget.cpp @@ -21,9 +21,6 @@ void OPGLWidget::initializeGL() { glLightfv(GL_LIGHT0, GL_SPECULAR, light_array); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - - obj.load_mtl("untitled.mtl"); - obj.load_obj("untitled.obj"); } void OPGLWidget::paintGL() {