aboutsummaryrefslogtreecommitdiffhomepage
path: root/demos
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-03-13 13:17:19 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-03-13 13:17:19 +0000
commit312994fa988e94e54b1e30aa28d06dca0c4c6f2a (patch)
tree7bde0b06fa1c1e31f870da0ad9ffe21511842a0d /demos
parentc6264d9b7e238740885cbc16b01964a9f1930487 (diff)
opengl demo: add aligned operator new where appropriate and remove my
mess...
Diffstat (limited to 'demos')
-rw-r--r--demos/opengl/camera.h3
-rw-r--r--demos/opengl/quaternion_demo.cpp75
-rw-r--r--demos/opengl/quaternion_demo.h4
3 files changed, 20 insertions, 62 deletions
diff --git a/demos/opengl/camera.h b/demos/opengl/camera.h
index f6d0d7da3..44a1ca9ed 100644
--- a/demos/opengl/camera.h
+++ b/demos/opengl/camera.h
@@ -32,6 +32,8 @@
class Frame
{
public:
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+
inline Frame(const Eigen::Vector3f& pos = Eigen::Vector3f::Zero(),
const Eigen::Quaternionf& o = Eigen::Quaternionf())
: orientation(o), position(pos)
@@ -49,6 +51,7 @@ class Frame
class Camera
{
public:
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Camera(void);
diff --git a/demos/opengl/quaternion_demo.cpp b/demos/opengl/quaternion_demo.cpp
index f7ff0b77e..10b18cd0b 100644
--- a/demos/opengl/quaternion_demo.cpp
+++ b/demos/opengl/quaternion_demo.cpp
@@ -44,6 +44,8 @@ using namespace Eigen;
class FancySpheres
{
public:
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+
FancySpheres()
{
const int levels = 4;
@@ -262,67 +264,18 @@ void RenderingWidget::drawScene()
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Vector4f(1, 1, 1, 1).data());
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 64);
-// glEnable(GL_LIGHTING);
-// glEnable(GL_LIGHT0);
-// glEnable(GL_LIGHT1);
-
- glColor3f(0.4, 0.7, 0.4);
-
- {IcoSphere s(5);
- float length = 6;
-// const std::vector<int>& indices = s.indices(2);
- for (unsigned int i=0; i<s.vertices().size() ; ++i)
- {
- Vector3f n = s.vertices()[i].normalized();
- Vector3f p = n*100;
-
- int i,j;
- float minc = n.minCoeff(&i);
- float maxc = n.maxCoeff(&j);
- Vector3f o = n;
- o[i] = -n[j];
- o[j] = n[i];
-
- //Vector3f u = n.unitOrthogonal().normalized();
- Vector3f u = n.cross(o).normalized();
- Vector3f v = n.cross(u).normalized();
- gpu.drawVector(p, length*u, Color(1,0,0,1));
- gpu.drawVector(p, length*v, Color(0,1,0,1));
-// gpu.drawVector(p, length*n, Color(0,0,1,1));
- }}
-
- for(;;)
- {
- Vector3f n = Vector3f::Random().normalized();
-// Vector3f p = n*100;
- //Vector3f u = n.unitOrthogonal().normalized();
-// int i,j;
-// float minc = n.minCoeff(&i);
-// float maxc = n.maxCoeff(&j);
-
-// Vector3f o = n;
-// o[i] = -n[j];
-// o[j] = n[i];
- Vector3f o = Vector3f(-n.y(),n.z(),n.x()).normalized();
- Vector3f u = n.cross(o).normalized();
-
- float d = ei_abs(o.dot(n));
-
- if (d>0.9999)
- std::cout << d << " " << n.transpose() << "\n";
-
-// Vector3f v = n.cross(u).normalized();
- }
-
-
-// sFancySpheres.draw();
-// glVertexPointer(3, GL_FLOAT, 0, mVertices[0].data());
-// glNormalPointer(GL_FLOAT, 0, mNormals[0].data());
-// glEnableClientState(GL_VERTEX_ARRAY);
-// glEnableClientState(GL_NORMAL_ARRAY);
-// glDrawArrays(GL_TRIANGLES, 0, mVertices.size());
-// glDisableClientState(GL_VERTEX_ARRAY);
-// glDisableClientState(GL_NORMAL_ARRAY);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHT1);
+
+ sFancySpheres.draw();
+ glVertexPointer(3, GL_FLOAT, 0, mVertices[0].data());
+ glNormalPointer(GL_FLOAT, 0, mNormals[0].data());
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glDrawArrays(GL_TRIANGLES, 0, mVertices.size());
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
glDisable(GL_LIGHTING);
}
diff --git a/demos/opengl/quaternion_demo.h b/demos/opengl/quaternion_demo.h
index f0b883e19..605c5f472 100644
--- a/demos/opengl/quaternion_demo.h
+++ b/demos/opengl/quaternion_demo.h
@@ -108,7 +108,9 @@ class RenderingWidget : public QGLWidget
virtual void keyPressEvent(QKeyEvent * e);
//--------------------------------------------------------------------------------
- public:
+ public:
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW
+
RenderingWidget();
~RenderingWidget() { }