Commit 57112c5e by Kai Westerkamp

Added cubewidget.cpp

parent d9772752
#include "cubewidget.h"
#include <QOpenGLFunctions>
CubeWidget::CubeWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
}
QSize CubeWidget::minimumSizeHint() const
{
return QSize(50, 50);
}
QSize CubeWidget::sizeHint() const
{
return QSize(600, 400);
}
void CubeWidget::initializeGL ()
{
glEnable(GL_DEPTH_TEST);
/* glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_MULTISAMPLE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
static GLfloat lightPosition[4] = { 0.5, 0.0, 2.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
*/
}
void CubeWidget::paintGL ( ) {}
void CubeWidget::resizeGL(int width , int height ) {}
void CubeWidget::mousePressEvent(QMouseEvent *event ) {}
void CubeWidget::mouseMoveEvent(QMouseEvent *event ) {}
void CubeWidget::wheelEvent(QWheelEvent *event ) {}
#ifndef CUBEWIDGET_H
#define CUBEWIDGET_H
#include <QtGui>
#include <QtOpenGL>
#include <QOpenGLFunctions>
class CubeWidget : public QGLWidget
{
protected :
void initializeGL ( ) ;
void paintGL ( ) ;
void resizeGL(int width , int height ) ;
void mousePressEvent(QMouseEvent *event ) ;
void mouseMoveEvent(QMouseEvent *event ) ;
void wheelEvent(QWheelEvent *event ) ;
public:
CubeWidget(QWidget *parent = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
#endif // CUBEWIDGET_H
......@@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
......@@ -12,9 +12,11 @@ TARGET = hellocube
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
mainwindow.cpp \
cubewidget.cpp
HEADERS += mainwindow.h
HEADERS += mainwindow.h \
cubewidget.h
RESOURCES += \
hellocube.qrc
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-10-21T15:50:15. -->
<!-- Written by QtCreator 3.5.1, 2015-10-21T20:58:23. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
......
......@@ -78,6 +78,11 @@ MainWindow::MainWindow(QWidget *parent)
statusBar->showMessage("Hello");
setStatusBar(statusBar);
//Main Widget
mainWidget = new CubeWidget(this);
setCentralWidget(mainWidget);
}
......
......@@ -11,6 +11,8 @@
#include <QToolBar>
#include <QStatusBar>
#include <cubewidget.h>
class MainWindow : public QMainWindow
{
......@@ -36,6 +38,8 @@ private:
QToolBar *toolBar;
QStatusBar *statusBar;
CubeWidget *mainWidget;
public:
MainWindow(QWidget *parent = 0);
......
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