10 #ifndef EIGEN_GPUHELPER_H 11 #define EIGEN_GPUHELPER_H 13 #include <Eigen/Geometry> 17 using namespace Eigen;
19 typedef Vector4f Color;
29 enum ProjectionMode2D { PM_Normalized = 1, PM_Viewport = 2 };
30 void pushProjectionMode2D(ProjectionMode2D pm);
31 void popProjectionMode2D();
40 template<
typename Scalar,
int _Flags>
50 template<
typename Scalar,
int _Flags>
53 template<
typename Scalar,
typename Derived>
63 inline void forceMatrixTarget(GLenum matrixTarget) {glMatrixMode(mCurrentMatrixTarget=matrixTarget);}
65 inline void setMatrixTarget(GLenum matrixTarget);
69 template<
typename Scalar,
int _Flags>
72 template<
typename Scalar,
typename Derived>
79 inline void pushMatrix(GLenum matrixTarget);
83 inline void popMatrix(GLenum matrixTarget);
85 void drawVector(
const Vector3f& position,
const Vector3f& vec,
const Color& color,
float aspect = 50.);
86 void drawVectorBox(
const Vector3f& position,
const Vector3f& vec,
const Color& color,
float aspect = 50.);
87 void drawUnitCube(
void);
88 void drawUnitSphere(
int level=0);
91 inline void draw(GLenum mode, uint nofElement);
94 inline void draw(GLenum mode, uint start, uint end);
97 inline void draw(GLenum mode,
const std::vector<uint>* pIndexes);
103 GLuint mColorBufferId;
104 int mVpWidth, mVpHeight;
105 GLenum mCurrentMatrixTarget;
134 inline void GpuHelper::setMatrixTarget(GLenum matrixTarget)
136 if (matrixTarget != mCurrentMatrixTarget)
137 glMatrixMode(mCurrentMatrixTarget=matrixTarget);
140 template<
typename Scalar,
int _Flags>
143 setMatrixTarget(matrixTarget);
147 template<
typename Scalar,
typename Derived>
152 setMatrixTarget(matrixTarget);
156 template<
typename Scalar,
int _Flags>
159 setMatrixTarget(matrixTarget);
165 setMatrixTarget(matrixTarget);
169 template<
typename Scalar,
int _Flags>
172 pushMatrix(matrixTarget);
176 template<
typename Scalar,
typename Derived>
181 pushMatrix(matrixTarget);
187 setMatrixTarget(matrixTarget);
193 glDrawArrays(mode, 0, nofElement);
199 glDrawElements(mode, pIndexes->size(), GL_UNSIGNED_INT, &(pIndexes->front()));
204 glDrawArrays(mode, start, end-start);
207 #endif // EIGEN_GPUHELPER_H void draw(GLenum mode, uint nofElement)
draw the nofElement first elements
Definition: gpuhelper.h:191
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
void forceMatrixTarget(GLenum matrixTarget)
Make the matrix matrixTarget the current OpenGL matrix target.
Definition: gpuhelper.h:63
Definition: gpuhelper.h:21
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:249
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
void popMatrix(GLenum matrixTarget)
Pop the OpenGL matrix matrixTarget.
Definition: gpuhelper.h:185
void pushMatrix(const Matrix< Scalar, 4, 4, _Flags, 4, 4 > &mat, GLenum matrixTarget)
Push the OpenGL matrix matrixTarget and load mat.
Definition: gpuhelper.h:170
void loadMatrix(const Eigen::Matrix< Scalar, 4, 4, _Flags, 4, 4 > &mat, GLenum matrixTarget)
Load the matrix mat to the OpenGL matrix matrixTarget.
Definition: gpuhelper.h:157
Definition: gpuhelper.h:116
Definition: NullaryFunctors.h:31
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
void multMatrix(const Matrix< Scalar, 4, 4, _Flags, 4, 4 > &mat, GLenum matrixTarget)
Multiply the OpenGL matrix matrixTarget by the matrix mat.
Definition: gpuhelper.h:141