Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Eigen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Eigen
Commits
312994fa
Commit
312994fa
authored
16 years ago
by
Gael Guennebaud
Browse files
Options
Downloads
Patches
Plain Diff
opengl demo: add aligned operator new where appropriate and remove my
mess...
parent
c6264d9b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
demos/opengl/camera.h
+3
-0
3 additions, 0 deletions
demos/opengl/camera.h
demos/opengl/quaternion_demo.cpp
+14
-61
14 additions, 61 deletions
demos/opengl/quaternion_demo.cpp
demos/opengl/quaternion_demo.h
+3
-1
3 additions, 1 deletion
demos/opengl/quaternion_demo.h
with
20 additions
and
62 deletions
demos/opengl/camera.h
+
3
−
0
View file @
312994fa
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
demos/opengl/quaternion_demo.cpp
+
14
−
61
View file @
312994fa
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
demos/opengl/quaternion_demo.h
+
3
−
1
View file @
312994fa
...
...
@@ -108,7 +108,9 @@ class RenderingWidget : public QGLWidget
virtual
void
keyPressEvent
(
QKeyEvent
*
e
);
//--------------------------------------------------------------------------------
public
:
public
:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
RenderingWidget
();
~
RenderingWidget
()
{
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment