Set clang-format argument options.
This commit is contained in:
		
							parent
							
								
									7fac6bafb4
								
							
						
					
					
						commit
						c86a7744b3
					
				@ -9,7 +9,6 @@ AlignEscapedNewlines: Left
 | 
				
			|||||||
AlignOperands: Align
 | 
					AlignOperands: Align
 | 
				
			||||||
AlignTrailingComments: true
 | 
					AlignTrailingComments: true
 | 
				
			||||||
AllowAllArgumentsOnNextLine: true
 | 
					AllowAllArgumentsOnNextLine: true
 | 
				
			||||||
AllowAllParametersOfDeclarationOnNextLine: true
 | 
					 | 
				
			||||||
AllowShortBlocksOnASingleLine: Never
 | 
					AllowShortBlocksOnASingleLine: Never
 | 
				
			||||||
AllowShortCaseLabelsOnASingleLine: false
 | 
					AllowShortCaseLabelsOnASingleLine: false
 | 
				
			||||||
AllowShortFunctionsOnASingleLine: Inline
 | 
					AllowShortFunctionsOnASingleLine: Inline
 | 
				
			||||||
@ -21,8 +20,10 @@ InsertBraces: true
 | 
				
			|||||||
IndentAccessModifiers: true
 | 
					IndentAccessModifiers: true
 | 
				
			||||||
EmptyLineAfterAccessModifier: Never
 | 
					EmptyLineAfterAccessModifier: Never
 | 
				
			||||||
EmptyLineBeforeAccessModifier: LogicalBlock
 | 
					EmptyLineBeforeAccessModifier: LogicalBlock
 | 
				
			||||||
BinPackArguments: true
 | 
					BinPackArguments: false
 | 
				
			||||||
BinPackParameters: true
 | 
					BinPackParameters: false
 | 
				
			||||||
 | 
					AllowAllParametersOfDeclarationOnNextLine: true
 | 
				
			||||||
 | 
					ExperimentalAutoDetectBinPacking: false
 | 
				
			||||||
BreakBeforeBraces: Linux
 | 
					BreakBeforeBraces: Linux
 | 
				
			||||||
BreakBeforeBinaryOperators: NonAssignment
 | 
					BreakBeforeBinaryOperators: NonAssignment
 | 
				
			||||||
BreakBeforeTernaryOperators: true
 | 
					BreakBeforeTernaryOperators: true
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,8 @@ DebugConsole::DebugConsole(QWidget * owner, const QString & key) :
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DebugConsole::DebugConsole(QWidget * owner, const QString & key,
 | 
					DebugConsole::DebugConsole(QWidget * owner,
 | 
				
			||||||
 | 
					                           const QString & key,
 | 
				
			||||||
                           const QString & name)
 | 
					                           const QString & name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ui_ = new Ui::DebugConsole;
 | 
					  ui_ = new Ui::DebugConsole;
 | 
				
			||||||
 | 
				
			|||||||
@ -36,9 +36,13 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent)
 | 
				
			|||||||
    // Add GUI 'view' toolbar option to show debug console.
 | 
					    // Add GUI 'view' toolbar option to show debug console.
 | 
				
			||||||
    ui_->menuView->addAction(qtkWidget->getActionToggleConsole());
 | 
					    ui_->menuView->addAction(qtkWidget->getActionToggleConsole());
 | 
				
			||||||
    // Refresh GUI widgets when scene or objects are updated.
 | 
					    // Refresh GUI widgets when scene or objects are updated.
 | 
				
			||||||
    connect(qtkWidget->getScene(), &Qtk::Scene::sceneUpdated, this,
 | 
					    connect(qtkWidget->getScene(),
 | 
				
			||||||
 | 
					            &Qtk::Scene::sceneUpdated,
 | 
				
			||||||
 | 
					            this,
 | 
				
			||||||
            &MainWindow::refreshScene);
 | 
					            &MainWindow::refreshScene);
 | 
				
			||||||
    connect(qtkWidget, &Qtk::QtkWidget::objectFocusChanged, ui_->qtk__ToolBox,
 | 
					    connect(qtkWidget,
 | 
				
			||||||
 | 
					            &Qtk::QtkWidget::objectFocusChanged,
 | 
				
			||||||
 | 
					            ui_->qtk__ToolBox,
 | 
				
			||||||
            &Qtk::ToolBox::updateFocus);
 | 
					            &Qtk::ToolBox::updateFocus);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -231,9 +231,10 @@ void QtkScene::init()
 | 
				
			|||||||
  // Building more complex objects for showing examples of lighting techniques
 | 
					  // Building more complex objects for showing examples of lighting techniques
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Test alien Model with phong lighting and specular mapping. */
 | 
					  /* Test alien Model with phong lighting and specular mapping. */
 | 
				
			||||||
  model = addObject(new Qtk::Model(
 | 
					  model = addObject(new Qtk::Model("alienTest",
 | 
				
			||||||
      "alienTest", ":/models/models/alien-hominid/alien.obj",
 | 
					                                   ":/models/models/alien-hominid/alien.obj",
 | 
				
			||||||
      ":/shaders/model-specular.vert", ":/shaders/model-specular.frag"));
 | 
					                                   ":/shaders/model-specular.vert",
 | 
				
			||||||
 | 
					                                   ":/shaders/model-specular.frag"));
 | 
				
			||||||
  model->getTransform().setTranslation(3.0f, -1.0f, 10.0f);
 | 
					  model->getTransform().setTranslation(3.0f, -1.0f, 10.0f);
 | 
				
			||||||
  model->getTransform().scale(0.15f);
 | 
					  model->getTransform().scale(0.15f);
 | 
				
			||||||
  model->setUniform("uMaterial.ambient", QVector3D(1.0f, 1.0f, 1.0f));
 | 
					  model->setUniform("uMaterial.ambient", QVector3D(1.0f, 1.0f, 1.0f));
 | 
				
			||||||
