第一个版本
This commit is contained in:
@@ -573,7 +573,7 @@ void TextureLoading::build_command_buffers()
|
|||||||
|
|
||||||
//vkCmdDrawIndexed(draw_cmd_buffers[i], index_count, 1, 0, 0, 0);
|
//vkCmdDrawIndexed(draw_cmd_buffers[i], index_count, 1, 0, 0, 0);
|
||||||
|
|
||||||
//draw_point_cloud(draw_cmd_buffers[i]);
|
draw_point_cloud(draw_cmd_buffers[i]);
|
||||||
draw_point_cloud_line(draw_cmd_buffers[i]);
|
draw_point_cloud_line(draw_cmd_buffers[i]);
|
||||||
|
|
||||||
//draw_ui(draw_cmd_buffers[i]);
|
//draw_ui(draw_cmd_buffers[i]);
|
||||||
@@ -1495,7 +1495,7 @@ bool TextureLoading::prepare(const vkb::ApplicationOptions& options)
|
|||||||
|
|
||||||
prepared = true;
|
prepared = true;
|
||||||
|
|
||||||
update_uniform_buffers_point(50, -0.5, -0.5, 0, 1, 1, 1, 0, 0, 0, 0, 0, -1);
|
update_uniform_buffers_point(47, -0.5, -0.51, 0, 1, 1, 1, 0, 0, 0, 0, 0, -1);
|
||||||
//start();
|
//start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1619,7 +1619,7 @@ void TextureLoading::createTexture(VkDevice device, VkPhysicalDevice physicalDev
|
|||||||
VkImageCreateInfo imageInfo = {};
|
VkImageCreateInfo imageInfo = {};
|
||||||
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||||
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
imageInfo.imageType = VK_IMAGE_TYPE_2D;
|
||||||
imageInfo.format = VK_FORMAT_R8G8B8A8_SRGB; //VK_FORMAT_R8G8B8A8_UNORM;
|
imageInfo.format = VK_FORMAT_R8G8B8A8_UNORM;// VK_FORMAT_R8G8B8A8_SRGB; //VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
imageInfo.extent.width = width;
|
imageInfo.extent.width = width;
|
||||||
imageInfo.extent.height = height;
|
imageInfo.extent.height = height;
|
||||||
imageInfo.extent.depth = 1;
|
imageInfo.extent.depth = 1;
|
||||||
@@ -1656,7 +1656,7 @@ void TextureLoading::createTexture(VkDevice device, VkPhysicalDevice physicalDev
|
|||||||
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||||
viewInfo.image = texture.image;
|
viewInfo.image = texture.image;
|
||||||
viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
viewInfo.format = VK_FORMAT_R8G8B8A8_SRGB; // VK_FORMAT_R8G8B8A8_UNORM;
|
viewInfo.format = VK_FORMAT_R8G8B8A8_UNORM;// VK_FORMAT_R8G8B8A8_SRGB; // VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
viewInfo.subresourceRange.baseMipLevel = 0;
|
viewInfo.subresourceRange.baseMipLevel = 0;
|
||||||
viewInfo.subresourceRange.levelCount = 1;
|
viewInfo.subresourceRange.levelCount = 1;
|
||||||
@@ -2007,7 +2007,35 @@ void TextureLoading::demo1(float* pos)
|
|||||||
{
|
{
|
||||||
add_point(pos, points, pointIndex[i]);
|
add_point(pos, points, pointIndex[i]);
|
||||||
}
|
}
|
||||||
update_point_vertex_buffer_line(points, point_index, 0.9f, 0.9f, 0.9f);
|
std::vector<LineVertex> vertices;
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 0.9f, 0.9f, 0.9f, vertices);
|
||||||
|
|
||||||
|
point_index = 0;
|
||||||
|
add_point(pos, points, 9);
|
||||||
|
add_point(pos, points, 168);
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 1, 0, 0, vertices);
|
||||||
|
|
||||||
|
point_index = 0;
|
||||||
|
add_point(pos, points, 9);
|
||||||
|
add_point(pos, points, 104);
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 1, 0, 0, vertices);
|
||||||
|
|
||||||
|
point_index = 0;
|
||||||
|
add_point(pos, points, 9);
|
||||||
|
add_point(pos, points, 108);
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 1, 0, 0, vertices);
|
||||||
|
|
||||||
|
point_index = 0;
|
||||||
|
add_point(pos, points, 9);
|
||||||
|
add_point(pos, points, 337);
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 1, 0, 0, vertices);
|
||||||
|
|
||||||
|
point_index = 0;
|
||||||
|
add_point(pos, points, 9);
|
||||||
|
add_point(pos, points, 333);
|
||||||
|
update_point_vertex_buffer_line(points, point_index, 1, 0, 0, vertices);
|
||||||
|
|
||||||
|
update_point_vertex_buffer_line_save(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_face_round_line_point(float* pos)
|
void update_face_round_line_point(float* pos)
|
||||||
@@ -2048,11 +2076,13 @@ void update_face_round_line_point(float* pos)
|
|||||||
TextureLoading* self = TextureLoading::Get();
|
TextureLoading* self = TextureLoading::Get();
|
||||||
if (self != nullptr)
|
if (self != nullptr)
|
||||||
{
|
{
|
||||||
self->update_point_vertex_buffer_line(points, point_index, 0.9f, 0.9f, 0.9f);
|
std::vector<LineVertex> vertices;
|
||||||
|
self->update_point_vertex_buffer_line(points, point_index, 0.9f, 0.9f, 0.9f, vertices);
|
||||||
|
self->update_point_vertex_buffer_line_save(vertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureLoading::update_point_vertex_buffer_line(float* pos, int count, float r, float g, float b)
|
void TextureLoading::update_point_vertex_buffer_line(float* pos, int count, float r, float g, float b, std::vector<LineVertex>& vertices)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mtx_point_line);
|
std::lock_guard<std::mutex> lock(mtx_point_line);
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
@@ -2063,8 +2093,6 @@ void TextureLoading::update_point_vertex_buffer_line(float* pos, int count, floa
|
|||||||
|
|
||||||
glm::vec3 color = { r,g,b };
|
glm::vec3 color = { r,g,b };
|
||||||
|
|
||||||
// 1. 准备顶点数据
|
|
||||||
std::vector<LineVertex> vertices;
|
|
||||||
|
|
||||||
for (int i = 0; i < count - 1; ++i)
|
for (int i = 0; i < count - 1; ++i)
|
||||||
{
|
{
|
||||||
@@ -2089,6 +2117,11 @@ void TextureLoading::update_point_vertex_buffer_line(float* pos, int count, floa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextureLoading::update_point_vertex_buffer_line_save(std::vector<LineVertex>& vertices)
|
||||||
|
{
|
||||||
point_count_line = vertices.size();
|
point_count_line = vertices.size();
|
||||||
|
|
||||||
// 2. 更新或创建顶点缓冲区
|
// 2. 更新或创建顶点缓冲区
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void update_point_vertex_buffer(float* pos, int pointCount);
|
void update_point_vertex_buffer(float* pos, int pointCount);
|
||||||
void update_point_vertex_buffer_line(float* pos, int pointCount_line, float r, float g, float b);
|
void update_point_vertex_buffer_line(float* pos, int pointCount_line, float r, float g, float b, std::vector<LineVertex>& vertices);
|
||||||
|
void update_point_vertex_buffer_line_save(std::vector<LineVertex>& vertices);
|
||||||
private:
|
private:
|
||||||
std::thread workerThread;
|
std::thread workerThread;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user