Commit fbbc62b6 by Alisa Jung

abgabe 20:55 Uhr

parent 8f95f651
...@@ -144,7 +144,7 @@ void Controller::processMouseMoveEvent(QMouseEvent *event, MyGLWidget *widget){ ...@@ -144,7 +144,7 @@ void Controller::processMouseMoveEvent(QMouseEvent *event, MyGLWidget *widget){
//view change //view change
widget->translateCamera(-0.01*diff.x(),0.01*diff.y()); widget->translateCamera(-0.01*diff.x(),0.01*diff.y());
} else if (currentTransform){ } else if (currentTransform){
qDebug("CurrentTransform not null"); // qDebug("CurrentTransform not null");
//state change for model //state change for model
QVector3D diffV(0.01*diff.x(),-0.01*diff.y(),0); QVector3D diffV(0.01*diff.x(),-0.01*diff.y(),0);
diffV = widget->getCameraRotation().conjugate().rotatedVector(diffV); diffV = widget->getCameraRotation().conjugate().rotatedVector(diffV);
...@@ -196,10 +196,10 @@ QQuaternion Controller::computeRotation(QPoint newPosition){ ...@@ -196,10 +196,10 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
double xyNew = xNew*xNew + yNew*yNew; double xyNew = xNew*xNew + yNew*yNew;
if (xyOld < rsquareover2){ if (xyOld < rsquareover2){
zOld = sqrt(radius*radius - xyOld); zOld = sqrt(radius*radius - xyOld);
qDebug() << "z old 1 " << zOld; // qDebug() << "z old 1 " << zOld;
}else{ }else{
zOld = rsquareover2/(sqrt(xyOld)); zOld = rsquareover2/(sqrt(xyOld));
qDebug() << "z old 2 " << zOld; // qDebug() << "z old 2 " << zOld;
} }
if(xyNew < rsquareover2){ if(xyNew < rsquareover2){
zNew = sqrt(radius*radius - xyNew); zNew = sqrt(radius*radius - xyNew);
...@@ -224,8 +224,8 @@ QQuaternion Controller::computeRotation(QPoint newPosition){ ...@@ -224,8 +224,8 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
//Accumulate Rotation //Accumulate Rotation
QQuaternion q = QQuaternion(cos(theta/2.0),sin(theta/2)*n); QQuaternion q = QQuaternion(cos(theta/2.0),sin(theta/2)*n);
q.normalize(); q.normalize();
qDebug() << "quaternion diff " << q << "xo " << xOld << "yo " << yOld << " x new " << xNew << " ynew " << yNew; // qDebug() << "quaternion diff " << q << "xo " << xOld << "yo " << yOld << " x new " << xNew << " ynew " << yNew;
qDebug() << "v1 " << v1 << ", v2 " << v2; // qDebug() << "v1 " << v1 << ", v2 " << v2;
return q; return q;
} }
......
#ifndef CONTROLLER_H #ifndef CONTROLLER_H
#define CONTROLLER_H #define CONTROLLER_H
#include <myglwidget.h>
#include <QGLWidget> #include <QGLWidget>
#include <gl/GLU.h> #include <gl/GLU.h>
#include <QDebug> #include <QDebug>
...@@ -22,7 +25,6 @@ ...@@ -22,7 +25,6 @@
#include <math.h> #include <math.h>
class MyGLWidget;
class SceneGraph; class SceneGraph;
class Controller : public QObject class Controller : public QObject
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -12,8 +12,9 @@ TARGET = helloqube ...@@ -12,8 +12,9 @@ TARGET = helloqube
TEMPLATE = app TEMPLATE = app
#not helping #not helping
LIBS += -lglut64 LIBS += -lglew32
LIBS += -LC:\glut LIBS += -LC:\glut
LIBS += -lglut64
SOURCES += main.cpp\ SOURCES += main.cpp\
mainwindow.cpp \ mainwindow.cpp \
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-23T01:20:22. --> <!-- Written by QtCreator 3.5.1, 2015-11-23T17:08:38. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <myglwidget.h>
#include <QMainWindow> #include <QMainWindow>
#include <QtGui> #include <QtGui>
#include <QMenuBar> #include <QMenuBar>
...@@ -10,7 +12,6 @@ ...@@ -10,7 +12,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QToolBar> #include <QToolBar>
#include <QStatusBar> #include <QStatusBar>
#include <myglwidget.h>
#include <QSlider> #include <QSlider>
#include <QToolButton> #include <QToolButton>
#include <controller.h> #include <controller.h>
......
...@@ -127,14 +127,87 @@ void MyGLWidget::initShaderStuff(){ ...@@ -127,14 +127,87 @@ void MyGLWidget::initShaderStuff(){
glPolygonMode(GL_FRONT,GL_FILL); glPolygonMode(GL_FRONT,GL_FILL);
phongShader->bind(); phongShader->bind();
// GLuint tid[1];
// glGenFrameBuffers(1, &tid[0]);
qDebug() << "FlatSlot setup."; qDebug() << "FlatSlot setup.";
} }
void MyGLWidget::paintGL(){ void MyGLWidget::paintGL(){
qDebug("paint gl"); qDebug() << "paint gl widget " << index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); glLoadIdentity();
/* not working. Nothing works. No tutorials or introductions or anything available. The small examples in the opengl wiki are horribly explained and don't work.
qDebug("Identity loaded");
GLuint fbo, depthRenderBuffer,sceneryBuffer, pickingBuffer, depthComponent;
qDebug("create color buffer...");
// Create the color buffer
glGenTextures(1, &sceneryBuffer);
glBindTexture(GL_TEXTURE_2D, sceneryBuffer);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, windowWidth, windowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Create the color picking buffer
/*glGenTextures(1, &pickingBuffer);
glBindTexture(GL_TEXTURE_2D, pickingBuffer);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, windowWidth, windowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
// Create the depth buffer
glGenTextures(1, &depthComponent);
glBindTexture(GL_TEXTURE_2D, depthComponent);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, windowWidth, windowHeight, 0, GL_RED, GL_BYTE, NULL);
qDebug("create QGLFUNCTIONS");
QGLFunctions functions = QGLFunctions(this->context());
qDebug("gen frame buffers");
functions.glGenFramebuffers(1, &fbo);
qDebug("bind frame buffers");
functions.glBindFramebuffer(GL_FRAMEBUFFER_EXT,fbo);
qDebug("something texture");
functions.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sceneryBuffer, 0);
//hier rendern?
/*functions.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, pickingBuffer, 0);
//hier auch rendern?
functions.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthComponent, 0);
qDebug("genRenderBuffers");
functions.glGenRenderbuffers(1,&depthRenderBuffer);
functions.glBindRenderbuffer(GL_RENDERBUFFER,depthRenderBuffer);
functions.glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH_COMPONENT24,windowWidth,windowHeight);
functions.glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER, depthRenderBuffer);
GLenum status;
status = functions.glCheckFramebufferStatus(GL_FRAMEBUFFER);
switch(status){
case GL_FRAMEBUFFER_COMPLETE:
qDebug("good: complete");
default:
qDebug("not good.");
}
functions.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glDisable(GL_TEXTURE_2D);*/ //Not working.
//cam rotation //cam rotation
QMatrix4x4 camRot = QMatrix4x4(); QMatrix4x4 camRot = QMatrix4x4();
camRot.rotate(cameraRotation); camRot.rotate(cameraRotation);
...@@ -147,7 +220,6 @@ void MyGLWidget::paintGL(){ ...@@ -147,7 +220,6 @@ void MyGLWidget::paintGL(){
glMultMatrixf(zoomCameraMatrix.data()); glMultMatrixf(zoomCameraMatrix.data());
glMultMatrixf(camRot.data()); glMultMatrixf(camRot.data());
glTranslatef(camRotCenter.x(),camRotCenter.y(),camRotCenter.z()); glTranslatef(camRotCenter.x(),camRotCenter.y(),camRotCenter.z());
// scene->drawAll(); // scene->drawAll();
const QList<RigidBodyTransformation*> graph = scene->getGraph(); const QList<RigidBodyTransformation*> graph = scene->getGraph();
...@@ -172,7 +244,7 @@ void MyGLWidget::paintGL(){ ...@@ -172,7 +244,7 @@ void MyGLWidget::paintGL(){
//draw primitive //draw primitive
for (int j = 0; j < (*i)->getChildrenCount(); j++){ for (int j = 0; j < (*i)->getChildrenCount(); j++){
qDebug() << "Draw child " << j <<" for " << (*i)->getName(); // qDebug() << "Draw child " << j <<" for " << (*i)->getName();
Primitive* p = (*i)->getChildAsPrimitive(j); Primitive* p = (*i)->getChildAsPrimitive(j);
int tesselation = p->getTesselation(); int tesselation = p->getTesselation();
Primitive::Type type = p->getType(); Primitive::Type type = p->getType();
...@@ -198,6 +270,13 @@ void MyGLWidget::paintGL(){ ...@@ -198,6 +270,13 @@ void MyGLWidget::paintGL(){
//has to be down here or will be overpainted by above code //has to be down here or will be overpainted by above code
if (isFocused) highlightViewport(); if (isFocused) highlightViewport();
/*fuck this
glDeleteTextures(1,&sceneryBuffer);
functions.glDeleteRenderbuffers(1,&depthRenderBuffer);
functions.glBindFramebuffer(GL_FRAMEBUFFER_EXT,0);
functions.glDeleteFramebuffers(1,&fbo);*/
} }
void MyGLWidget::setFocused(bool isFocused){ void MyGLWidget::setFocused(bool isFocused){
...@@ -320,7 +399,7 @@ void MyGLWidget::resetCamera(){ ...@@ -320,7 +399,7 @@ void MyGLWidget::resetCamera(){
/*Notification for changed model*/ /*Notification for changed model*/
void MyGLWidget::modelChanged(){ void MyGLWidget::modelChanged(){
qDebug("update view"); // qDebug() << "update view " << QString::number(index);
updateGL(); updateGL();
} }
......
#ifndef GLWIDGET_H #ifndef GLWIDGET_H
#define GLWIDGET_H #define GLWIDGET_H
//#include "glew.h"
#include <QGLWidget> #include <QGLWidget>
#include <gl/GLU.h> #include <gl/GLU.h>
#include <QDebug> #include <QDebug>
...@@ -14,10 +16,17 @@ ...@@ -14,10 +16,17 @@
#include <QStyleOption> #include <QStyleOption>
#include <QStylePainter> #include <QStylePainter>
#include "glut.h" #include <gl/GL.h>
#include <QtCore>
#include <QtGui>
#include <rigidbodytransformation.h>//vorläufig, bis szenengraph steht. #include <rigidbodytransformation.h>//vorläufig, bis szenengraph steht.
#include "glut.h"
#include <QOpenGLFunctions>
#include <QGLFunctions>
class Controller; class Controller;
class SceneGraph; class SceneGraph;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment