Got rid of segfault when uploading VBOs.
Added go-to-zero function. Reworked how work pos is obtained.
This commit is contained in:
+14
-7
@@ -91,8 +91,13 @@ void grbl::program_renderer::update(const grbl::program& pgm, const grbl::machin
|
||||
// build vbo and vao
|
||||
vertices_count = build_vbo(pgm);
|
||||
|
||||
auto x = cnc.get_status().work_pos;
|
||||
spindle_pos = glm::vec3(x[0], x[1], x[2]);
|
||||
auto work_pos = cnc.get_status().machine_pos;
|
||||
auto offsets = cnc.get_current_work_offset_values();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
work_pos[i] -= offsets[i];
|
||||
}
|
||||
|
||||
spindle_pos = glm::vec3(work_pos[0], work_pos[1], work_pos[2]);
|
||||
}
|
||||
|
||||
void grbl::program_renderer::initialize_spindle_buffers() {
|
||||
@@ -148,7 +153,7 @@ void grbl::program_renderer::initialize_spindle_buffers() {
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, spindle_vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeOfVertexInBytes * buffer_data.size(), buffer_data.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buffer_data.size(), buffer_data.data(), GL_STATIC_DRAW);
|
||||
|
||||
spindle_vertices_count = buffer_data.size() * sizeof(float) / sizeOfVertexInBytes;
|
||||
}
|
||||
@@ -178,7 +183,8 @@ GLsizei grbl::program_renderer::build_vbo(const grbl::program& pgm) {
|
||||
static auto movement_re = std::regex(R"(([gG]0*1?\s+|[xXyYzZ]\s*[0-9\.\-]+))");
|
||||
bool is_tool_on = false;
|
||||
|
||||
std::vector<float> buffer_data;
|
||||
|
||||
buffer_data.clear();
|
||||
|
||||
glm::vec3 tool_pos;
|
||||
min_pos = max_pos = tool_pos = glm::vec3(0);
|
||||
@@ -270,10 +276,11 @@ GLsizei grbl::program_renderer::build_vbo(const grbl::program& pgm) {
|
||||
}
|
||||
|
||||
const GLsizei sizeOfVertexInBytes = 28;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeOfVertexInBytes * buffer_data.size(), buffer_data.data(), GL_DYNAMIC_DRAW);
|
||||
|
||||
auto number_of_vertices = buffer_data.size() * sizeof(float) / sizeOfVertexInBytes;
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buffer_data.size(), buffer_data.data(), GL_STATIC_DRAW);
|
||||
|
||||
return number_of_vertices;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user