Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <QtCore>
- #include <QWidget>
- #include "qapplication.h"
- #include "GLWidget.hpp"
- #include "assimp.h"
- #include "aiScene.h"
- // rename GLWidget to GLBaseWidget (cause its abstract)
- // TEMP
- namespace paragon {
- class Foo : public GLWidget {
- const aiScene *scene;
- public:
- Foo (QWidget *parent = 0) : GLWidget (0, parent) {
- scene = aiImportFile ("wall_04x04.3DS", 0);
- if (scene) {
- std::cout << scene->mNumMeshes << std::endl;
- }
- }
- ~Foo () {
- if (scene) aiReleaseImport (scene);
- scene = 0;
- }
- protected:
- void initializeGL () {
- glShadeModel(GL_SMOOTH);
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClearDepth(1.0f);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- glDisable (GL_LIGHTING);
- }
- void resizeGL (int width, int height) {
- height = height?height:1;
- glViewport( 0, 0, (GLint)width, (GLint)height );
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void paintGL () {
- glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity ();
- glTranslatef (0, 0, -25);
- for (unsigned int n = 0; n < scene->mNumMeshes; ++n) {
- const struct aiMesh *mesh = scene->mMeshes [n];
- for (unsigned int t = 0; t < mesh->mNumFaces; ++t) {
- const struct aiFace *face = &mesh->mFaces[t];
- glBegin (GL_POLYGON);
- for (unsigned int i = 0; i < face->mNumIndices; ++i) {
- int index = face->mIndices[i];
- glVertex3fv (&mesh->mVertices[index].x);
- }
- glEnd ();
- }
- }
- }
- };
- }
- int main (int argc, char *argv[]) {
- QApplication app (argc, argv);
- paragon::Foo widget;
- widget.setWindowTitle ("QT OpenGL Widget");
- widget.resize (640, 480);
- widget.show ();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement