Commit fbbc62b6 by Alisa Jung

abgabe 20:55 Uhr

parent 8f95f651
......@@ -144,7 +144,7 @@ void Controller::processMouseMoveEvent(QMouseEvent *event, MyGLWidget *widget){
//view change
widget->translateCamera(-0.01*diff.x(),0.01*diff.y());
} else if (currentTransform){
qDebug("CurrentTransform not null");
// qDebug("CurrentTransform not null");
//state change for model
QVector3D diffV(0.01*diff.x(),-0.01*diff.y(),0);
diffV = widget->getCameraRotation().conjugate().rotatedVector(diffV);
......@@ -196,10 +196,10 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
double xyNew = xNew*xNew + yNew*yNew;
if (xyOld < rsquareover2){
zOld = sqrt(radius*radius - xyOld);
qDebug() << "z old 1 " << zOld;
// qDebug() << "z old 1 " << zOld;
}else{
zOld = rsquareover2/(sqrt(xyOld));
qDebug() << "z old 2 " << zOld;
// qDebug() << "z old 2 " << zOld;
}
if(xyNew < rsquareover2){
zNew = sqrt(radius*radius - xyNew);
......@@ -224,8 +224,8 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
//Accumulate Rotation
QQuaternion q = QQuaternion(cos(theta/2.0),sin(theta/2)*n);
q.normalize();
qDebug() << "quaternion diff " << q << "xo " << xOld << "yo " << yOld << " x new " << xNew << " ynew " << yNew;
qDebug() << "v1 " << v1 << ", v2 " << v2;
// qDebug() << "quaternion diff " << q << "xo " << xOld << "yo " << yOld << " x new " << xNew << " ynew " << yNew;
// qDebug() << "v1 " << v1 << ", v2 " << v2;
return q;
}
......
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <myglwidget.h>
#include <QGLWidget>
#include <gl/GLU.h>
#include <QDebug>
......@@ -22,7 +25,6 @@
#include <math.h>
class MyGLWidget;
class SceneGraph;
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
TEMPLATE = app
#not helping
LIBS += -lglut64
LIBS += -lglew32
LIBS += -LC:\glut
LIBS += -lglut64
SOURCES += main.cpp\
mainwindow.cpp \
......
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data>
<variable>EnvironmentId</variable>
......
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <myglwidget.h>
#include <QMainWindow>
#include <QtGui>
#include <QMenuBar>
......@@ -10,7 +12,6 @@
#include <QMessageBox>
#include <QToolBar>
#include <QStatusBar>
#include <myglwidget.h>
#include <QSlider>
#include <QToolButton>
#include <controller.h>
......
......@@ -127,14 +127,87 @@ void MyGLWidget::initShaderStuff(){
glPolygonMode(GL_FRONT,GL_FILL);
phongShader->bind();
// GLuint tid[1];
// glGenFrameBuffers(1, &tid[0]);
qDebug() << "FlatSlot setup.";
}
void MyGLWidget::paintGL(){
qDebug("paint gl");
qDebug() << "paint gl widget " << index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
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
QMatrix4x4 camRot = QMatrix4x4();
camRot.rotate(cameraRotation);
......@@ -147,7 +220,6 @@ void MyGLWidget::paintGL(){
glMultMatrixf(zoomCameraMatrix.data());
glMultMatrixf(camRot.data());
glTranslatef(camRotCenter.x(),camRotCenter.y(),camRotCenter.z());
// scene->drawAll();
const QList<RigidBodyTransformation*> graph = scene->getGraph();
......@@ -172,7 +244,7 @@ void MyGLWidget::paintGL(){
//draw primitive
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);
int tesselation = p->getTesselation();
Primitive::Type type = p->getType();
......@@ -198,6 +270,13 @@ void MyGLWidget::paintGL(){
//has to be down here or will be overpainted by above code
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){
......@@ -320,7 +399,7 @@ void MyGLWidget::resetCamera(){
/*Notification for changed model*/
void MyGLWidget::modelChanged(){
qDebug("update view");
// qDebug() << "update view " << QString::number(index);
updateGL();
}
......
#ifndef GLWIDGET_H
#define GLWIDGET_H
//#include "glew.h"
#include <QGLWidget>
#include <gl/GLU.h>
#include <QDebug>
......@@ -14,10 +16,17 @@
#include <QStyleOption>
#include <QStylePainter>
#include "glut.h"
#include <gl/GL.h>
#include <QtCore>
#include <QtGui>
#include <rigidbodytransformation.h>//vorläufig, bis szenengraph steht.
#include "glut.h"
#include <QOpenGLFunctions>
#include <QGLFunctions>
class Controller;
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