Refactoring in GCodeViewer
This commit is contained in:
parent
46e4f54fd0
commit
194cab75d9
@ -3756,11 +3756,11 @@ void GCodeViewer::render_toolpaths() const
|
||||
const IBuffer& i_buffer = buffer.indices[j];
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, i_buffer.vbo));
|
||||
glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_size()));
|
||||
glsafe(::glVertexPointer(buffer.vertices.position_size_floats(), GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.position_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
bool has_normals = buffer.vertices.normal_size_floats() > 0;
|
||||
if (has_normals) {
|
||||
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_size()));
|
||||
glsafe(::glNormalPointer(GL_FLOAT, buffer.vertices.vertex_size_bytes(), (const void*)buffer.vertices.normal_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
}
|
||||
|
||||
@ -3802,11 +3802,11 @@ void GCodeViewer::render_toolpaths() const
|
||||
shader->start_using();
|
||||
|
||||
glsafe(::glBindBuffer(GL_ARRAY_BUFFER, cap.vbo));
|
||||
glsafe(::glVertexPointer(cap.buffer->vertices.position_size_floats(), GL_FLOAT, cap.buffer->vertices.vertex_size_bytes(), (const void*)cap.buffer->vertices.position_offset_size()));
|
||||
glsafe(::glVertexPointer(cap.buffer->vertices.position_size_floats(), GL_FLOAT, cap.buffer->vertices.vertex_size_bytes(), (const void*)cap.buffer->vertices.position_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
|
||||
bool has_normals = cap.buffer->vertices.normal_size_floats() > 0;
|
||||
if (has_normals) {
|
||||
glsafe(::glNormalPointer(GL_FLOAT, cap.buffer->vertices.vertex_size_bytes(), (const void*)cap.buffer->vertices.normal_offset_size()));
|
||||
glsafe(::glNormalPointer(GL_FLOAT, cap.buffer->vertices.vertex_size_bytes(), (const void*)cap.buffer->vertices.normal_offset_bytes()));
|
||||
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
|
||||
}
|
||||
|
||||
|
@ -89,35 +89,20 @@ class GCodeViewer
|
||||
size_t vertex_size_bytes() const { return vertex_size_floats() * sizeof(float); }
|
||||
|
||||
size_t position_offset_floats() const { return 0; }
|
||||
size_t position_offset_size() const { return position_offset_floats() * sizeof(float); }
|
||||
size_t position_size_floats() const {
|
||||
switch (format)
|
||||
{
|
||||
case EFormat::Position:
|
||||
case EFormat::PositionNormal3: { return 3; }
|
||||
case EFormat::PositionNormal1: { return 4; }
|
||||
default: { return 0; }
|
||||
}
|
||||
}
|
||||
size_t position_offset_bytes() const { return position_offset_floats() * sizeof(float); }
|
||||
|
||||
size_t position_size_floats() const { return 3; }
|
||||
size_t position_size_bytes() const { return position_size_floats() * sizeof(float); }
|
||||
|
||||
size_t normal_offset_floats() const {
|
||||
switch (format)
|
||||
{
|
||||
case EFormat::Position:
|
||||
case EFormat::PositionNormal1: { return 0; }
|
||||
case EFormat::PositionNormal3: { return 3; }
|
||||
default: { return 0; }
|
||||
}
|
||||
}
|
||||
size_t normal_offset_size() const { return normal_offset_floats() * sizeof(float); }
|
||||
size_t normal_offset_floats() const { return position_size_floats(); }
|
||||
size_t normal_offset_bytes() const { return normal_offset_floats() * sizeof(float); }
|
||||
|
||||
size_t normal_size_floats() const {
|
||||
switch (format)
|
||||
{
|
||||
default:
|
||||
case EFormat::Position:
|
||||
case EFormat::PositionNormal1: { return 0; }
|
||||
case EFormat::PositionNormal1: { return 1; }
|
||||
case EFormat::PositionNormal3: { return 3; }
|
||||
default: { return 0; }
|
||||
}
|
||||
}
|
||||
size_t normal_size_bytes() const { return normal_size_floats() * sizeof(float); }
|
||||
|
Loading…
Reference in New Issue
Block a user