虚线的代码完成。
This commit is contained in:
@@ -40,6 +40,13 @@ struct PointVertex {
|
||||
float r, g, b; // 颜色 (可以根据需要修改)
|
||||
};
|
||||
|
||||
struct LineVertex {
|
||||
glm::vec3 position; // 顶点自身位置
|
||||
glm::vec3 color;
|
||||
glm::vec3 lineStart; // 该顶点所属线段的起点
|
||||
glm::vec3 lineEnd; // 该顶点所属线段的终点
|
||||
};
|
||||
|
||||
class TextureLoading : public ApiVulkanSample
|
||||
{
|
||||
public:
|
||||
@@ -84,8 +91,22 @@ public:
|
||||
glm::mat4 view;
|
||||
} ubo_vs_point;
|
||||
|
||||
// 确保内存布局与GLSL中的std140一致
|
||||
struct DashParameters {
|
||||
alignas(4) float dashSize = 5.0f; // 实线长度(像素)
|
||||
alignas(4) float gapSize = 3.0f; // 间隙长度(像素)
|
||||
alignas(4) float dashOffset = 0.0f; // 虚线偏移
|
||||
alignas(4) float uAASize = 1.5f; // 抗锯齿过渡区大小
|
||||
alignas(4) int useWorldSpace = 0; // 0:屏幕空间,1:世界空间
|
||||
// 添加padding以确保大小为16字节的倍数(std140要求)
|
||||
alignas(8) glm::vec2 padding; // 可选,确保16字节对齐
|
||||
}_DashParameters;
|
||||
|
||||
static_assert(sizeof(DashParameters) == 32, "DashParameters size must match GLSL layout");
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_vs;
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_vs_point;
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_DashParameters;
|
||||
|
||||
|
||||
//glm::vec3 camear_pos_point = {0, 0, -2.f};
|
||||
@@ -153,6 +174,8 @@ public:
|
||||
void prepare_uniform_buffers_point();
|
||||
void update_uniform_buffers_point(float fov, float x, float y, float z, float sx, float sy, float sz, float rotx, float roty, float rotz, float camx, float camy, float camz);
|
||||
|
||||
void prepare_uniform_buffers_DashParameters();
|
||||
void update_uniform_buffers_DashParameters(float dashSize, float gapSize, float dashOffset, float uAASize, int useWorldSpace);
|
||||
|
||||
void prepare_pipelines();
|
||||
void prepare_pipeline_bg();
|
||||
|
||||
Reference in New Issue
Block a user