@ -257,9 +258,10 @@ void QtkScene::init()
 | 
				
			|||||||
  mesh->setColor(GREEN);
 | 
					  mesh->setColor(GREEN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Test spartan Model with phong lighting, specular and normal mapping. */
 | 
					  /* Test spartan Model with phong lighting, specular and normal mapping. */
 | 
				
			||||||
  model = addObject(new Qtk::Model(
 | 
					  model = addObject(new Qtk::Model("spartanTest",
 | 
				
			||||||
      "spartanTest", ":/models/models/spartan/spartan.obj",
 | 
					                                   ":/models/models/spartan/spartan.obj",
 | 
				
			||||||
      ":/shaders/model-normals.vert", ":/shaders/model-normals.frag"));
 | 
					                                   ":/shaders/model-normals.vert",
 | 
				
			||||||
 | 
					                                   ":/shaders/model-normals.frag"));
 | 
				
			||||||
  model->getTransform().setTranslation(0.0f, -1.0f, 10.0f);
 | 
					  model->getTransform().setTranslation(0.0f, -1.0f, 10.0f);
 | 
				
			||||||
  model->getTransform().scale(2.0f);
 | 
					  model->getTransform().scale(2.0f);
 | 
				
			||||||
  model->setUniform("uMaterial.ambient", QVector3D(1.0f, 1.0f, 1.0f));
 | 
					  model->setUniform("uMaterial.ambient", QVector3D(1.0f, 1.0f, 1.0f));
 | 
				
			||||||
@ -493,8 +495,8 @@ void QtkScene::update()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Rotate lighting example cubes
 | 
					  // Rotate lighting example cubes
 | 
				
			||||||
  mTestPhong->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
					  mTestPhong->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
				
			||||||
  MeshRenderer::getInstance("noLight")->getTransform().rotate(0.75f, 0.5f, 0.3f,
 | 
					  MeshRenderer::getInstance("noLight")->getTransform().rotate(
 | 
				
			||||||
                                                              0.2f);
 | 
					      0.75f, 0.5f, 0.3f, 0.2f);
 | 
				
			||||||
  mTestAmbient->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
					  mTestAmbient->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
				
			||||||
  mTestDiffuse->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
					  mTestDiffuse->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
				
			||||||
  mTestSpecular->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
					  mTestSpecular->getTransform().rotate(0.75f, 0.5f, 0.3f, 0.2f);
 | 
				
			||||||
 | 
				
			|||||||
@ -88,7 +88,9 @@ void QtkWidget::initializeGL()
 | 
				
			|||||||
  mDebugLogger = new QOpenGLDebugLogger(this);
 | 
					  mDebugLogger = new QOpenGLDebugLogger(this);
 | 
				
			||||||
  if (mDebugLogger->initialize()) {
 | 
					  if (mDebugLogger->initialize()) {
 | 
				
			||||||
    qDebug() << "GL_DEBUG Debug Logger" << mDebugLogger << "\n";
 | 
					    qDebug() << "GL_DEBUG Debug Logger" << mDebugLogger << "\n";
 | 
				
			||||||
    connect(mDebugLogger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this,
 | 
					    connect(mDebugLogger,
 | 
				
			||||||
 | 
					            SIGNAL(messageLogged(QOpenGLDebugMessage)),
 | 
				
			||||||
 | 
					            this,
 | 
				
			||||||
            SLOT(messageLogged(QOpenGLDebugMessage)));
 | 
					            SLOT(messageLogged(QOpenGLDebugMessage)));
 | 
				
			||||||
    mDebugLogger->startLogging();
 | 
					    mDebugLogger->startLogging();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -109,8 +111,8 @@ void QtkWidget::initializeGL()
 | 
				
			|||||||
void QtkWidget::resizeGL(int width, int height)
 | 
					void QtkWidget::resizeGL(int width, int height)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  Scene::getProjectionMatrix().setToIdentity();
 | 
					  Scene::getProjectionMatrix().setToIdentity();
 | 
				
			||||||
  Scene::getProjectionMatrix().perspective(45.0f, float(width) / float(height),
 | 
					  Scene::getProjectionMatrix().perspective(
 | 
				
			||||||
                                           0.1f, 1000.0f);
 | 
					      45.0f, float(width) / float(height), 0.1f, 1000.0f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QtkWidget::paintGL()
 | 
					void QtkWidget::paintGL()
 | 
				
			||||||
@ -126,7 +128,9 @@ void QtkWidget::setScene(Scene * scene)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  if (mScene != Q_NULLPTR) {
 | 
					  if (mScene != Q_NULLPTR) {
 | 
				
			||||||
    delete mScene;
 | 
					    delete mScene;
 | 
				
			||||||
    connect(scene, &Scene::sceneUpdated, MainWindow::getMainWindow(),
 | 
					    connect(scene,
 | 
				
			||||||
 | 
					            &Scene::sceneUpdated,
 | 
				
			||||||
 | 
					            MainWindow::getMainWindow(),
 | 
				
			||||||
            &MainWindow::refreshScene);
 | 
					            &MainWindow::refreshScene);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -74,13 +74,19 @@ void ToolBox::createPageProperties(const Object * object)
 | 
				
			|||||||
    rowLayout->addWidget(spinBox);
 | 
					    rowLayout->addWidget(spinBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (i == 0) {
 | 
					    if (i == 0) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(spinBox,
 | 
				
			||||||
 | 
					              &QDoubleSpinBox::valueChanged,
 | 
				
			||||||
 | 
					              object,
 | 
				
			||||||
              &Object::setTranslationX);
 | 
					              &Object::setTranslationX);
 | 
				
			||||||
    } else if (i == 1) {
 | 
					    } else if (i == 1) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(spinBox,
 | 
				
			||||||
 | 
					              &QDoubleSpinBox::valueChanged,
 | 
				
			||||||
 | 
					              object,
 | 
				
			||||||
              &Object::setTranslationY);
 | 
					              &Object::setTranslationY);
 | 
				
			||||||
    } else if (i == 2) {
 | 
					    } else if (i == 2) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(spinBox,
 | 
				
			||||||
 | 
					              &QDoubleSpinBox::valueChanged,
 | 
				
			||||||
 | 
					              object,
 | 
				
			||||||
              &Object::setTranslationZ);
 | 
					              &Object::setTranslationZ);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -97,14 +103,14 @@ void ToolBox::createPageProperties(const Object * object)
 | 
				
			|||||||
    rowLayout->addWidget(spinBox);
 | 
					    rowLayout->addWidget(spinBox);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (i == 0) {
 | 
					    if (i == 0) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(
 | 
				
			||||||
              &Object::setScaleX);
 | 
					          spinBox, &QDoubleSpinBox::valueChanged, object, &Object::setScaleX);
 | 
				
			||||||
    } else if (i == 1) {
 | 
					    } else if (i == 1) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(
 | 
				
			||||||
              &Object::setScaleY);
 | 
					          spinBox, &QDoubleSpinBox::valueChanged, object, &Object::setScaleY);
 | 
				
			||||||
    } else if (i == 2) {
 | 
					    } else if (i == 2) {
 | 
				
			||||||
      connect(spinBox, &QDoubleSpinBox::valueChanged, object,
 | 
					      connect(
 | 
				
			||||||
              &Object::setScaleZ);
 | 
					          spinBox, &QDoubleSpinBox::valueChanged, object, &Object::setScaleZ);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  layout->addRow(rowLayout);
 | 
					  layout->addRow(rowLayout);
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,9 @@ Qtk::TreeView::TreeView(QWidget * parent) :
 | 
				
			|||||||
    QDockWidget(parent), ui(new Ui::TreeView)
 | 
					    QDockWidget(parent), ui(new Ui::TreeView)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ui->setupUi(this);
 | 
					  ui->setupUi(this);
 | 
				
			||||||
  connect(ui->treeWidget, &QTreeWidget::itemDoubleClicked, this,
 | 
					  connect(ui->treeWidget,
 | 
				
			||||||
 | 
					          &QTreeWidget::itemDoubleClicked,
 | 
				
			||||||
 | 
					          this,
 | 
				
			||||||
          &TreeView::itemFocus);
 | 
					          &TreeView::itemFocus);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,9 @@
 | 
				
			|||||||
 * Constructors, Destructors
 | 
					 * Constructors, Destructors
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WidgetPlugin::WidgetPlugin(QString group, QString class_name, QString include,
 | 
					WidgetPlugin::WidgetPlugin(QString group,
 | 
				
			||||||
 | 
					                           QString class_name,
 | 
				
			||||||
 | 
					                           QString include,
 | 
				
			||||||
                           WidgetPlugin::Factory factory) :
 | 
					                           WidgetPlugin::Factory factory) :
 | 
				
			||||||
    m_group(std::move(group)), m_className(std::move(class_name)),
 | 
					    m_group(std::move(group)), m_className(std::move(class_name)),
 | 
				
			||||||
    m_includeFile(std::move(include)), m_factory(std::move(factory)),
 | 
					    m_includeFile(std::move(include)), m_factory(std::move(factory)),
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,9 @@ class QDESIGNER_WIDGET_EXPORT WidgetPlugin :
 | 
				
			|||||||
     * Contructors / Destructors
 | 
					     * Contructors / Destructors
 | 
				
			||||||
     **************************************************************************/
 | 
					     **************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WidgetPlugin(QString group, QString class_name, QString include,
 | 
					    WidgetPlugin(QString group,
 | 
				
			||||||
 | 
					                 QString class_name,
 | 
				
			||||||
 | 
					                 QString include,
 | 
				
			||||||
                 Factory factory);
 | 
					                 Factory factory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    explicit WidgetPlugin(QObject * parent = nullptr);
 | 
					    explicit WidgetPlugin(QObject * parent = nullptr);
 | 
				
			||||||
 | 
				
			|||||||
@ -23,13 +23,19 @@ WidgetPluginCollection::WidgetPluginCollection(QObject * parent) :
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  m_collection = {
 | 
					  m_collection = {
 | 
				
			||||||
      new WidgetPlugin(
 | 
					      new WidgetPlugin(
 | 
				
			||||||
          m_collectionName, "Qtk::QtkWidget", "qtkwidget.h",
 | 
					          m_collectionName,
 | 
				
			||||||
 | 
					          "Qtk::QtkWidget",
 | 
				
			||||||
 | 
					          "qtkwidget.h",
 | 
				
			||||||
          [](QWidget * parent) { return new Qtk::QtkWidget(parent); }),
 | 
					          [](QWidget * parent) { return new Qtk::QtkWidget(parent); }),
 | 
				
			||||||
      new WidgetPlugin(
 | 
					      new WidgetPlugin(
 | 
				
			||||||
          m_collectionName, "Qtk::TreeView", "treeview.h",
 | 
					          m_collectionName,
 | 
				
			||||||
 | 
					          "Qtk::TreeView",
 | 
				
			||||||
 | 
					          "treeview.h",
 | 
				
			||||||
          [](QWidget * parent) { return new Qtk::TreeView(parent); }),
 | 
					          [](QWidget * parent) { return new Qtk::TreeView(parent); }),
 | 
				
			||||||
      new WidgetPlugin(
 | 
					      new WidgetPlugin(
 | 
				
			||||||
          m_collectionName, "Qtk::ToolBox", "toolbox.h",
 | 
					          m_collectionName,
 | 
				
			||||||
 | 
					          "Qtk::ToolBox",
 | 
				
			||||||
 | 
					          "toolbox.h",
 | 
				
			||||||
          [](QWidget * parent) { return new Qtk::ToolBox(parent); }),
 | 
					          [](QWidget * parent) { return new Qtk::ToolBox(parent); }),
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -21,8 +21,10 @@ Qtk::MeshRenderer::MeshManager Qtk::MeshRenderer::sInstances;
 | 
				
			|||||||
 * Constructors / Destructors
 | 
					 * Constructors / Destructors
 | 
				
			||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MeshRenderer::MeshRenderer(const char * name, Vertices vertices,
 | 
					MeshRenderer::MeshRenderer(const char * name,
 | 
				
			||||||
                           Indices indices, DrawMode mode) :
 | 
					                           Vertices vertices,
 | 
				
			||||||
 | 
					                           Indices indices,
 | 
				
			||||||
 | 
					                           DrawMode mode) :
 | 
				
			||||||
    MeshRenderer(name, ShapeBase(mode, std::move(vertices), std::move(indices)))
 | 
					    MeshRenderer(name, ShapeBase(mode, std::move(vertices), std::move(indices)))
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -90,9 +92,11 @@ void MeshRenderer::init()
 | 
				
			|||||||
  mProgram.setAttributeBuffer(0, GL_FLOAT, 0, 3, sizeof(QVector3D));
 | 
					  mProgram.setAttributeBuffer(0, GL_FLOAT, 0, 3, sizeof(QVector3D));
 | 
				
			||||||
  // Enable color attribute, setting offset to total size of vertices()
 | 
					  // Enable color attribute, setting offset to total size of vertices()
 | 
				
			||||||
  mProgram.enableAttributeArray(1);
 | 
					  mProgram.enableAttributeArray(1);
 | 
				
			||||||
  mProgram.setAttributeBuffer(1, GL_FLOAT,
 | 
					  mProgram.setAttributeBuffer(1,
 | 
				
			||||||
 | 
					                              GL_FLOAT,
 | 
				
			||||||
                              getVertices().size() * sizeof(getVertices()[0]),
 | 
					                              getVertices().size() * sizeof(getVertices()[0]),
 | 
				
			||||||
                              3, sizeof(QVector3D));
 | 
					                              3,
 | 
				
			||||||
 | 
					                              sizeof(QVector3D));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mVBO.release();
 | 
					  mVBO.release();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -116,7 +120,9 @@ void MeshRenderer::draw()
 | 
				
			|||||||
    glDrawArrays(mDrawType, 0, getVertices().size());
 | 
					    glDrawArrays(mDrawType, 0, getVertices().size());
 | 
				
			||||||
  } else if (mShape.mDrawMode == QTK_DRAW_ELEMENTS
 | 
					  } else if (mShape.mDrawMode == QTK_DRAW_ELEMENTS
 | 
				
			||||||
             || mShape.mDrawMode == QTK_DRAW_ELEMENTS_NORMALS) {
 | 
					             || mShape.mDrawMode == QTK_DRAW_ELEMENTS_NORMALS) {
 | 
				
			||||||
    glDrawElements(mDrawType, mShape.mIndices.size(), GL_UNSIGNED_INT,
 | 
					    glDrawElements(mDrawType,
 | 
				
			||||||
 | 
					                   mShape.mIndices.size(),
 | 
				
			||||||
 | 
					                   GL_UNSIGNED_INT,
 | 
				
			||||||
                   mShape.mIndices.data());
 | 
					                   mShape.mIndices.data());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -179,7 +185,8 @@ void MeshRenderer::setShaders(const std::string & vert,
 | 
				
			|||||||
  init();
 | 
					  init();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MeshRenderer::setUniformMVP(const char * model, const char * view,
 | 
					void MeshRenderer::setUniformMVP(const char * model,
 | 
				
			||||||
 | 
					                                 const char * view,
 | 
				
			||||||
                                 const char * projection)
 | 
					                                 const char * projection)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ShaderBindScope lock(&mProgram, mBound);
 | 
					  ShaderBindScope lock(&mProgram, mBound);
 | 
				
			||||||
@ -209,8 +216,8 @@ void MeshRenderer::setColor(const QVector3D & color)
 | 
				
			|||||||
  init();
 | 
					  init();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MeshRenderer::setAttributeBuffer(int location, GLenum type, int offset,
 | 
					void MeshRenderer::setAttributeBuffer(
 | 
				
			||||||
                                      int tupleSize, int stride)
 | 
					    int location, GLenum type, int offset, int tupleSize, int stride)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ShaderBindScope lock(&mProgram, mBound);
 | 
					  ShaderBindScope lock(&mProgram, mBound);
 | 
				
			||||||
  mVAO.bind();
 | 
					  mVAO.bind();
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,9 @@ namespace Qtk
 | 
				
			|||||||
       * @param indices Indicess to use for initializes geometry shape.
 | 
					       * @param indices Indicess to use for initializes geometry shape.
 | 
				
			||||||
       * @param mode OpenGL draw mode. Supported modes are prefixed with QTK_*
 | 
					       * @param mode OpenGL draw mode. Supported modes are prefixed with QTK_*
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      MeshRenderer(const char * name, Vertices vertices, Indices indices,
 | 
					      MeshRenderer(const char * name,
 | 
				
			||||||
 | 
					                   Vertices vertices,
 | 
				
			||||||
 | 
					                   Indices indices,
 | 
				
			||||||
                   DrawMode mode = QTK_DRAW_ARRAYS);
 | 
					                   DrawMode mode = QTK_DRAW_ARRAYS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
@ -197,8 +199,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param stride Stride between groups of elements in the buffer.
 | 
					       * @param stride Stride between groups of elements in the buffer.
 | 
				
			||||||
       *    For example (x, y) data stride is `2 * sizeof(type)`
 | 
					       *    For example (x, y) data stride is `2 * sizeof(type)`
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      void setAttributeBuffer(int location, GLenum type, int offset,
 | 
					      void setAttributeBuffer(
 | 
				
			||||||
                              int tupleSize, int stride = 0);
 | 
					          int location, GLenum type, int offset, int tupleSize, int stride = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
       * Accessors
 | 
					       * Accessors
 | 
				
			||||||
 | 
				
			|||||||
@ -80,8 +80,8 @@ void Model::loadModel(const std::string & path)
 | 
				
			|||||||
  // + And flipping texture UVs, etc..
 | 
					  // + And flipping texture UVs, etc..
 | 
				
			||||||
  // Assimp options: http://assimp.sourceforge.net/lib_html/postprocess_8h.html
 | 
					  // Assimp options: http://assimp.sourceforge.net/lib_html/postprocess_8h.html
 | 
				
			||||||
  const aiScene * scene = import.ReadFile(
 | 
					  const aiScene * scene = import.ReadFile(
 | 
				
			||||||
      path.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs
 | 
					      path.c_str(),
 | 
				
			||||||
                        | aiProcess_GenSmoothNormals
 | 
					      aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenSmoothNormals
 | 
				
			||||||
          | aiProcess_CalcTangentSpace | aiProcess_OptimizeMeshes
 | 
					          | aiProcess_CalcTangentSpace | aiProcess_OptimizeMeshes
 | 
				
			||||||
          | aiProcess_SplitLargeMeshes);
 | 
					          | aiProcess_SplitLargeMeshes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -208,7 +208,10 @@ ModelMesh Model::processMesh(aiMesh * mesh, const aiScene * scene)
 | 
				
			|||||||
    textures.insert(textures.end(), normalMaps.begin(), normalMaps.end());
 | 
					    textures.insert(textures.end(), normalMaps.begin(), normalMaps.end());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {vertices, indices, textures, mVertexShader.c_str(),
 | 
					  return {vertices,
 | 
				
			||||||
 | 
					          indices,
 | 
				
			||||||
 | 
					          textures,
 | 
				
			||||||
 | 
					          mVertexShader.c_str(),
 | 
				
			||||||
          mFragmentShader.c_str()};
 | 
					          mFragmentShader.c_str()};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -239,7 +242,8 @@ ModelMesh::Textures Model::loadMaterialTextures(aiMaterial * mat,
 | 
				
			|||||||
    if (!skip) {
 | 
					    if (!skip) {
 | 
				
			||||||
      ModelTexture texture;
 | 
					      ModelTexture texture;
 | 
				
			||||||
      texture.mTexture = OpenGLTextureFactory::initTexture(
 | 
					      texture.mTexture = OpenGLTextureFactory::initTexture(
 | 
				
			||||||
          std::string(mDirectory + '/' + fileName.C_Str()).c_str(), false,
 | 
					          std::string(mDirectory + '/' + fileName.C_Str()).c_str(),
 | 
				
			||||||
 | 
					          false,
 | 
				
			||||||
          false);
 | 
					          false);
 | 
				
			||||||
      texture.mID = texture.mTexture->textureId();
 | 
					      texture.mID = texture.mTexture->textureId();
 | 
				
			||||||
      texture.mType = typeName;
 | 
					      texture.mType = typeName;
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param vertexShader Optional path to custom vertex shader.
 | 
					       * @param vertexShader Optional path to custom vertex shader.
 | 
				
			||||||
       * @param fragmentShader Optional path to custom fragment shader.
 | 
					       * @param fragmentShader Optional path to custom fragment shader.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      inline Model(const char * name, const char * path,
 | 
					      inline Model(const char * name,
 | 
				
			||||||
 | 
					                   const char * path,
 | 
				
			||||||
                   const char * vertexShader = ":/shaders/model-basic.vert",
 | 
					                   const char * vertexShader = ":/shaders/model-basic.vert",
 | 
				
			||||||
                   const char * fragmentShader = ":/shaders/model-basic.frag") :
 | 
					                   const char * fragmentShader = ":/shaders/model-basic.frag") :
 | 
				
			||||||
          Object(name, QTK_MODEL), mModelPath(path),
 | 
					          Object(name, QTK_MODEL), mModelPath(path),
 | 
				
			||||||
@ -87,7 +88,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param flipX Flip the texture along the X axis
 | 
					       * @param flipX Flip the texture along the X axis
 | 
				
			||||||
       * @param flipY Flip the texture along the Y axis
 | 
					       * @param flipY Flip the texture along the Y axis
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      void flipTexture(const std::string & fileName, bool flipX = false,
 | 
					      void flipTexture(const std::string & fileName,
 | 
				
			||||||
 | 
					                       bool flipX = false,
 | 
				
			||||||
                       bool flipY = true);
 | 
					                       bool flipY = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
 | 
				
			|||||||
@ -58,8 +58,8 @@ void ModelMesh::draw(QOpenGLShaderProgram & shader)
 | 
				
			|||||||
  glActiveTexture(GL_TEXTURE0);
 | 
					  glActiveTexture(GL_TEXTURE0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Draw the mesh
 | 
					  // Draw the mesh
 | 
				
			||||||
  glDrawElements(GL_TRIANGLES, mIndices.size(), GL_UNSIGNED_INT,
 | 
					  glDrawElements(
 | 
				
			||||||
                 mIndices.data());
 | 
					      GL_TRIANGLES, mIndices.size(), GL_UNSIGNED_INT, mIndices.data());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Release shader, textures
 | 
					  // Release shader, textures
 | 
				
			||||||
  for (const auto & texture : mTextures) {
 | 
					  for (const auto & texture : mTextures) {
 | 
				
			||||||
@ -104,29 +104,31 @@ void ModelMesh::initMesh(const char * vert, const char * frag)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Positions
 | 
					  // Positions
 | 
				
			||||||
  mProgram->enableAttributeArray(0);
 | 
					  mProgram->enableAttributeArray(0);
 | 
				
			||||||
  mProgram->setAttributeBuffer(0, GL_FLOAT, offsetof(ModelVertex, mPosition), 3,
 | 
					  mProgram->setAttributeBuffer(
 | 
				
			||||||
                               sizeof(ModelVertex));
 | 
					      0, GL_FLOAT, offsetof(ModelVertex, mPosition), 3, sizeof(ModelVertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Normals
 | 
					  // Normals
 | 
				
			||||||
  mProgram->enableAttributeArray(1);
 | 
					  mProgram->enableAttributeArray(1);
 | 
				
			||||||
  mProgram->setAttributeBuffer(1, GL_FLOAT, offsetof(ModelVertex, mNormal), 3,
 | 
					  mProgram->setAttributeBuffer(
 | 
				
			||||||
                               sizeof(ModelVertex));
 | 
					      1, GL_FLOAT, offsetof(ModelVertex, mNormal), 3, sizeof(ModelVertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Texture Coordinates
 | 
					  // Texture Coordinates
 | 
				
			||||||
  mProgram->enableAttributeArray(2);
 | 
					  mProgram->enableAttributeArray(2);
 | 
				
			||||||
  mProgram->setAttributeBuffer(2, GL_FLOAT,
 | 
					  mProgram->setAttributeBuffer(2,
 | 
				
			||||||
                               offsetof(ModelVertex, mTextureCoord), 2,
 | 
					                               GL_FLOAT,
 | 
				
			||||||
 | 
					                               offsetof(ModelVertex, mTextureCoord),
 | 
				
			||||||
 | 
					                               2,
 | 
				
			||||||
                               sizeof(ModelVertex));
 | 
					                               sizeof(ModelVertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Vertex tangents
 | 
					  // Vertex tangents
 | 
				
			||||||
  mProgram->enableAttributeArray(3);
 | 
					  mProgram->enableAttributeArray(3);
 | 
				
			||||||
  mProgram->setAttributeBuffer(3, GL_FLOAT, offsetof(ModelVertex, mTangent), 3,
 | 
					  mProgram->setAttributeBuffer(
 | 
				
			||||||
                               sizeof(ModelVertex));
 | 
					      3, GL_FLOAT, offsetof(ModelVertex, mTangent), 3, sizeof(ModelVertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Vertex bitangents
 | 
					  // Vertex bitangents
 | 
				
			||||||
  mProgram->enableAttributeArray(4);
 | 
					  mProgram->enableAttributeArray(4);
 | 
				
			||||||
  mProgram->setAttributeBuffer(4, GL_FLOAT, offsetof(ModelVertex, mBitangent),
 | 
					  mProgram->setAttributeBuffer(
 | 
				
			||||||
                               3, sizeof(ModelVertex));
 | 
					      4, GL_FLOAT, offsetof(ModelVertex, mBitangent), 3, sizeof(ModelVertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mProgram->release();
 | 
					  mProgram->release();
 | 
				
			||||||
  mVBO->release();
 | 
					  mVBO->release();
 | 
				
			||||||
 | 
				
			|||||||
@ -94,7 +94,9 @@ namespace Qtk
 | 
				
			|||||||
       * @param vertexShader Path to vertex shader for this ModelMesh.
 | 
					       * @param vertexShader Path to vertex shader for this ModelMesh.
 | 
				
			||||||
       * @param fragmentShader Path to fragment shader for this ModelMesh.
 | 
					       * @param fragmentShader Path to fragment shader for this ModelMesh.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      ModelMesh(Vertices vertices, Indices indices, Textures textures,
 | 
					      ModelMesh(Vertices vertices,
 | 
				
			||||||
 | 
					                Indices indices,
 | 
				
			||||||
 | 
					                Textures textures,
 | 
				
			||||||
                const char * vertexShader = ":/model-basic.vert",
 | 
					                const char * vertexShader = ":/model-basic.vert",
 | 
				
			||||||
                const char * fragmentShader = ":/model-basic.frag") :
 | 
					                const char * fragmentShader = ":/model-basic.frag") :
 | 
				
			||||||
          mProgram(new QOpenGLShaderProgram),
 | 
					          mProgram(new QOpenGLShaderProgram),
 | 
				
			||||||
 | 
				
			|||||||
@ -149,7 +149,8 @@ namespace Qtk
 | 
				
			|||||||
        mShape.mTexCoords = value;
 | 
					        mShape.mTexCoords = value;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      virtual inline void setTexture(const char * path, bool flipX = false,
 | 
					      virtual inline void setTexture(const char * path,
 | 
				
			||||||
 | 
					                                     bool flipX = false,
 | 
				
			||||||
                                     bool flipY = false)
 | 
					                                     bool flipY = false)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTexture.setTexture(path, flipX, flipY);
 | 
					        mTexture.setTexture(path, flipX, flipY);
 | 
				
			||||||
@ -172,38 +173,41 @@ namespace Qtk
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      inline void setScaleX(double x)
 | 
					      inline void setScaleX(double x)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setScale(x, mTransform.getScale().y(),
 | 
					        mTransform.setScale(
 | 
				
			||||||
                            mTransform.getScale().z());
 | 
					            x, mTransform.getScale().y(), mTransform.getScale().z());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline void setScaleY(double y)
 | 
					      inline void setScaleY(double y)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setScale(mTransform.getScale().x(), y,
 | 
					        mTransform.setScale(
 | 
				
			||||||
                            mTransform.getScale().z());
 | 
					            mTransform.getScale().x(), y, mTransform.getScale().z());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline void setScaleZ(double z)
 | 
					      inline void setScaleZ(double z)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setScale(mTransform.getScale().x(),
 | 
					        mTransform.setScale(
 | 
				
			||||||
                            mTransform.getScale().y(), z);
 | 
					            mTransform.getScale().x(), mTransform.getScale().y(), z);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline void setTranslationX(double x)
 | 
					      inline void setTranslationX(double x)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setTranslation(x, mTransform.getTranslation().y(),
 | 
					        mTransform.setTranslation(x,
 | 
				
			||||||
 | 
					                                  mTransform.getTranslation().y(),
 | 
				
			||||||
                                  mTransform.getTranslation().z());
 | 
					                                  mTransform.getTranslation().z());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline void setTranslationY(double y)
 | 
					      inline void setTranslationY(double y)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setTranslation(mTransform.getTranslation().x(), y,
 | 
					        mTransform.setTranslation(mTransform.getTranslation().x(),
 | 
				
			||||||
 | 
					                                  y,
 | 
				
			||||||
                                  mTransform.getTranslation().z());
 | 
					                                  mTransform.getTranslation().z());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      inline void setTranslationZ(double z)
 | 
					      inline void setTranslationZ(double z)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mTransform.setTranslation(mTransform.getTranslation().x(),
 | 
					        mTransform.setTranslation(mTransform.getTranslation().x(),
 | 
				
			||||||
                                  mTransform.getTranslation().y(), z);
 | 
					                                  mTransform.getTranslation().y(),
 | 
				
			||||||
 | 
					                                  z);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /*************************************************************************
 | 
					      /*************************************************************************
 | 
				
			||||||
 | 
				
			|||||||
@ -115,8 +115,11 @@ namespace Qtk
 | 
				
			|||||||
       * @param t Texture coordinates for this shape.
 | 
					       * @param t Texture coordinates for this shape.
 | 
				
			||||||
       * @param n Normals for this shape.
 | 
					       * @param n Normals for this shape.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      explicit ShapeBase(DrawMode mode = QTK_DRAW_ARRAYS, Vertices v = {},
 | 
					      explicit ShapeBase(DrawMode mode = QTK_DRAW_ARRAYS,
 | 
				
			||||||
                         Indices i = {}, Colors c = {}, TexCoords t = {},
 | 
					                         Vertices v = {},
 | 
				
			||||||
 | 
					                         Indices i = {},
 | 
				
			||||||
 | 
					                         Colors c = {},
 | 
				
			||||||
 | 
					                         TexCoords t = {},
 | 
				
			||||||
                         Normals n = {}) :
 | 
					                         Normals n = {}) :
 | 
				
			||||||
          mDrawMode(mode), mVertices(std::move(v)), mColors(std::move(c)),
 | 
					          mDrawMode(mode), mVertices(std::move(v)), mColors(std::move(c)),
 | 
				
			||||||
          mIndices(std::move(i)), mTexCoords(std::move(t)),
 | 
					          mIndices(std::move(i)), mTexCoords(std::move(t)),
 | 
				
			||||||
 | 
				
			|||||||
@ -17,9 +17,13 @@ using namespace Qtk;
 | 
				
			|||||||
 ******************************************************************************/
 | 
					 ******************************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Skybox::Skybox(const std::string & name) :
 | 
					Skybox::Skybox(const std::string & name) :
 | 
				
			||||||
    Skybox(":/textures/skybox/right.png", ":/textures/skybox/top.png",
 | 
					    Skybox(":/textures/skybox/right.png",
 | 
				
			||||||
           ":/textures/skybox/front.png", ":/textures/skybox/left.png",
 | 
					           ":/textures/skybox/top.png",
 | 
				
			||||||
           ":/textures/skybox/bottom.png", ":/textures/skybox/back.png", name)
 | 
					           ":/textures/skybox/front.png",
 | 
				
			||||||
 | 
					           ":/textures/skybox/left.png",
 | 
				
			||||||
 | 
					           ":/textures/skybox/bottom.png",
 | 
				
			||||||
 | 
					           ":/textures/skybox/back.png",
 | 
				
			||||||
 | 
					           name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -29,18 +33,24 @@ Skybox::Skybox(QOpenGLTexture * cubeMap, const std::string & name)
 | 
				
			|||||||
  init();
 | 
					  init();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Skybox::Skybox(const std::string & right, const std::string & top,
 | 
					Skybox::Skybox(const std::string & right,
 | 
				
			||||||
               const std::string & front, const std::string & left,
 | 
					               const std::string & top,
 | 
				
			||||||
               const std::string & bottom, const std::string & back,
 | 
					               const std::string & front,
 | 
				
			||||||
 | 
					               const std::string & left,
 | 
				
			||||||
 | 
					               const std::string & bottom,
 | 
				
			||||||
 | 
					               const std::string & back,
 | 
				
			||||||
               const std::string & name) :
 | 
					               const std::string & name) :
 | 
				
			||||||
    mVBO(QOpenGLBuffer::VertexBuffer),
 | 
					    mVBO(QOpenGLBuffer::VertexBuffer),
 | 
				
			||||||
    mVertices(Cube(QTK_DRAW_ELEMENTS).getVertices()),
 | 
					    mVertices(Cube(QTK_DRAW_ELEMENTS).getVertices()),
 | 
				
			||||||
    mIndices(Cube(QTK_DRAW_ELEMENTS).getIndexData())
 | 
					    mIndices(Cube(QTK_DRAW_ELEMENTS).getIndexData())
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  init();
 | 
					  init();
 | 
				
			||||||
  mTexture.setCubeMap(QImage(right.c_str()).mirrored(), QImage(top.c_str()),
 | 
					  mTexture.setCubeMap(QImage(right.c_str()).mirrored(),
 | 
				
			||||||
                      QImage(front.c_str()), QImage(left.c_str()),
 | 
					                      QImage(top.c_str()),
 | 
				
			||||||
                      QImage(bottom.c_str()), QImage(back.c_str()));
 | 
					                      QImage(front.c_str()),
 | 
				
			||||||
 | 
					                      QImage(left.c_str()),
 | 
				
			||||||
 | 
					                      QImage(bottom.c_str()),
 | 
				
			||||||
 | 
					                      QImage(back.c_str()));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*******************************************************************************
 | 
					/*******************************************************************************
 | 
				
			||||||
@ -59,8 +69,8 @@ void Skybox::draw()
 | 
				
			|||||||
  mProgram.setUniformValue("uProjectionMatrix", Scene::getProjectionMatrix());
 | 
					  mProgram.setUniformValue("uProjectionMatrix", Scene::getProjectionMatrix());
 | 
				
			||||||
  mProgram.setUniformValue("uViewMatrix", Scene::getCamera().toMatrix());
 | 
					  mProgram.setUniformValue("uViewMatrix", Scene::getCamera().toMatrix());
 | 
				
			||||||
  mProgram.setUniformValue("uTexture", 0);
 | 
					  mProgram.setUniformValue("uTexture", 0);
 | 
				
			||||||
  glDrawElements(GL_TRIANGLES, mIndices.size(), GL_UNSIGNED_INT,
 | 
					  glDrawElements(
 | 
				
			||||||
                 mIndices.data());
 | 
					      GL_TRIANGLES, mIndices.size(), GL_UNSIGNED_INT, mIndices.data());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  mTexture.getOpenGLTexture().bind();
 | 
					  mTexture.getOpenGLTexture().bind();
 | 
				
			||||||
  mProgram.release();
 | 
					  mProgram.release();
 | 
				
			||||||
 | 
				
			|||||||
@ -64,9 +64,12 @@ namespace Qtk
 | 
				
			|||||||
       * @param back Image to use for the back side of the Skybox.
 | 
					       * @param back Image to use for the back side of the Skybox.
 | 
				
			||||||
       * @param name The objectName to use for this Skybox.
 | 
					       * @param name The objectName to use for this Skybox.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      Skybox(const std::string & right, const std::string & top,
 | 
					      Skybox(const std::string & right,
 | 
				
			||||||
             const std::string & front, const std::string & left,
 | 
					             const std::string & top,
 | 
				
			||||||
             const std::string & bottom, const std::string & back,
 | 
					             const std::string & front,
 | 
				
			||||||
 | 
					             const std::string & left,
 | 
				
			||||||
 | 
					             const std::string & bottom,
 | 
				
			||||||
 | 
					             const std::string & back,
 | 
				
			||||||
             const std::string & name = "Skybox");
 | 
					             const std::string & name = "Skybox");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      ~Skybox() = default;
 | 
					      ~Skybox() = default;
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using namespace Qtk;
 | 
					using namespace Qtk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QImage OpenGLTextureFactory::initImage(const char * image, bool flipX,
 | 
					QImage OpenGLTextureFactory::initImage(const char * image,
 | 
				
			||||||
 | 
					                                       bool flipX,
 | 
				
			||||||
                                       bool flipY)
 | 
					                                       bool flipY)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  // Qt6 limits loaded images to 256MB by default
 | 
					  // Qt6 limits loaded images to 256MB by default
 | 
				
			||||||
@ -28,7 +29,8 @@ QImage OpenGLTextureFactory::initImage(const char * image, bool flipX,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QOpenGLTexture * OpenGLTextureFactory::initTexture(const char * texture,
 | 
					QOpenGLTexture * OpenGLTextureFactory::initTexture(const char * texture,
 | 
				
			||||||
                                                   bool flipX, bool flipY)
 | 
					                                                   bool flipX,
 | 
				
			||||||
 | 
					                                                   bool flipY)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QImage image = initImage(texture, flipX, flipY);
 | 
					  QImage image = initImage(texture, flipX, flipY);
 | 
				
			||||||
  auto newTexture = new QOpenGLTexture(QOpenGLTexture::Target2D);
 | 
					  auto newTexture = new QOpenGLTexture(QOpenGLTexture::Target2D);
 | 
				
			||||||
@ -41,21 +43,35 @@ QOpenGLTexture * OpenGLTextureFactory::initTexture(const char * texture,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QOpenGLTexture * OpenGLTextureFactory::initCubeMap(const char * tile)
 | 
					QOpenGLTexture * OpenGLTextureFactory::initCubeMap(const char * tile)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return initCubeMap(QImage(tile), QImage(tile), QImage(tile), QImage(tile),
 | 
					  return initCubeMap(QImage(tile),
 | 
				
			||||||
                     QImage(tile), QImage(tile));
 | 
					                     QImage(tile),
 | 
				
			||||||
 | 
					                     QImage(tile),
 | 
				
			||||||
 | 
					                     QImage(tile),
 | 
				
			||||||
 | 
					                     QImage(tile),
 | 
				
			||||||
 | 
					                     QImage(tile));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QOpenGLTexture * OpenGLTextureFactory::initCubeMap(
 | 
					QOpenGLTexture * OpenGLTextureFactory::initCubeMap(const char * right,
 | 
				
			||||||
    const char * right, const char * top, const char * front, const char * left,
 | 
					                                                   const char * top,
 | 
				
			||||||
    const char * bottom, const char * back)
 | 
					                                                   const char * front,
 | 
				
			||||||
 | 
					                                                   const char * left,
 | 
				
			||||||
 | 
					                                                   const char * bottom,
 | 
				
			||||||
 | 
					                                                   const char * back)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return initCubeMap(QImage(right), QImage(top), QImage(front), QImage(left),
 | 
					  return initCubeMap(QImage(right),
 | 
				
			||||||
                     QImage(bottom), QImage(back));
 | 
					                     QImage(top),
 | 
				
			||||||
 | 
					                     QImage(front),
 | 
				
			||||||
 | 
					                     QImage(left),
 | 
				
			||||||
 | 
					                     QImage(bottom),
 | 
				
			||||||
 | 
					                     QImage(back));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QOpenGLTexture * OpenGLTextureFactory::initCubeMap(
 | 
					QOpenGLTexture * OpenGLTextureFactory::initCubeMap(const QImage & right,
 | 
				
			||||||
    const QImage & right, const QImage & top, const QImage & front,
 | 
					                                                   const QImage & top,
 | 
				
			||||||
    const QImage & left, const QImage & bottom, const QImage & back)
 | 
					                                                   const QImage & front,
 | 
				
			||||||
 | 
					                                                   const QImage & left,
 | 
				
			||||||
 | 
					                                                   const QImage & bottom,
 | 
				
			||||||
 | 
					                                                   const QImage & back)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  auto texture = new QOpenGLTexture(QOpenGLTexture::TargetCubeMap);
 | 
					  auto texture = new QOpenGLTexture(QOpenGLTexture::TargetCubeMap);
 | 
				
			||||||
  std::vector<QImage> faceTextures = {right, top, front, left, bottom, back};
 | 
					  std::vector<QImage> faceTextures = {right, top, front, left, bottom, back};
 | 
				
			||||||
@ -64,9 +80,12 @@ QOpenGLTexture * OpenGLTextureFactory::initCubeMap(
 | 
				
			|||||||
  texture->bind();
 | 
					  texture->bind();
 | 
				
			||||||
  // For each cube map face
 | 
					  // For each cube map face
 | 
				
			||||||
  std::vector<QOpenGLTexture::CubeMapFace> faces = {
 | 
					  std::vector<QOpenGLTexture::CubeMapFace> faces = {
 | 
				
			||||||
      QOpenGLTexture::CubeMapPositiveX, QOpenGLTexture::CubeMapPositiveY,
 | 
					      QOpenGLTexture::CubeMapPositiveX,
 | 
				
			||||||
      QOpenGLTexture::CubeMapPositiveZ, QOpenGLTexture::CubeMapNegativeX,
 | 
					      QOpenGLTexture::CubeMapPositiveY,
 | 
				
			||||||
      QOpenGLTexture::CubeMapNegativeY, QOpenGLTexture::CubeMapNegativeZ};
 | 
					      QOpenGLTexture::CubeMapPositiveZ,
 | 
				
			||||||
 | 
					      QOpenGLTexture::CubeMapNegativeX,
 | 
				
			||||||
 | 
					      QOpenGLTexture::CubeMapNegativeY,
 | 
				
			||||||
 | 
					      QOpenGLTexture::CubeMapNegativeZ};
 | 
				
			||||||
  int i = 0;
 | 
					  int i = 0;
 | 
				
			||||||
  for (const auto & face : faces) {
 | 
					  for (const auto & face : faces) {
 | 
				
			||||||
    QImage faceImage(faceTextures[i]);
 | 
					    QImage faceImage(faceTextures[i]);
 | 
				
			||||||
@ -79,13 +98,17 @@ QOpenGLTexture * OpenGLTextureFactory::initCubeMap(
 | 
				
			|||||||
    // On the first iteration, set format and allocate texture storage
 | 
					    // On the first iteration, set format and allocate texture storage
 | 
				
			||||||
    if (face == QOpenGLTexture::CubeMapPositiveX) {
 | 
					    if (face == QOpenGLTexture::CubeMapPositiveX) {
 | 
				
			||||||
      // This also needs to happen on the first iteration, anyways
 | 
					      // This also needs to happen on the first iteration, anyways
 | 
				
			||||||
      texture->setSize(faceImage.width(), faceImage.height(),
 | 
					      texture->setSize(
 | 
				
			||||||
                       faceImage.depth());
 | 
					          faceImage.width(), faceImage.height(), faceImage.depth());
 | 
				
			||||||
      texture->setFormat(QOpenGLTexture::RGBA8_UNorm);
 | 
					      texture->setFormat(QOpenGLTexture::RGBA8_UNorm);
 | 
				
			||||||
      texture->allocateStorage();
 | 
					      texture->allocateStorage();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    texture->setData(0, 0, face, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8,
 | 
					    texture->setData(0,
 | 
				
			||||||
 | 
					                     0,
 | 
				
			||||||
 | 
					                     face,
 | 
				
			||||||
 | 
					                     QOpenGLTexture::RGBA,
 | 
				
			||||||
 | 
					                     QOpenGLTexture::UInt8,
 | 
				
			||||||
                     faceImage.constBits());
 | 
					                     faceImage.constBits());
 | 
				
			||||||
    i++;
 | 
					    i++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -80,7 +80,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param flipY If true the image will be flipped on Y axis.
 | 
					       * @param flipY If true the image will be flipped on Y axis.
 | 
				
			||||||
       * @return QImage object.
 | 
					       * @return QImage object.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      static QImage initImage(const char * image, bool flipX = false,
 | 
					      static QImage initImage(const char * image,
 | 
				
			||||||
 | 
					                              bool flipX = false,
 | 
				
			||||||
                              bool flipY = false);
 | 
					                              bool flipY = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
@ -108,9 +109,12 @@ namespace Qtk
 | 
				
			|||||||
       * @param back Path to image for the back side of the CubeMap.
 | 
					       * @param back Path to image for the back side of the CubeMap.
 | 
				
			||||||
       * @return Pointer to an initialized QOpenGLTexture object.
 | 
					       * @return Pointer to an initialized QOpenGLTexture object.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      static QOpenGLTexture * initCubeMap(
 | 
					      static QOpenGLTexture * initCubeMap(const QImage & right,
 | 
				
			||||||
          const QImage & right, const QImage & top, const QImage & front,
 | 
					                                          const QImage & top,
 | 
				
			||||||
          const QImage & left, const QImage & bottom, const QImage & back);
 | 
					                                          const QImage & front,
 | 
				
			||||||
 | 
					                                          const QImage & left,
 | 
				
			||||||
 | 
					                                          const QImage & bottom,
 | 
				
			||||||
 | 
					                                          const QImage & back);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
       * CubeMap factory for tiling the same image on all sides.
 | 
					       * CubeMap factory for tiling the same image on all sides.
 | 
				
			||||||
@ -133,8 +137,10 @@ namespace Qtk
 | 
				
			|||||||
       * @param back Path to image for the back side of the CubeMap.
 | 
					       * @param back Path to image for the back side of the CubeMap.
 | 
				
			||||||
       * @return Pointer to an initialized QOpenGLTexture object.
 | 
					       * @return Pointer to an initialized QOpenGLTexture object.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      static QOpenGLTexture * initCubeMap(const char * right, const char * top,
 | 
					      static QOpenGLTexture * initCubeMap(const char * right,
 | 
				
			||||||
                                          const char * front, const char * left,
 | 
					                                          const char * top,
 | 
				
			||||||
 | 
					                                          const char * front,
 | 
				
			||||||
 | 
					                                          const char * left,
 | 
				
			||||||
                                          const char * bottom,
 | 
					                                          const char * bottom,
 | 
				
			||||||
                                          const char * back);
 | 
					                                          const char * back);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -188,7 +194,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param flipX True if texture is to be flipped on the X axis.
 | 
					       * @param flipX True if texture is to be flipped on the X axis.
 | 
				
			||||||
       * @param flipY True if texture is to be flipped on the Y axis.
 | 
					       * @param flipY True if texture is to be flipped on the Y axis.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      explicit Texture(const char * path, bool flipX = false,
 | 
					      explicit Texture(const char * path,
 | 
				
			||||||
 | 
					                       bool flipX = false,
 | 
				
			||||||
                       bool flipY = false) :
 | 
					                       bool flipY = false) :
 | 
				
			||||||
          mOpenGLTexture(OpenGLTextureFactory::initTexture(path, flipX, flipY)),
 | 
					          mOpenGLTexture(OpenGLTextureFactory::initTexture(path, flipX, flipY)),
 | 
				
			||||||
          mPath(path)
 | 
					          mPath(path)
 | 
				
			||||||
@ -244,7 +251,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param flipX True if texture is to be flipped on the X axis.
 | 
					       * @param flipX True if texture is to be flipped on the X axis.
 | 
				
			||||||
       * @param flipY True if texture is to be flipped on the Y axis.
 | 
					       * @param flipY True if texture is to be flipped on the Y axis.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      inline void setTexture(const std::string & path, bool flipX = false,
 | 
					      inline void setTexture(const std::string & path,
 | 
				
			||||||
 | 
					                             bool flipX = false,
 | 
				
			||||||
                             bool flipY = false)
 | 
					                             bool flipY = false)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        setTexture(path.c_str(), flipX, flipY);
 | 
					        setTexture(path.c_str(), flipX, flipY);
 | 
				
			||||||
@ -255,7 +263,8 @@ namespace Qtk
 | 
				
			|||||||
       * @param flipX True if texture is to be flipped on the X axis.
 | 
					       * @param flipX True if texture is to be flipped on the X axis.
 | 
				
			||||||
       * @param flipY True if texture is to be flipped on the Y axis.
 | 
					       * @param flipY True if texture is to be flipped on the Y axis.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      inline void setTexture(const char * path, bool flipX = false,
 | 
					      inline void setTexture(const char * path,
 | 
				
			||||||
 | 
					                             bool flipX = false,
 | 
				
			||||||
                             bool flipY = false)
 | 
					                             bool flipY = false)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mOpenGLTexture = OpenGLTextureFactory::initTexture(path, flipX, flipY);
 | 
					        mOpenGLTexture = OpenGLTextureFactory::initTexture(path, flipX, flipY);
 | 
				
			||||||
@ -283,12 +292,15 @@ namespace Qtk
 | 
				
			|||||||
       * @param bottom Path to texture to use for bottom cube map side.
 | 
					       * @param bottom Path to texture to use for bottom cube map side.
 | 
				
			||||||
       * @param back Path to texture to use for back cube map side.
 | 
					       * @param back Path to texture to use for back cube map side.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      virtual inline void setCubeMap(const char * right, const char * top,
 | 
					      virtual inline void setCubeMap(const char * right,
 | 
				
			||||||
                                     const char * front, const char * left,
 | 
					                                     const char * top,
 | 
				
			||||||
                                     const char * bottom, const char * back)
 | 
					                                     const char * front,
 | 
				
			||||||
 | 
					                                     const char * left,
 | 
				
			||||||
 | 
					                                     const char * bottom,
 | 
				
			||||||
 | 
					                                     const char * back)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mOpenGLTexture = OpenGLTextureFactory::initCubeMap(right, top, front,
 | 
					        mOpenGLTexture = OpenGLTextureFactory::initCubeMap(
 | 
				
			||||||
                                                           left, bottom, back);
 | 
					            right, top, front, left, bottom, back);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /**
 | 
					      /**
 | 
				
			||||||
@ -301,12 +313,15 @@ namespace Qtk
 | 
				
			|||||||
       * @param bottom Path to texture to use for bottom cube map side.
 | 
					       * @param bottom Path to texture to use for bottom cube map side.
 | 
				
			||||||
       * @param back Path to texture to use for back cube map side.
 | 
					       * @param back Path to texture to use for back cube map side.
 | 
				
			||||||
       */
 | 
					       */
 | 
				
			||||||
      virtual inline void setCubeMap(const QImage & right, const QImage & top,
 | 
					      virtual inline void setCubeMap(const QImage & right,
 | 
				
			||||||
                                     const QImage & front, const QImage & left,
 | 
					                                     const QImage & top,
 | 
				
			||||||
                                     const QImage & bottom, const QImage & back)
 | 
					                                     const QImage & front,
 | 
				
			||||||
 | 
					                                     const QImage & left,
 | 
				
			||||||
 | 
					                                     const QImage & bottom,
 | 
				
			||||||
 | 
					                                     const QImage & back)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        mOpenGLTexture = OpenGLTextureFactory::initCubeMap(right, top, front,
 | 
					        mOpenGLTexture = OpenGLTextureFactory::initCubeMap(
 | 
				
			||||||
                                                           left, bottom, back);
 | 
					            right, top, front, left, bottom, back);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
					    private:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user