This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Eigen with OpenGL VAO

Tags: None
(comma "," separated)
alexanderc
Registered Member
Posts
6
Karma
0

Eigen with OpenGL VAO

Mon Jun 23, 2014 11:34 pm
Hello ,

I am trying to integrate Eigen into an OpenGL application but I am having problem with creating VAO using Eigen Vector3f inside a structure.
If I define something like this:

Code: Select all
struct Vertex
{
   Eigen::Vector3f position;
   Eigen::Vector3f normal;
   Eigen::Vector2f texcoord;
};


Then if I pass it to glVertexAttribPointer , I am not sure what the size of the stride should be ?
What is the suggested workflow in this case ?

Thanks in advance,

Alex
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Eigen with OpenGL VAO

Wed Jun 25, 2014 12:03 pm
The stride should be 'sizeof(Vertex)'. For the pointer offsets, the safest is to let the compiler computes it for you, e.g.:

Vertex *vertices = ...;

then the offset for the texture coordinates is: (void*)(vertices[0].texcoord.data() - vertices[0].position.data())


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]