#include "GLWidget.h"
#include <stdexcept>
GLWidget::GLWidget() : QGLWidget() { }
GLWidget::~GLWidget() {
h3dutDumpMessages();
h3dRelease();
}
void GLWidget::initializeGL() {
if (!h3dInit()) {
h3dutDumpMessages();
throw std::runtime_error("Could not initialize renderer");
}
H3DRes pipeline = h3dAddResource(
H3DResTypes::Pipeline, "pipelines/forward.pipeline.xml", 0);
H3DRes knight = h3dAddResource(
H3DResTypes::SceneGraph , "models/knight/knight.scene.xml", 0);
h3dutLoadResourcesFromDisk("Content");
H3DNode node = h3dAddNodes(H3DRootNode, knight);
h3dSetNodeTransform(node, 0,0,0, 0,0,0, 1,1,1);
mCam = h3dAddCameraNode(H3DRootNode, "cam", pipeline);
h3dSetNodeTransform(mCam, 0,40,-40, 23,-166,0, 1,1,1);
}
void GLWidget::paintGL() {
h3dRender(mCam);
}
void GLWidget::resizeGL(int width, int height) {
h3dSetupViewport(0, 0, width, height, true);
h3dSetupCameraView(
mCam, 45.0f, static_cast<float>(width)/height, 0.1f, 1000.0f);
}