Add assimp as external dependency

This commit is contained in:
2022-08-14 17:02:50 -04:00
parent 249a2b4446
commit f3406ee749
7 changed files with 72 additions and 54 deletions

View File

@@ -20,12 +20,13 @@
namespace Qtk {
class Scene : protected QOpenGLFunctions {
friend class MainWidget;
public:
Scene();
~Scene();
virtual void init() = 0;
virtual void draw() = 0;
virtual void draw() { privDraw(); };
virtual void update() = 0;
static Camera3D & Camera() { return mCamera;}

View File

@@ -65,7 +65,7 @@ void MainWidget::paintGL()
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
// Draw the scene first, since it handles drawing our skybox
if (mScene != Q_NULLPTR) mScene->privDraw();
if (mScene != Q_NULLPTR) mScene->draw();
}
void MainWidget::initializeGL()

View File

@@ -15,14 +15,16 @@ using namespace Qtk;
Skybox::Skybox(std::string right, std::string top, std::string front,
std::string left, std::string bottom, std::string back,
const std::string & name)
: mCubeMap(Texture::initCubeMap(
QImage(right.c_str()).mirrored(), QImage(top.c_str()),
QImage(front.c_str()), QImage(left.c_str()),
QImage(bottom.c_str()), QImage(back.c_str()))),
mVBO(QOpenGLBuffer::VertexBuffer),
: mVBO(QOpenGLBuffer::VertexBuffer),
mVertices(Cube(QTK_DRAW_ELEMENTS).vertices()),
mIndices(Cube(QTK_DRAW_ELEMENTS).indices())
{ init();}
{
init();
mCubeMap = Texture::initCubeMap(
QImage(right.c_str()).mirrored(), QImage(top.c_str()),
QImage(front.c_str()), QImage(left.c_str()),
QImage(bottom.c_str()), QImage(back.c_str()));
}
Skybox::Skybox(std::string name)
: Skybox(":/right.png", ":/top.png", ":/front.png",
@@ -87,13 +89,11 @@ void Skybox::init()
mVBO.setUsagePattern(QOpenGLBuffer::StaticDraw);
mVBO.bind();
// Allocate vertex positions into VBO
mVBO.allocate(mVertices.data(),
mVertices.size() * sizeof(mVertices[0]));
mVBO.allocate(mVertices.data(), mVertices.size() * sizeof(mVertices[0]));
// Enable attribute array for vertex positions
mProgram.enableAttributeArray(0);
mProgram.setAttributeBuffer(0, GL_FLOAT, 0,
3, sizeof(QVector3D));
mProgram.setAttributeBuffer(0, GL_FLOAT, 0, 3, sizeof(QVector3D));
// Set shader texture unit to 0
mProgram.setUniformValue("uTexture", 0);