summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2011-03-31 14:55:08 +0000
committerJakob Odersky <jodersky@gmail.com>2011-03-31 14:55:08 +0000
commitdbd8760e5b935dfd8d6672964075c5064159749f (patch)
treee83c46ab339b83f10cccbf587fb42d5b1ec4e407 /src/gui
parentd84ecd9ecbdc97459f76ba374fbdd815a0c8964c (diff)
downloadvhc-dbd8760e5b935dfd8d6672964075c5064159749f.tar.gz
vhc-dbd8760e5b935dfd8d6672964075c5064159749f.tar.bz2
vhc-dbd8760e5b935dfd8d6672964075c5064159749f.zip
Essais OpenGL
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/GLWidget.cc15
-rw-r--r--src/gui/Makefile11
-rw-r--r--src/gui/gui.pro4
3 files changed, 19 insertions, 11 deletions
diff --git a/src/gui/GLWidget.cc b/src/gui/GLWidget.cc
index 4fb43fa..8d91c16 100644
--- a/src/gui/GLWidget.cc
+++ b/src/gui/GLWidget.cc
@@ -2,21 +2,21 @@
#include <math.h>
#include "GLWidget.h"
-void torus(int numc, int numt) {
+void torus(int numc, int numt, double R = 1, double r = 0.1) {
int i, j, k;
double s, t, x, y, z, twopi;
twopi = 2 * M_PI;
for (i = 0; i < numc; i++) {
glBegin(GL_QUAD_STRIP);
- for (j = 0; j <= numt; j++) {
+ for (j = 0; j <= numt ; j++) {
for (k = 1; k >= 0; k--) {
s = (i + k) % numc + 0.5;
t = j % numt;
- x = (1+.1*cos(s*twopi/numc))*cos(t*twopi/numt);
- y = (1+.1*cos(s*twopi/numc))*sin(t*twopi/numt);
- z = .1 * sin(s * twopi / numc);
+ x = (R+r*cos(s*twopi/numc))*cos(t*twopi/numt);
+ y = (R+r*cos(s*twopi/numc))*sin(t*twopi/numt);
+ z = r * sin(s * twopi / numc);
glColor3d(0, s/numc, t/numc);
glVertex3f(x, y, z);
}
@@ -98,7 +98,10 @@ void GLWidget::paintGL () {
glColor3d(0,0,1);
glScaled(300,300,300);
- torus(80, 250);
+ glPolygonMode(GL_FRONT, GL_LINE);
+ glPolygonMode(GL_BACK, GL_LINE);
+
+ torus(12, 20, 1, 0.2);
}
void GLWidget::resizeGL (int width, int height) {
diff --git a/src/gui/Makefile b/src/gui/Makefile
index 52f8f7f..3d4afd4 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: Wed Mar 30 20:40:02 2011
+# Generated by qmake (2.01a) (Qt 4.7.0) on: Thu Mar 31 16:54:10 2011
# Project: gui.pro
# Template: app
# Command: /usr/bin/qmake -o Makefile gui.pro
@@ -44,9 +44,11 @@ OBJECTS_DIR = $(BINDIR)/gui/
####### Files
SOURCES = Main.cc \
- GLWidget.cc moc_GLWidget.cpp
+ GLWidget.cc \
+ Camera.cc moc_GLWidget.cpp
OBJECTS = $(BINDIR)/gui/Main.o \
$(BINDIR)/gui/GLWidget.o \
+ $(BINDIR)/gui/Camera.o \
$(BINDIR)/gui/moc_GLWidget.o
DIST = /usr/share/qt4/mkspecs/common/g++.conf \
/usr/share/qt4/mkspecs/common/unix.conf \
@@ -156,7 +158,7 @@ qmake: FORCE
dist:
@$(CHK_DIR_EXISTS) $(BINDIR)/gui/gui1.0.0 || $(MKDIR) $(BINDIR)/gui/gui1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) $(BINDIR)/gui/gui1.0.0/ && $(COPY_FILE) --parents GLWidget.h $(BINDIR)/gui/gui1.0.0/ && $(COPY_FILE) --parents Main.cc GLWidget.cc $(BINDIR)/gui/gui1.0.0/ && (cd `dirname $(BINDIR)/gui/gui1.0.0` && $(TAR) gui1.0.0.tar gui1.0.0 && $(COMPRESS) gui1.0.0.tar) && $(MOVE) `dirname $(BINDIR)/gui/gui1.0.0`/gui1.0.0.tar.gz . && $(DEL_FILE) -r $(BINDIR)/gui/gui1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) $(BINDIR)/gui/gui1.0.0/ && $(COPY_FILE) --parents GLWidget.h Camera.h $(BINDIR)/gui/gui1.0.0/ && $(COPY_FILE) --parents Main.cc GLWidget.cc Camera.cc $(BINDIR)/gui/gui1.0.0/ && (cd `dirname $(BINDIR)/gui/gui1.0.0` && $(TAR) gui1.0.0.tar gui1.0.0 && $(COMPRESS) gui1.0.0.tar) && $(MOVE) `dirname $(BINDIR)/gui/gui1.0.0`/gui1.0.0.tar.gz . && $(DEL_FILE) -r $(BINDIR)/gui/gui1.0.0
clean:compiler_clean
@@ -208,6 +210,9 @@ $(BINDIR)/gui/Main.o: Main.cc GLWidget.h
$(BINDIR)/gui/GLWidget.o: GLWidget.cc GLWidget.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(BINDIR)/gui/GLWidget.o GLWidget.cc
+$(BINDIR)/gui/Camera.o: Camera.cc Camera.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(BINDIR)/gui/Camera.o Camera.cc
+
$(BINDIR)/gui/moc_GLWidget.o: moc_GLWidget.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(BINDIR)/gui/moc_GLWidget.o moc_GLWidget.cpp
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 1ccb513..fc82d3f 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -10,5 +10,5 @@ LIBS += -L$(BINDIR)/main -lvhc
QT += opengl
# Input
-HEADERS += GLWidget.h
-SOURCES += Main.cc GLWidget.cc
+HEADERS += GLWidget.h Camera.h
+SOURCES += Main.cc GLWidget.cc Camera.cc