diff options
author | Jakob Odersky <jodersky@gmail.com> | 2011-03-29 19:21:17 +0000 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2011-03-29 19:21:17 +0000 |
commit | b1729c8ac1eaf48e78f7163983842ec00774fa10 (patch) | |
tree | 386dca9fb775f86e54b753e17959d8b9c752bceb /src/gui | |
parent | 9aae664e3c7dbbe8ba5bde9959b88e7d55377f6d (diff) | |
download | vhc-b1729c8ac1eaf48e78f7163983842ec00774fa10.tar.gz vhc-b1729c8ac1eaf48e78f7163983842ec00774fa10.tar.bz2 vhc-b1729c8ac1eaf48e78f7163983842ec00774fa10.zip |
Modification de `ParticleTest'.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/GLWidget.cc | 78 | ||||
-rw-r--r-- | src/gui/GLWidget.h | 27 | ||||
-rw-r--r-- | src/gui/Makefile | 2 | ||||
-rw-r--r-- | src/gui/moc_GLWidget.cpp | 69 |
4 files changed, 175 insertions, 1 deletions
diff --git a/src/gui/GLWidget.cc b/src/gui/GLWidget.cc new file mode 100644 index 0000000..60d411b --- /dev/null +++ b/src/gui/GLWidget.cc @@ -0,0 +1,78 @@ +#include <QtOpenGL> +#include "GLWidget.h" + +GLWidget::GLWidget (QWidget* parent) + : QGLWidget (parent) +{ + resize (sizeHint ()); +} + +GLWidget::~GLWidget () {} + +QSize GLWidget::minimumSizeHint () const { + return QSize (50, 50); +} + +QSize GLWidget::sizeHint () const { + return QSize (800, 600); +} + +void GLWidget::initializeGL () { + glClearColor (255, 255, 255, 1.0); + glEnable (GL_DEPTH_TEST); + gluPerspective(65.0, 4.0/3, 1.0, 1000.0); +} + +void GLWidget::paintGL () { + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glLoadIdentity (); + //gluLookAt(0,0,0, + // 0,0,0, + // 0,0,1); + //glTranslated (0.0, 0.0, -10.0); + //glColor3d (0.0, 0.0, 1.0); + //glScaled (300.0, 300.0, 300.0); + + glBegin (GL_POLYGON); + glColor3d(1,0,0); + glVertex3d (-300, -300, 0.0); + glColor3d(0,1,0); + glVertex3d (300 + 10, -300, 0.0); + glColor3d(0,0,1); + glVertex3d (0, 300, 0.0); + glColor3d(1,1,1); + glVertex3d (0, 0, 100); + glColor3d(0,1,0); + glVertex3d (300 + 10, -300, 0.0); + glEnd (); +} + +void GLWidget::resizeGL (int width, int height) { + glViewport (0, 0, width, height); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glOrtho (-width, width, -height, height, -100.0, 100.0); + glMatrixMode (GL_MODELVIEW); +} + +void GLWidget::mousePressEvent (QMouseEvent* event) { +} + +void GLWidget::mouseReleaseEvent (QMouseEvent* event) { +} + +void GLWidget::keyPressEvent (QKeyEvent* event) { + switch (event->key()) { + case Qt::Key_Escape: + qApp->quit(); + break; + case Qt::Key_Up: + qApp->quit(); + break; + default: + break; + } +} + +void GLWidget::keyReleaseEvent (QKeyEvent* event) { +} diff --git a/src/gui/GLWidget.h b/src/gui/GLWidget.h new file mode 100644 index 0000000..b2cd02d --- /dev/null +++ b/src/gui/GLWidget.h @@ -0,0 +1,27 @@ +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include <QGLWidget> +class GLWidget : public QGLWidget +{ + Q_OBJECT + +public: + GLWidget (QWidget* parent = 0); + ~GLWidget (); + + QSize minimumSizeHint () const; + QSize sizeHint () const; + +protected: + + void initializeGL (); + void paintGL (); + void resizeGL (int width, int height); + void mousePressEvent (QMouseEvent* event); + void mouseReleaseEvent (QMouseEvent* event); + void keyPressEvent (QKeyEvent* event); + void keyReleaseEvent (QKeyEvent* event); +}; + +#endif diff --git a/src/gui/Makefile b/src/gui/Makefile index 8595ac2..aed836b 100644 --- a/src/gui/Makefile +++ b/src/gui/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: $(BINDIR)/gui/gui -# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Mar 29 19:14:31 2011 +# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Mar 29 20:46:53 2011 # Project: gui.pro # Template: app # Command: /usr/bin/qmake -o Makefile gui.pro diff --git a/src/gui/moc_GLWidget.cpp b/src/gui/moc_GLWidget.cpp new file mode 100644 index 0000000..bef8a88 --- /dev/null +++ b/src/gui/moc_GLWidget.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** Meta object code from reading C++ file 'GLWidget.h' +** +** Created: Mon Mar 28 20:36:46 2011 +** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include "GLWidget.h" +#if !defined(Q_MOC_OUTPUT_REVISION) +#error "The header file 'GLWidget.h' doesn't include <QObject>." +#elif Q_MOC_OUTPUT_REVISION != 62 +#error "This file was generated using the moc from 4.7.0. It" +#error "cannot be used with the include files from this version of Qt." +#error "(The moc has changed too much.)" +#endif + +QT_BEGIN_MOC_NAMESPACE +static const uint qt_meta_data_GLWidget[] = { + + // content: + 5, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 0, // flags + 0, // signalCount + + 0 // eod +}; + +static const char qt_meta_stringdata_GLWidget[] = { + "GLWidget\0" +}; + +const QMetaObject GLWidget::staticMetaObject = { + { &QGLWidget::staticMetaObject, qt_meta_stringdata_GLWidget, + qt_meta_data_GLWidget, 0 } +}; + +#ifdef Q_NO_DATA_RELOCATION +const QMetaObject &GLWidget::getStaticMetaObject() { return staticMetaObject; } +#endif //Q_NO_DATA_RELOCATION + +const QMetaObject *GLWidget::metaObject() const +{ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; +} + +void *GLWidget::qt_metacast(const char *_clname) +{ + if (!_clname) return 0; + if (!strcmp(_clname, qt_meta_stringdata_GLWidget)) + return static_cast<void*>(const_cast< GLWidget*>(this)); + return QGLWidget::qt_metacast(_clname); +} + +int GLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) +{ + _id = QGLWidget::qt_metacall(_c, _id, _a); + if (_id < 0) + return _id; + return _id; +} +QT_END_MOC_NAMESPACE |