Skip to main content

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uvnormal should be 2412, &vertices[0].normaluv should be 1224 and, and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {          //previousfloats * sizeof(float) = offset
    glm::vec3 position;  //0*4 =0 * 4 = 0
    glm::vec3 normal;    // 3 * 4 = 12
    glm::vec2 uv;        // 6 * 4 = 24
    glm::vec3 tangent;   // 8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

See the documentation for the glVertexAttribPointer here. The big hint being:

pointer

Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0.

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uv should be 24, &vertices[0].normal should be 12 and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {         //previousfloats * sizeof(float) = offset
    glm::vec3 position; //0*4 = 4
    glm::vec3 normal; //3 * 4 = 12
    glm::vec2 uv; //6 * 4 = 24
    glm::vec3 tangent; //8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

See the documentation for the glVertexAttribPointer here. The big hint being:

pointer

Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0.

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].normal should be 12, &vertices[0].uv should be 24, and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {          //previousfloats * sizeof(float) = offset
    glm::vec3 position;  // 0 * 4 = 0
    glm::vec3 normal;    // 3 * 4 = 12
    glm::vec2 uv;        // 6 * 4 = 24
    glm::vec3 tangent;   // 8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

See the documentation for the glVertexAttribPointer here. The big hint being:

pointer

Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0.

added 320 characters in body
Source Link
House
  • 73.3k
  • 17
  • 185
  • 273

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uv should be 24, &vertices[0].normal should be 12 and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {         //previousfloats * sizeof(float) = offset
    glm::vec3 position; //0*4 = 4
    glm::vec3 normal; //3 * 4 = 12
    glm::vec2 uv; //6 * 4 = 24
    glm::vec3 tangent; //8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

See the documentation for the glVertexAttribPointer here. The big hint being:

pointer

Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0.

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uv should be 24, &vertices[0].normal should be 12 and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {         //previousfloats * sizeof(float) = offset
    glm::vec3 position; //0*4 = 4
    glm::vec3 normal; //3 * 4 = 12
    glm::vec2 uv; //6 * 4 = 24
    glm::vec3 tangent; //8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uv should be 24, &vertices[0].normal should be 12 and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {         //previousfloats * sizeof(float) = offset
    glm::vec3 position; //0*4 = 4
    glm::vec3 normal; //3 * 4 = 12
    glm::vec2 uv; //6 * 4 = 24
    glm::vec3 tangent; //8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};

See the documentation for the glVertexAttribPointer here. The big hint being:

pointer

Specifies a pointer to the first component of the first generic vertex attribute in the array. The initial value is 0.

Source Link
House
  • 73.3k
  • 17
  • 185
  • 273

I think you want to change your attribute pointers, specifically the offsets you have listed. &vertices[0].position should be 0, &vertices[0].uv should be 24, &vertices[0].normal should be 12 and so on.

Since getting the address of a struct member gives you the absolute address instead of the address relative to the beginning of the struct. glVertexAttribPointer is looking for the offset into your interleaved set.

struct Vertex {         //previousfloats * sizeof(float) = offset
    glm::vec3 position; //0*4 = 4
    glm::vec3 normal; //3 * 4 = 12
    glm::vec2 uv; //6 * 4 = 24
    glm::vec3 tangent; //8 * 4 = 32
    glm::vec3 bitangent; // 11 * 4 = 44
};