Skip to content

Commit

Permalink
move stride to the binding
Browse files Browse the repository at this point in the history
  • Loading branch information
WinteryFox committed Nov 7, 2023
1 parent ddc587f commit 0a96901
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion engine/gl/GlVertexArrayObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Vixen::Gl {
for (const auto &binding: bindings) {
for (const auto &location: binding.locations) {
glVertexArrayVertexBuffer(vao, location.index, binding.buffer->getBuffer(), location.offset,
location.stride);
static_cast<GLsizei>(binding.stride));
glVertexArrayAttribFormat(vao, location.index, location.size, location.type, location.normalized,
location.offset);
glEnableVertexArrayAttrib(vao, location.index);
Expand Down
13 changes: 7 additions & 6 deletions engine/gl/GlVertexArrayObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace Vixen::Gl {
struct VertexBinding {
struct Location {
Location(GLuint index, GLint size, GLenum type, GLboolean normalized, GLintptr offset, GLsizei stride)
: index(index), size(size), type(type), normalized(normalized), offset(offset), stride(stride) {}
Location(GLuint index, GLint size, GLenum type, GLboolean normalized, GLintptr offset)
: index(index), size(size), type(type), normalized(normalized), offset(offset) {}

GLuint index;

Expand All @@ -19,15 +19,16 @@ namespace Vixen::Gl {
GLboolean normalized;

GLintptr offset;

GLsizei stride;
};

VertexBinding(uint32_t index, const std::shared_ptr<GlBuffer> &buffer, const std::vector<Location> &locations)
: index(index), buffer(buffer), locations(locations) {}
VertexBinding(uint32_t index, uint32_t stride, const std::shared_ptr<GlBuffer> &buffer,
const std::vector<Location> &locations)
: index(index), stride(stride), buffer(buffer), locations(locations) {}

uint32_t index;

uint32_t stride;

std::shared_ptr<GlBuffer> buffer;

std::vector<Location> locations;
Expand Down
7 changes: 3 additions & 4 deletions engine/gl/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,22 @@ int main() {
{
Vixen::Gl::VertexBinding(
0,
sizeof(Vertex),
vbo,
{
Vixen::Gl::VertexBinding::Location(
0,
3,
GL_FLOAT,
GL_FALSE,
offsetof(Vertex, position),
sizeof(Vertex)
offsetof(Vertex, position)
),
Vixen::Gl::VertexBinding::Location(
1,
3,
GL_FLOAT,
GL_FALSE,
offsetof(Vertex, color),
sizeof(Vertex)
offsetof(Vertex, color)
)
}
)
Expand Down

0 comments on commit 0a96901

Please sign in to comment.