293 pointsToRender(polygon, [&](const glm::vec3& point, const glm::vec3& normal){ |
293 pointsToRender(polygon, [&](const glm::vec3& point, const glm::vec3& normal){ |
294 gl::ModelShaders::Vertex& vertex = vertexBuffer.emplace_back(); |
294 gl::ModelShaders::Vertex& vertex = vertexBuffer.emplace_back(); |
295 vertex.position = point; |
295 vertex.position = point; |
296 vertex.normal = normal; |
296 vertex.normal = normal; |
297 vertex.color = glm::vec4{color.redF(), color.greenF(), color.blueF(), color.alphaF()}; |
297 vertex.color = glm::vec4{color.redF(), color.greenF(), color.blueF(), color.alphaF()}; |
298 vertex.id = polygon.id.value; |
298 vertex.id = polygon.linenumber; |
299 vertex.pickcolor = idToColor(polygon.id.value); |
299 vertex.pickcolor = idToColor(polygon.linenumber); |
300 }); |
300 }); |
301 }); |
301 }); |
302 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) |
302 for (gl::ModelShaders::ShaderObject& shader : shaders->shaderObjects) |
303 { |
303 { |
304 shader.vertexCount = shader.cachedData.size(); |
304 shader.vertexCount = shader.cachedData.size(); |
307 shader.buffer.allocate(shader.cachedData.data(), bytes); |
307 shader.buffer.allocate(shader.cachedData.data(), bytes); |
308 shader.buffer.release(); |
308 shader.buffer.release(); |
309 } |
309 } |
310 } |
310 } |
311 |
311 |
312 ElementId gl::idFromUcharColor(const std::array<GLubyte, 3>& data) |
312 int gl::idFromUcharColor(const std::array<GLubyte, 3>& data) |
313 { |
313 { |
314 return { |
314 return |
315 static_cast<std::int32_t>(data[0]) | |
315 static_cast<std::int32_t>(data[0]) | |
316 static_cast<std::int32_t>(data[1]) << 8 | |
316 static_cast<std::int32_t>(data[1]) << 8 | |
317 static_cast<std::int32_t>(data[2]) << 16 |
317 static_cast<std::int32_t>(data[2]) << 16; |
318 }; |
|
319 } |
318 } |
320 |
319 |
321 void gl::bindModelShaderVertexArray(gl::ModelShaders* shaders, gl::ArrayClass arrayClass) |
320 void gl::bindModelShaderVertexArray(gl::ModelShaders* shaders, gl::ArrayClass arrayClass) |
322 { |
321 { |
323 ModelShaders::ShaderObject& shaderObject = shaders->shaderObjects[static_cast<int>(arrayClass)]; |
322 ModelShaders::ShaderObject& shaderObject = shaders->shaderObjects[static_cast<int>(arrayClass)]; |
330 ModelShaders::ShaderObject& shaderObject = shaders->shaderObjects[static_cast<int>(arrayClass)]; |
329 ModelShaders::ShaderObject& shaderObject = shaders->shaderObjects[static_cast<int>(arrayClass)]; |
331 shaderObject.program->release(); |
330 shaderObject.program->release(); |
332 shaderObject.vertexArray.release(); |
331 shaderObject.vertexArray.release(); |
333 } |
332 } |
334 |
333 |
|
334 /* |
335 void gl::setModelShaderSelectedObjects(gl::ModelShaders* shaders, const QSet<ElementId> &ids) |
335 void gl::setModelShaderSelectedObjects(gl::ModelShaders* shaders, const QSet<ElementId> &ids) |
336 { |
336 { |
337 for (ModelShaders::ShaderObject& object : shaders->shaderObjects) |
337 for (ModelShaders::ShaderObject& object : shaders->shaderObjects) |
338 { |
338 { |
339 std::vector<ModelShaders::Vertex>& vector = object.cachedData; |
339 std::vector<ModelShaders::Vertex>& vector = object.cachedData; |
345 object.buffer.bind(); |
345 object.buffer.bind(); |
346 glBufferSubData(GL_ARRAY_BUFFER, 0, size, vector.data()); |
346 glBufferSubData(GL_ARRAY_BUFFER, 0, size, vector.data()); |
347 object.buffer.release(); |
347 object.buffer.release(); |
348 } |
348 } |
349 } |
349 } |
|
350 */ |
350 |
351 |
351 std::size_t gl::vertexCount(const gl::ModelShaders* shaders, const gl::ArrayClass arrayClass) |
352 std::size_t gl::vertexCount(const gl::ModelShaders* shaders, const gl::ArrayClass arrayClass) |
352 { |
353 { |
353 return shaders->shaderObjects[static_cast<int>(arrayClass)].vertexCount; |
354 return shaders->shaderObjects[static_cast<int>(arrayClass)].vertexCount; |
354 } |
355 } |