Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MyOpenGLWidget::loadTexture()
- {
- if (eof == true)
- return;
- img_data = SOIL_load_image(path, &width, &height, &channels, SOIL_LOAD_RGB);
- glEnable(GL_TEXTURE_2D);
- glGenTextures(1, &texture); // exception thrown here
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, img_data);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- SOIL_free_image_data(img_data);
- }
- void MyOpenGLWidget::initializeGL()
- {
- initializeOpenGLFunctions();
- // some other code here
- }
- class MyGLThread : public QThread
- {
- Q_OBJECT
- public:
- MyGLThread();
- ~MyGLThread();
- void init(MyOpenGLWidget* widget);
- void loadTexture();
- // some other code here
- protected:
- virtual void run();
- private:
- MyOpenGLWidget* gl_widget;
- };
- MyGLThread::MyGLThread()
- {
- gl_widget = nullptr;
- }
- MyGLThread::~MyGLThread()
- {
- }
- void MyGLThread::init(MyOpenGLWidget * widget)
- {
- gl_widget = widget;
- }
- void GLThread::loadTexture()
- {
- gl_widget->loadTexture();
- }
- void MyGLThread::run()
- {
- while (true) {
- if (!gl_widget)
- continue;
- loadTexture();
- msleep(30);
- }
- }
- INSlides::INSlides(QWidget *parent)
- : QMainWindow(parent)
- {
- ui.setupUi(this);
- extractor_thread = new ExtractorThread(); // thread used to extract images
- extractor_thread->start();
- gl_widget = new MyOpenGLWidget(this);
- gl_widget->setGeometry(100, 100, 1280, 720);
- gl_thread = new MyGLThread();
- gl_thread->init(gl_widget);
- gl_thread->start();
- connect(ui.openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement